unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: Show cleaner addresses during message display.
@ 2010-11-05 15:04 David Edmondson
  2010-11-09 17:34 ` David Edmondson
  0 siblings, 1 reply; 9+ messages in thread
From: David Edmondson @ 2010-11-05 15:04 UTC (permalink / raw)
  To: notmuch

Remove double quotes and flatten "foo@bar.com <foo@bar.com>" to
"foo@bar.com".
---
 emacs/notmuch-show.el |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 07cf846..2838968 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -26,6 +26,7 @@
 (require 'message)
 (require 'mm-decode)
 (require 'mailcap)
+(require 'mail-parse)
 
 (require 'notmuch-lib)
 (require 'notmuch-query)
@@ -204,12 +205,26 @@ same as that of the previous message."
 					     'face 'notmuch-tag-face)
 				 ")"))))))
 
+(defun notmuch-show-clean-address (parsed-address)
+  "Clean a single email address for display."
+  (let ((address (car parsed-address))
+	(name (cdr parsed-address)))
+    ;; 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)
   "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
+	     (mail-header-parse-address (plist-get headers :From)))
 	    " ("
 	    date
 	    ") ("
@@ -220,7 +235,18 @@ message at DEPTH in the current thread."
 
 (defun notmuch-show-insert-header (header header-value)
   "Insert a single header."
-  (insert header ": " header-value "\n"))
+  (insert header ": "
+	  (cond
+	   ((or (string= "To" header)
+		(string= "Cc" header)
+		(string= "Bcc" header)
+		(string= "From" header))
+	    (mapconcat 'notmuch-show-clean-address
+		       (mail-header-parse-addresses header-value)
+		       ", "))
+	   (t
+	    header-value))
+	  "\n"))
 
 (defun notmuch-show-insert-headers (headers)
   "Insert the headers of the current message."
-- 
1.7.2.3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2010-11-12  8:00 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-05 15:04 [PATCH] emacs: Show cleaner addresses during message display David Edmondson
2010-11-09 17:34 ` David Edmondson
2010-11-09 20:53   ` Jameson Rollins
2010-11-10  7:20     ` Sebastian Spaeth
2010-11-10  8:27       ` David Edmondson
2010-11-10  9:17         ` Sebastian Spaeth
2010-11-10  9:23         ` David Edmondson
2010-11-12  1:14           ` Carl Worth
2010-11-12  7:58             ` David Edmondson

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).