* elmo-archive.el (elmo-archive-get-archive-name): Cause an error when
[elisp/wanderlust.git] / wl / wl-address.el
index 02957b8..259ae2b 100644 (file)
@@ -1,8 +1,8 @@
 ;;; wl-address.el -- Tiny address management for Wanderlust.
 
-;; Copyright 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
-;;                          Shun-ichi GOTO <gotoh@taiyo.co.jp>
-;;                          Takeshi Chiba <chiba@d3.bs1.fc.nec.co.jp>
+;; Copyright (C) 1998,1999,2000 Yuuichi Teranishi <teranisi@gohome.org>
+;; Copyright (C) 1998,1999,2000 Shun-ichi GOTO <gotoh@taiyo.co.jp>
+;; Copyright (C) 1998,1999,2000 Takeshi Chiba <chiba@d3.bs1.fc.nec.co.jp>
 
 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
 ;;     Shun-ichi GOTO <gotoh@taiyo.co.jp>
@@ -119,6 +119,7 @@ Returns matched uniq string list."
       (setq type (car (car entry))
            values (mapcar (function wl-ldap-alias-safe-string)
                           (cdr (car entry)))
+           values (elmo-flatten values)
            entry (cdr entry))
       (if (string-match "::?$" type)
          (setq type (substring type 0 (match-beginning 0))))
@@ -134,15 +135,13 @@ Returns matched uniq string list."
 (defun wl-ldap-alias-safe-string (str)
   "Modify STR for alias.
 Replace space/tab in STR into '_' char.
-Replace '@' in STR into '/' char."
+Replace '@' in STR into list of mailbox and sub-domains."
   (while (string-match "[^_a-zA-Z0-9+@%.!\\-/]+" str)
     (setq str (concat (substring str 0 (match-beginning 0))
                      "_"
                      (substring str (match-end 0)))))
   (if (string-match "\\(@\\)[^/@]+" str)
-      (setq str (concat (substring str 0 (match-beginning 1))
-                       "/"
-                       (substring str (match-end 1)))))
+      (setq str (split-string str  "[@\\.]")))
   str)
 
 (defun wl-ldap-register-dn-string (hash dn &optional str dn-list)
@@ -158,7 +157,8 @@ Replace '@' in STR into '/' char."
                                    (if (string-match "[a-z]+=\\(.*\\)" str)
                                        (wl-ldap-alias-safe-string
                                         (wl-match-string 1 str))))
-                                 (split-string dn ",")))))
+                                 (split-string dn "[ \t]*,[ \t]*")))))
+      (setq dn-list (elmo-flatten dn-list))
       ;; prepare candidate for uniq str
       (if str
          (setq str (concat str wl-ldap-alias-sep (car dn-list))
@@ -280,9 +280,11 @@ Matched address lists are append to CL."
        (completing-read "To: " cl)
       (read-string "To: "))))
 
+(defconst wl-address-specials-regexp "[]\"(),.:;<>@[\\]")
+
 (defun wl-address-quote-specials (word)
   "Make quoted string of WORD if needed."
-  (if (assq 'specials (std11-lexical-analyze word))
+  (if (string-match wl-address-specials-regexp word)
       (prin1-to-string word)
     word))
 
@@ -547,7 +549,7 @@ Refresh `wl-address-list', `wl-address-completion-list', and
            (forward-line))
          ret))))
 
-(defsubst wl-address-get-petname-1 (string)
+(defun wl-address-get-petname-1 (string)
   (let ((address (downcase (wl-address-header-extract-address string))))
     (elmo-get-hash-val address wl-address-petname-hash)))