Try this:

*** bbdb.el.~1~ Fri Feb 18 14:40:21 1994
--- bbdb.el     Mon Apr 11 17:38:29 1994
***************
*** 1818,1824 ****
  If PROMPT-TO-CREATE-P is true, then the user will be asked for confirmation
  before the record is created, otherwise it is created without confirmation 
  \(assuming that CREATE-P is true\).  "
!   (let* ((data (mail-extract-address-components from))
         (name (car data))
         (net (car (cdr data))))
      (if (equal name net) (setq name nil))
--- 1818,1826 ----
  If PROMPT-TO-CREATE-P is true, then the user will be asked for confirmation
  before the record is created, otherwise it is created without confirmation 
  \(assuming that CREATE-P is true\).  "
!   (let* ((data (if (consp from)
!                  from ; if from is a cons, it's pre-parsed (hack hack)
!                (mail-extract-address-components from)))
         (name (car data))
         (net (car (cdr data))))
      (if (equal name net) (setq name nil))
*** bbdb-vm.el.~1~      Tue Mar 29 12:47:48 1994
--- bbdb-vm.el  Mon Apr 11 17:38:32 1994
***************
*** 30,78 ****
  (or (boundp 'vm-mode-map)
      (load-library "vm-vars"))
  
  (defun bbdb/vm-update-record (&optional offer-to-create)
!   "returns the record corresponding to the current VM message, creating or
! modifying it as necessary.  A record will be created if 
  bbdb/mail-auto-create-p is non-nil, or if OFFER-TO-CREATE is true and
  the user confirms the creation."
    (save-excursion
!   (and vm-mail-buffer (set-buffer vm-mail-buffer))
!   (if bbdb-use-pop-up
!       (bbdb/vm-pop-up-bbdb-buffer offer-to-create)
!     (let ((msg (car vm-message-pointer))
!         (inhibit-local-variables nil) ; vm binds this to t...
!         (enable-local-variables t)    ; ...or vm bind this to nil.
!         (inhibit-quit nil))   ; vm damn well better not bind this to t!
!       ;; this doesn't optimize the case of moving thru a folder where
!       ;; few messages have associated records.
!       (or (bbdb-message-cache-lookup msg nil)  ; nil = current-buffer
!         (and msg
!           ;; ## Note: once VM uses mail-extr.el, we should just get the
!           ;; ## name and address from `vm-su-full-name' and `vm-su-from'
!           ;; ## instead of parsing it again here.
!           (save-excursion
!             (save-restriction
!               ;; Select the buffer containing the message.
!               ;; Needed to handle VM virtual folders.
!               (set-buffer (marker-buffer (vm-start-of msg)))
!               (widen)
!               (narrow-to-region (vm-start-of msg) (vm-end-of msg))
!               (let ((from (mail-fetch-field "from")))
!                 (if (or (null from)
!                         (string-match (bbdb-user-mail-names)
!                           ;; mail-strip-quoted-names is too broken!
!                           ;;(mail-strip-quoted-names from)
!                           (car (cdr (mail-extract-address-components
!                                      from)))))
!                     ;; if logged in user sent this, use recipients.
!                     (setq from (or (mail-fetch-field "to") from)))
!                 (if from
!                     (bbdb-encache-message msg
!                       (bbdb-annotate-message-sender from t
!                         (or (bbdb-invoke-hook-for-value
!                              bbdb/mail-auto-create-p)
!                             offer-to-create)
!                         offer-to-create))))))))))))
  
  (defun bbdb/vm-annotate-sender (string)
    "Add a line to the end of the Notes field of the BBDB record 
--- 30,100 ----
  (or (boundp 'vm-mode-map)
      (load-library "vm-vars"))
  
+ (defun bbdb/vm-get-from (msg)
+   (setq msg (vm-real-message-of msg))
+   (if (and (boundp 'vm-chop-full-name-function)
+          (eq vm-chop-full-name-function 'mail-extract-address-components))
+       ;; Good, VM is using mail-extr.el to do its parsing.  That means
+       ;; we can trust the data in the pre-parsed full-name and
+       (let ((n (vm-su-full-name msg))
+           (a (vm-su-from msg)))
+       ;; if logged in user sent this, use recipients.
+       (if (string-match (bbdb-user-mail-names) (or a ""))
+           (setq n (vm-su-to-names msg)
+                 a (vm-su-to msg)))
+       (if (= (length n) 0) (setq n nil))
+       (if (= (length a) 0) (setq a nil))
+       (if (equal n a) (setq n nil))
+       (list n a))
+     ;; Bad, VM isn't using mail-extr, so we need to find the folder buffer
+     ;; and parse out the From: field ourselves...
+     (save-excursion
+       (save-restriction
+       ;; Select the buffer containing the message.
+       ;; Needed to handle VM virtual folders.
+       (set-buffer (vm-buffer-of msg))
+       (widen)
+       (narrow-to-region (vm-start-of msg) (vm-end-of msg))
+       (let ((from (mail-fetch-field "from")))
+         (if (or (null from)
+                 (string-match (bbdb-user-mail-names)
+                               ;; mail-strip-quoted-names is too broken!
+                               ;;(mail-strip-quoted-names from)
+                               (car (cdr (mail-extract-address-components
+                                          from)))))
+             ;; if logged in user sent this, use recipients.
+             (setq from (or (mail-fetch-field "to") from)))
+         from)))))
+ 
  (defun bbdb/vm-update-record (&optional offer-to-create)
!   "Returns the record corresponding to the current VM message, 
! creating or modifying it as necessary.  A record will be created if 
  bbdb/mail-auto-create-p is non-nil, or if OFFER-TO-CREATE is true and
  the user confirms the creation."
    (save-excursion
!     (vm-select-folder-buffer)
!     (vm-check-for-killed-summary)
!     (vm-error-if-folder-empty)
!     (if bbdb-use-pop-up
!       (bbdb/vm-pop-up-bbdb-buffer offer-to-create)
!       (let ((msg (car vm-message-pointer))
!           (inhibit-local-variables nil) ; vm binds this to t...
!           (enable-local-variables t)    ; ...or vm bind this to nil.
!           (inhibit-quit nil))  ; vm damn well better not bind this to t!
!       ;; this doesn't optimize the case of moving thru a folder where
!       ;; few messages have associated records.
!       (or (bbdb-message-cache-lookup msg nil) ; nil = current-buffer
!           (and msg
!                (let ((from (bbdb/vm-get-from msg)))
!                  (if from
!                      (bbdb-encache-message
!                       msg
!                       (bbdb-annotate-message-sender
!                        from t
!                        (or (bbdb-invoke-hook-for-value
!                             bbdb/mail-auto-create-p)
!                            offer-to-create)
!                        offer-to-create))))))))))
  
  (defun bbdb/vm-annotate-sender (string)
    "Add a line to the end of the Notes field of the BBDB record 

Reply via email to