Remove double quotes and flatten "f...@bar.com <f...@bar.com>" to
"f...@bar.com". If the address is of the form "name <f...@bar.com>",
show only 'name' with a tooltip of the address.
---
More aggressive simplification and tooltips.

 emacs/notmuch-show.el |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 9e5d72d..098146b 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)
@@ -198,12 +199,25 @@ any given message."
                                             'face 'notmuch-tag-face)
                                 ")"))))))
 
+(defun notmuch-show-clean-address (parsed-address)
+  "Prepare a single email address for display."
+  (let ((address (car parsed-address))
+       (name (cdr parsed-address)))
+    ;; If the address is 'f...@bar.com <f...@bar.com>' then show just
+    ;; 'f...@bar.com'.
+    (when (string= name address)
+      (setq name nil))
+    (if name
+       (propertize name 'help-echo address)
+       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
            ") ("
@@ -214,7 +228,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

_______________________________________________
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to