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 960A240D158 for ; Fri, 5 Nov 2010 08:05:06 -0700 (PDT) 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 O4Z3nNfR-d-5 for ; Fri, 5 Nov 2010 08:04:56 -0700 (PDT) Received: from mail-ey0-f181.google.com (mail-ey0-f181.google.com [209.85.215.181]) by olra.theworths.org (Postfix) with ESMTP id CF42C4196F2 for ; Fri, 5 Nov 2010 08:04:55 -0700 (PDT) Received: by eyb6 with SMTP id 6so1860320eyb.26 for ; Fri, 05 Nov 2010 08:04:52 -0700 (PDT) Received: by 10.216.23.206 with SMTP id v56mr1282963wev.67.1288969491950; Fri, 05 Nov 2010 08:04:51 -0700 (PDT) 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 x23sm894024weq.34.2010.11.05.08.04.50 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 05 Nov 2010 08:04:51 -0700 (PDT) Received: by ut.hh.sledj.net (Postfix, from userid 1000) id 1CD3F59405B; Fri, 5 Nov 2010 15:04:18 +0000 (GMT) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH] emacs: Show cleaner addresses during message display. Date: Fri, 5 Nov 2010 15:04:16 +0000 Message-Id: <1288969456-15997-1-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.2.3 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: Fri, 05 Nov 2010 15:05:06 -0000 Remove double quotes and flatten "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 ' 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