message.el (message-insert-formatted-citation-line): handle finding first/lastname...
authorAdam Sjøgren <asjo@koldfront.dk>
Thu, 16 May 2013 22:00:02 +0000 (00:00 +0200)
committerAdam Sjøgren <asjo@koldfront.dk>
Sun, 19 May 2013 13:18:03 +0000 (15:18 +0200)
lisp/ChangeLog
lisp/message.el

index 9506db7..9efb9fd 100644 (file)
@@ -1,3 +1,8 @@
+2013-05-19  Adam Sjøgren  <asjo@koldfront.dk>
+
+       * message.el (message-insert-formatted-citation-line): handle finding
+       first/lastname when more than 2 names appear.
+
 2013-05-19  Adam Sjøgren  <asjo@koldfront.dk>
 
        * shr.el (shr-tag-span): New function.
index 920e805..2374314 100644 (file)
@@ -3988,18 +3988,16 @@ 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) " "))) )))
              ;; The following letters are not used in `format-time-string':
              (push ?E lst) (push "<E>" lst)
              (push ?F lst) (push fname lst)