Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 4F9DD40DAEA for ; Tue, 9 Nov 2010 09:36:26 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.9 X-Spam-Level: X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8lXq7+qhMBvj for ; Tue, 9 Nov 2010 09:36:15 -0800 (PST) Received: from mail-ew0-f53.google.com (mail-ew0-f53.google.com [209.85.215.53]) by olra.theworths.org (Postfix) with ESMTP id AC3C940DAC6 for ; Tue, 9 Nov 2010 09:36:15 -0800 (PST) Received: by ewy10 with SMTP id 10so4161115ewy.26 for ; Tue, 09 Nov 2010 09:36:13 -0800 (PST) Received: by 10.216.0.7 with SMTP id 7mr7165800wea.22.1289324172811; Tue, 09 Nov 2010 09:36:12 -0800 (PST) Received: from ut.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com [81.149.164.25]) by mx.google.com with ESMTPS id 7sm1046210wet.24.2010.11.09.09.36.06 (version=TLSv1/SSLv3 cipher=RC4-MD5); Tue, 09 Nov 2010 09:36:07 -0800 (PST) Received: by ut.hh.sledj.net (Postfix, from userid 1000) id D8AA359405B; Tue, 9 Nov 2010 17:34:51 +0000 (GMT) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH] emacs: Show cleaner addresses during message display. Date: Tue, 9 Nov 2010 17:34:50 +0000 Message-Id: <1289324090-25246-1-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.2.3 In-Reply-To: <1288969456-15997-1-git-send-email-dme@dme.org> References: <1288969456-15997-1-git-send-email-dme@dme.org> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Nov 2010 17:36:26 -0000 Remove double quotes and flatten "foo@bar.com " to "foo@bar.com". If the address is of the form "name ", 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 'foo@bar.com ' then show just + ;; 'foo@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