X-Git-Url: https://cgit.sxemacs.org/?a=blobdiff_plain;f=lisp%2Fmessage.el;h=ca1a2e6fbc248694fc0903ff1df7d2e3be3990c7;hb=378aea34bb2b6ea37439350a3d432fd510b8e223;hp=920e805eec937253bc60a80e654e1ce431df6757;hpb=786ff2141fd1613c88035aae899ec9d71ffb5cd0;p=gnus diff --git a/lisp/message.el b/lisp/message.el index 920e805ee..ca1a2e6fb 100644 --- a/lisp/message.el +++ b/lisp/message.el @@ -3988,18 +3988,19 @@ See `message-citation-line-format'." (let ((i ?A) lst) (when (stringp name) ;; Guess first name and last name: - (cond ((string-match - "\\`\\(\\w\\|[-.]\\)+ \\(\\w\\|[-.]\\)+\\'" name) - (setq fname (nth 0 (split-string name "[ \t]+")) - lname (nth 1 (split-string name "[ \t]+")))) - ((string-match - "\\`\\(\\w\\|[-.]\\)+, \\(\\w\\|[-.]\\)+\\'" name) - (setq fname (nth 1 (split-string name "[ \t,]+")) - lname (nth 0 (split-string name "[ \t,]+")))) - ((string-match - "\\`\\(\\w\\|[-.]\\)+\\'" name) - (setq fname name - lname "")))) + (let* ((names (delq nil (mapcar (lambda (x) + (if (string-match "\\`\\(\\w\\|[-.]\\)+\\'" x) x nil)) + (split-string name "[ \t]+")))) + (count (length names))) + (cond ((= count 1) (setq fname (car names) + lname "")) + ((or (= count 2) (= count 3)) (setq fname (car names) + lname (mapconcat 'identity (cdr names) " "))) + ((> count 3) (setq fname (mapconcat 'identity (butlast names (- count 2)) " ") + lname (mapconcat 'identity (nthcdr 2 names) " "))) ) + (when (string-match "\\(.*\\),\\'" fname) + (let ((newlname (match-string 1 fname))) + (setq fname lname lname newlname))))) ;; The following letters are not used in `format-time-string': (push ?E lst) (push "" lst) (push ?F lst) (push fname lst)