From: David Edmondson Date: Wed, 19 May 2010 10:21:05 +0000 (+0100) Subject: emacs: Show cleaner `From:' addresses in the summary line. X-Git-Tag: debian/0.6_254~145 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=0898cfad5ef2d7c000e9c23e9205e02aec18cc24;p=notmuch.git emacs: Show cleaner `From:' addresses in the summary line. Remove double quotes and flatten "foo@bar.com " to "foo@bar.com". Edited-by: Daniel Kahn Gillmor (clean up expected output for emacs tests). Signed-off-by: Jameson Rollins --- diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el index 9c174e25..ed7037a1 100644 --- a/emacs/notmuch-show.el +++ b/emacs/notmuch-show.el @@ -222,12 +222,30 @@ same as that of the previous message." 'face 'notmuch-tag-face) ")")))))) +(defun notmuch-show-clean-address (address) + "Clean a single email address for display." + (let* ((parsed (mail-header-parse-address address)) + (address (car parsed)) + (name (cdr parsed))) + ;; Remove double quotes. They might be required during transport, + ;; but we don't need to see them. + (when name + (setq name (replace-regexp-in-string "\"" "" name))) + ;; If the address is 'foo@bar.com ' then show just + ;; 'foo@bar.com'. + (when (string= name address) + (setq name nil)) + + (if (not name) + address + (concat name " <" address ">")))) + (defun notmuch-show-insert-headerline (headers date tags depth) "Insert a notmuch style headerline based on HEADERS for a message at DEPTH in the current thread." (let ((start (point))) (insert (notmuch-show-spaces-n depth) - (plist-get headers :From) + (notmuch-show-clean-address (plist-get headers :From)) " (" date ") (" diff --git a/test/emacs.expected-output/notmuch-show-thread-maildir-storage b/test/emacs.expected-output/notmuch-show-thread-maildir-storage index 6eed85b8..a0fc1407 100644 --- a/test/emacs.expected-output/notmuch-show-thread-maildir-storage +++ b/test/emacs.expected-output/notmuch-show-thread-maildir-storage @@ -101,7 +101,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch - "Mikhail Gusarov" (2009-11-17) (inbox unread) + Mikhail Gusarov (2009-11-17) (inbox unread) Subject: [notmuch] Working with Maildir storage? To: notmuch@notmuchmail.org Date: Wed, 18 Nov 2009 02:50:48 +0600 @@ -129,7 +129,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch Desc: not available URL: - "Keith Packard" (2009-11-17) (inbox unread) + Keith Packard (2009-11-17) (inbox unread) Subject: [notmuch] Working with Maildir storage? To: notmuch@notmuchmail.org Date: Tue, 17 Nov 2009 13:24:13 -0800 @@ -179,7 +179,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch notmuch mailing list notmuch@notmuchmail.org http://notmuchmail.org/mailman/listinfo/notmuch - "Carl Worth" (2009-11-18) (inbox unread) + Carl Worth (2009-11-18) (inbox unread) Subject: [notmuch] Working with Maildir storage? To: notmuch@notmuchmail.org Date: Wed, 18 Nov 2009 02:08:10 -0800