[PATCH] emacs: Show cleaner addresses during message display.
authorDavid Edmondson <dme@dme.org>
Fri, 5 Nov 2010 15:04:16 +0000 (15:04 +0000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:37:23 +0000 (09:37 -0800)
db/74eabad1d1d1e2a8f897a2be9064a15be91a10 [new file with mode: 0644]

diff --git a/db/74eabad1d1d1e2a8f897a2be9064a15be91a10 b/db/74eabad1d1d1e2a8f897a2be9064a15be91a10
new file mode 100644 (file)
index 0000000..7771474
--- /dev/null
@@ -0,0 +1,120 @@
+Return-Path: <dme@dme.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 960A240D158\r
+       for <notmuch@notmuchmail.org>; Fri,  5 Nov 2010 08:05:06 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.9\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
+       tests=[BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=ham\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id O4Z3nNfR-d-5 for <notmuch@notmuchmail.org>;\r
+       Fri,  5 Nov 2010 08:04:56 -0700 (PDT)\r
+Received: from mail-ey0-f181.google.com (mail-ey0-f181.google.com\r
+       [209.85.215.181])\r
+       by olra.theworths.org (Postfix) with ESMTP id CF42C4196F2\r
+       for <notmuch@notmuchmail.org>; Fri,  5 Nov 2010 08:04:55 -0700 (PDT)\r
+Received: by eyb6 with SMTP id 6so1860320eyb.26\r
+       for <notmuch@notmuchmail.org>; Fri, 05 Nov 2010 08:04:52 -0700 (PDT)\r
+Received: by 10.216.23.206 with SMTP id v56mr1282963wev.67.1288969491950;\r
+       Fri, 05 Nov 2010 08:04:51 -0700 (PDT)\r
+Received: from ut.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com\r
+       [81.149.164.25])\r
+       by mx.google.com with ESMTPS id x23sm894024weq.34.2010.11.05.08.04.50\r
+       (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
+       Fri, 05 Nov 2010 08:04:51 -0700 (PDT)\r
+Received: by ut.hh.sledj.net (Postfix, from userid 1000)\r
+       id 1CD3F59405B; Fri,  5 Nov 2010 15:04:18 +0000 (GMT)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: Show cleaner addresses during message display.\r
+Date: Fri,  5 Nov 2010 15:04:16 +0000\r
+Message-Id: <1288969456-15997-1-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 1.7.2.3\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Fri, 05 Nov 2010 15:05:06 -0000\r
+\r
+Remove double quotes and flatten "foo@bar.com <foo@bar.com>" to\r
+"foo@bar.com".\r
+---\r
+ emacs/notmuch-show.el |   30 ++++++++++++++++++++++++++++--\r
+ 1 files changed, 28 insertions(+), 2 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 07cf846..2838968 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -26,6 +26,7 @@\r
+ (require 'message)\r
+ (require 'mm-decode)\r
+ (require 'mailcap)\r
++(require 'mail-parse)\r
\r
+ (require 'notmuch-lib)\r
+ (require 'notmuch-query)\r
+@@ -204,12 +205,26 @@ same as that of the previous message."\r
+                                            'face 'notmuch-tag-face)\r
+                                ")"))))))\r
\r
++(defun notmuch-show-clean-address (parsed-address)\r
++  "Clean a single email address for display."\r
++  (let ((address (car parsed-address))\r
++      (name (cdr parsed-address)))\r
++    ;; If the address is 'foo@bar.com <foo@bar.com>' then show just\r
++    ;; 'foo@bar.com'.\r
++    (when (string= name address)\r
++      (setq name nil))\r
++\r
++    (if (not name)\r
++      address\r
++      (concat name " <" address ">"))))\r
++\r
+ (defun notmuch-show-insert-headerline (headers date tags depth)\r
+   "Insert a notmuch style headerline based on HEADERS for a\r
+ message at DEPTH in the current thread."\r
+   (let ((start (point)))\r
+     (insert (notmuch-show-spaces-n depth)\r
+-          (plist-get headers :From)\r
++          (notmuch-show-clean-address\r
++           (mail-header-parse-address (plist-get headers :From)))\r
+           " ("\r
+           date\r
+           ") ("\r
+@@ -220,7 +235,18 @@ message at DEPTH in the current thread."\r
\r
+ (defun notmuch-show-insert-header (header header-value)\r
+   "Insert a single header."\r
+-  (insert header ": " header-value "\n"))\r
++  (insert header ": "\r
++        (cond\r
++         ((or (string= "To" header)\r
++              (string= "Cc" header)\r
++              (string= "Bcc" header)\r
++              (string= "From" header))\r
++          (mapconcat 'notmuch-show-clean-address\r
++                     (mail-header-parse-addresses header-value)\r
++                     ", "))\r
++         (t\r
++          header-value))\r
++        "\n"))\r
\r
+ (defun notmuch-show-insert-headers (headers)\r
+   "Insert the headers of the current message."\r
+-- \r
+1.7.2.3\r
+\r