emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r112641: lisp/gnus/message.el (messag


From: Katsumi Yamaoka
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r112641: lisp/gnus/message.el (message-insert-formatted-citation-line): Handle finding first/lastname when more than 2 names appear
Date: Sun, 19 May 2013 22:50:16 +0000
User-agent: Bazaar (2.6b2)

------------------------------------------------------------
revno: 112641
author: Adam Sjøgren <address@hidden>
committer: Katsumi Yamaoka <address@hidden>
branch nick: trunk
timestamp: Sun 2013-05-19 22:50:16 +0000
message:
  lisp/gnus/message.el (message-insert-formatted-citation-line): Handle finding 
first/lastname when more than 2 names appear
modified:
  lisp/gnus/ChangeLog
  lisp/gnus/message.el
=== modified file 'lisp/gnus/ChangeLog'
--- a/lisp/gnus/ChangeLog       2013-05-19 22:49:17 +0000
+++ b/lisp/gnus/ChangeLog       2013-05-19 22:50:16 +0000
@@ -1,5 +1,10 @@
 2013-05-19  Adam Sjøgren  <address@hidden>
 
+       * message.el (message-insert-formatted-citation-line): Handle finding
+       first/lastname when more than 2 names appear.
+
+2013-05-19  Adam Sjøgren  <address@hidden>
+
        * shr.el (shr-tag-span): New function.
 
 2013-05-18  Glenn Morris  <address@hidden>

=== modified file 'lisp/gnus/message.el'
--- a/lisp/gnus/message.el      2013-05-18 00:30:49 +0000
+++ b/lisp/gnus/message.el      2013-05-19 22:50:16 +0000
@@ -3944,18 +3944,19 @@
            (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 "<E>" lst)
              (push ?F lst) (push fname lst)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]