Synch up with main trunk (bbdb-wl.el).
authorteranisi <teranisi>
Thu, 1 Feb 2001 00:39:20 +0000 (00:39 +0000)
committerteranisi <teranisi>
Thu, 1 Feb 2001 00:39:20 +0000 (00:39 +0000)
utils/bbdb-wl.el

index 197cfe8..7c1a86a 100644 (file)
   (require 'mime-setup)
   (require 'elmo-vars)
   (require 'elmo-util)
-  (require 'bbdb)
   (require 'wl-summary)
   (require 'wl-message)
   (require 'wl-draft)
   (require 'wl-address)
-  (defvar bbdb-pop-up-elided-display nil)
-  (or (fboundp 'bbdb-extract-field-value-internal)
-      (defun bbdb-extract-field-value-internal (field))))
+  (defvar bbdb-pop-up-elided-display nil))
+;;  (or (fboundp 'bbdb-wl-extract-field-value-internal)
+;;      (defun bbdb-wl-extract-field-value-internal (field))))
+(require 'bbdb)
 
 (defvar bbdb-wl-get-update-record-hook nil)
 
 (defun bbdb-wl-setup ()
-  (require 'bbdb)
   (add-hook 'wl-message-redisplay-hook 'bbdb-wl-get-update-record)
   (add-hook 'wl-summary-exit-hook 'bbdb-wl-hide-bbdb-buffer)
   (add-hook 'wl-message-window-deleted-hook 'bbdb-wl-hide-bbdb-buffer)
        (let ((pop-up-windows nil))
          (switch-to-buffer (get-buffer-create bbdb-buffer-name)))))))
 
+(defun bbdb-wl-get-petname (from)
+  "For `wl-summary-get-petname-func'."
+  (let* ((address (wl-address-header-extract-address from))
+        (record (bbdb-search-simple nil address)))
+    (and record
+        (or (bbdb-record-name record)
+            (car (bbdb-record-name record))))))
+
 (defun bbdb-wl-from-func (string)
   "A candidate From field STRING.  For `wl-summary-from-func'."
   (let ((hit (bbdb-search-simple nil (wl-address-header-extract-address
@@ -249,20 +256,21 @@ displaying the record corresponding to the sender of the current message."
 
 ;;; @ bbdb-extract-field-value -- stolen from tm-bbdb.
 ;;;
-(and (not (fboundp 'bbdb-extract-field-value-internal))
+(and (not (fboundp 'bbdb-wl-extract-field-value-internal))
 ;;;  (not (fboundp 'PLEASE_REPLACE_WITH_SEMI-BASED_MIME-BBDB)) ;; mime-bbdb
     (progn
-;;;   (require 'bbdb-hooks) ; not provided.
-;;;   (or (fboundp 'bbdb-extract-field-value) ; defined as autoload
-      (or (fboundp 'bbdb-header-start)
-          (load "bbdb-hooks"))
-      (fset 'bbdb-extract-field-value-internal
+      (if (and (string< bbdb-version "1.58")
+              ;; (not (fboundp 'bbdb-extract-field-value) ; defined as autoload
+              (not (fboundp 'bbdb-header-start)))
+         (load "bbdb-hooks")
+       (require 'bbdb-hooks))
+      (fset 'bbdb-wl-extract-field-value-internal
            (cond
             ((fboundp 'tm:bbdb-extract-field-value)
              (symbol-function 'tm:bbdb-extract-field-value))
             (t (symbol-function 'bbdb-extract-field-value))))
       (defun bbdb-extract-field-value (field)
-       (let ((value (bbdb-extract-field-value-internal field)))
+       (let ((value (bbdb-wl-extract-field-value-internal field)))
          (with-temp-buffer ; to keep raw buffer unibyte.
            (elmo-set-buffer-multibyte
             default-enable-multibyte-characters)