emacs: Show cleaner `From:' addresses in the summary line.

Remove double quotes and flatten "foo@bar.com <foo@bar.com>" to
"foo@bar.com".

Edited-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net> (clean up
expected output for emacs tests).

Signed-off-by: Jameson Rollins <jrollins@finestructure.net>
This commit is contained in:
David Edmondson 2010-05-19 11:21:05 +01:00 committed by Carl Worth
parent 4f04d2734f
commit 0898cfad5e
2 changed files with 22 additions and 4 deletions

View file

@ -222,12 +222,30 @@ same as that of the previous message."
'face 'notmuch-tag-face) '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 <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) (defun notmuch-show-insert-headerline (headers date tags depth)
"Insert a notmuch style headerline based on HEADERS for a "Insert a notmuch style headerline based on HEADERS for a
message at DEPTH in the current thread." message at DEPTH in the current thread."
(let ((start (point))) (let ((start (point)))
(insert (notmuch-show-spaces-n depth) (insert (notmuch-show-spaces-n depth)
(plist-get headers :From) (notmuch-show-clean-address (plist-get headers :From))
" (" " ("
date date
") (" ") ("

View file

@ -101,7 +101,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
notmuch mailing list notmuch mailing list
notmuch@notmuchmail.org notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch http://notmuchmail.org/mailman/listinfo/notmuch
"Mikhail Gusarov" <dottedmag@dottedmag.net> (2009-11-17) (inbox unread) Mikhail Gusarov <dottedmag@dottedmag.net> (2009-11-17) (inbox unread)
Subject: [notmuch] Working with Maildir storage? Subject: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org To: notmuch@notmuchmail.org
Date: Wed, 18 Nov 2009 02:50:48 +0600 Date: Wed, 18 Nov 2009 02:50:48 +0600
@ -129,7 +129,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
Desc: not available Desc: not available
URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20091118/0e33d964/attachment.pgp> URL: <http://notmuchmail.org/pipermail/notmuch/attachments/20091118/0e33d964/attachment.pgp>
"Keith Packard" <keithp@keithp.com> (2009-11-17) (inbox unread) Keith Packard <keithp@keithp.com> (2009-11-17) (inbox unread)
Subject: [notmuch] Working with Maildir storage? Subject: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org To: notmuch@notmuchmail.org
Date: Tue, 17 Nov 2009 13:24:13 -0800 Date: Tue, 17 Nov 2009 13:24:13 -0800
@ -179,7 +179,7 @@ http://notmuchmail.org/mailman/listinfo/notmuch
notmuch mailing list notmuch mailing list
notmuch@notmuchmail.org notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch http://notmuchmail.org/mailman/listinfo/notmuch
"Carl Worth" <cworth@cworth.org> (2009-11-18) (inbox unread) Carl Worth <cworth@cworth.org> (2009-11-18) (inbox unread)
Subject: [notmuch] Working with Maildir storage? Subject: [notmuch] Working with Maildir storage?
To: notmuch@notmuchmail.org To: notmuch@notmuchmail.org
Date: Wed, 18 Nov 2009 02:08:10 -0800 Date: Wed, 18 Nov 2009 02:08:10 -0800