Synch up with main trunk, and prepare the release 2.12.0.
[elisp/wanderlust.git] / wl / wl-address.el
index 6026ad6..d539d6b 100644 (file)
@@ -37,7 +37,7 @@
 (require 'wl-vars)
 (require 'std11)
 
-(defvar wl-address-complete-header-list 
+(defvar wl-address-complete-header-list
   '("To:" "From:" "Cc:" "Bcc:" "Mail-Followup-To:" "Reply-To:"
     "Return-Receipt-To:"))
 (defvar wl-address-complete-header-regexp nil) ; auto-generated.
@@ -87,7 +87,7 @@ If level 3 is required for uniqness with other candidates,
 (defconst wl-ldap-alias-sep "/")
 
 (defconst wl-ldap-search-attribute-type-list
-  '("sn" "cn" "mail" "email" "displayName" "gecos"))
+  '("sn" "cn" "mail" "email"))
 
 (defun wl-ldap-get-value (type entry)
   ""
@@ -207,7 +207,7 @@ Matched address lists are append to CL."
        (ldap-default-base (or wl-ldap-base ldap-default-base))
        (dnhash (elmo-make-hash))
        cache len sym tmpl regexp entries ent values dn dnstr alias
-       result fullname mails)
+       result cn mails)
     ;; check cache
     (mapatoms (lambda (atom)
                (if (and (string-match
@@ -244,9 +244,7 @@ Matched address lists are append to CL."
                    ent)
            mails (or (wl-ldap-get-value-list "mail" ent)
                      (wl-ldap-get-value-list "email" ent))
-           fullname (or (wl-ldap-get-value "displayName" ent)
-                        (wl-ldap-get-value "gecos" ent)
-                        (wl-ldap-get-value "cn" ent))
+           cn (wl-ldap-get-value "cn" ent)
            dn (car (car entries))
            dnstr (elmo-get-hash-val (upcase dn) dnhash))
       ;; make alias list generated from LDAP data.
@@ -261,7 +259,7 @@ Matched address lists are append to CL."
        (when (not (boundp sym))
          (set sym alias)
          (setq result (cons (cons alias
-                                  (concat fullname " <" (car mails) ">"))
+                                  (concat cn " <" (car mails) ">"))
                             result)))
        (setq values (cdr values)))
       ;; make mail addrses list
@@ -270,7 +268,7 @@ Matched address lists are append to CL."
            ;; (string-match regexp (car mails))
            ;; add mail address itself to completion list
            (setq result (cons (cons (car mails)
-                                    (concat fullname " <" (car mails) ">"))
+                                    (concat cn " <" (car mails) ">"))
                               result)))
        (setq mails (cdr mails)))
       (setq entries (cdr entries)))
@@ -735,6 +733,31 @@ If already registerd, change it."
        (wl-address-init)
        (list (or new-addr address) the-petname the-realname)))))
 
+;; Read addresses from minibuffer with completion.
+(defvar wl-address-minibuffer-history nil)
+(defvar wl-address-minibuffer-local-map nil
+  "Keymap to use when reading address from the minibuffer.")
+
+(unless wl-address-minibuffer-local-map
+  (let ((map (make-sparse-keymap)))
+    (set-keymap-parent map minibuffer-local-map)
+    (define-key map "\C-i"
+      (lambda ()
+       (interactive)
+       (wl-complete-field-body wl-address-completion-list
+                               ?@ nil wl-use-ldap)))
+    (setq wl-address-minibuffer-local-map map)))
+
+(defun wl-address-read-from-minibuffer (prompt &optional
+                                              initial-contents
+                                              default-value)
+  (read-from-minibuffer prompt
+                       initial-contents
+                       wl-address-minibuffer-local-map
+                       nil
+                       'wl-address-minibuffer-history
+                       default-value))
+
 (require 'product)
 (product-provide (provide 'wl-address) (require 'wl-version))