From: Adam Sjøgren Date: Sun, 19 May 2013 22:50:16 +0000 (+0000) Subject: lisp/gnus/message.el (message-insert-formatted-citation-line): Handle finding first... X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2026^2~229^2~28 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=047dc96582413e3ee76a816f1d49f1c63f04d969;p=emacs.git lisp/gnus/message.el (message-insert-formatted-citation-line): Handle finding first/lastname when more than 2 names appear --- diff --git a/lisp/gnus/ChangeLog b/lisp/gnus/ChangeLog index 8d380695ec1..def8ef0db14 100644 --- a/lisp/gnus/ChangeLog +++ b/lisp/gnus/ChangeLog @@ -1,3 +1,8 @@ +2013-05-19 Adam Sjøgren + + * message.el (message-insert-formatted-citation-line): Handle finding + first/lastname when more than 2 names appear. + 2013-05-19 Adam Sjøgren * shr.el (shr-tag-span): New function. diff --git a/lisp/gnus/message.el b/lisp/gnus/message.el index a14f257aaf3..c6f5d904677 100644 --- a/lisp/gnus/message.el +++ b/lisp/gnus/message.el @@ -3944,18 +3944,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)