1 Return-Path: <dme@dme.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id 42EFC431FB6
\r
6 for <notmuch@notmuchmail.org>; Mon, 16 Jan 2012 09:08:36 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id Lw3t2wpx1p6y for <notmuch@notmuchmail.org>;
\r
16 Mon, 16 Jan 2012 09:08:35 -0800 (PST)
\r
17 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com
\r
18 [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 4AAAF431FD4
\r
21 for <notmuch@notmuchmail.org>; Mon, 16 Jan 2012 09:08:35 -0800 (PST)
\r
22 Received: by werb13 with SMTP id b13so21040wer.26
\r
23 for <notmuch@notmuchmail.org>; Mon, 16 Jan 2012 09:08:34 -0800 (PST)
\r
24 Received: by 10.180.94.102 with SMTP id db6mr19075389wib.0.1326733713981;
\r
25 Mon, 16 Jan 2012 09:08:33 -0800 (PST)
\r
26 Received: from hotblack-desiato.hh.sledj.net
\r
27 (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])
\r
28 by mx.google.com with ESMTPS id gf8sm23009719wbb.11.2012.01.16.09.08.32
\r
29 (version=TLSv1/SSLv3 cipher=OTHER);
\r
30 Mon, 16 Jan 2012 09:08:33 -0800 (PST)
\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)
\r
32 id 0B4F0A0397; Mon, 16 Jan 2012 17:08:31 +0000 (GMT)
\r
33 From: David Edmondson <dme@dme.org>
\r
34 To: notmuch@notmuchmail.org
\r
35 Subject: [PATCH 1/2] emacs: Avoid `mail-header-parse-address' in
\r
36 `notmuch-show-clean-address'.
\r
37 Date: Mon, 16 Jan 2012 17:08:28 +0000
\r
38 Message-Id: <1326733709-25985-1-git-send-email-dme@dme.org>
\r
39 X-Mailer: git-send-email 1.7.7.3
\r
40 In-Reply-To: <1326732453-23377-2-git-send-email-dme@dme.org>
\r
41 References: <1326732453-23377-2-git-send-email-dme@dme.org>
\r
42 X-BeenThere: notmuch@notmuchmail.org
\r
43 X-Mailman-Version: 2.1.13
\r
45 List-Id: "Use and development of the notmuch mail system."
\r
46 <notmuch.notmuchmail.org>
\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
50 List-Post: <mailto:notmuch@notmuchmail.org>
\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
54 X-List-Received-Date: Mon, 16 Jan 2012 17:08:36 -0000
\r
56 `mail-header-parse-address' expects un-decoded mailbox parts, which is
\r
57 not what we have at this point. Replace it with simple string
\r
61 Fix the failing test in the previous set.
\r
63 emacs/notmuch-show.el | 48 +++++++++++++++++++++++++++++++++++-------------
\r
64 1 files changed, 35 insertions(+), 13 deletions(-)
\r
66 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
67 index 1a250a3..02819f3 100644
\r
68 --- a/emacs/notmuch-show.el
\r
69 +++ b/emacs/notmuch-show.el
\r
70 @@ -227,21 +227,43 @@ indentation."
\r
71 "Try to clean a single email ADDRESS for display. Return
\r
72 unchanged ADDRESS if parsing fails."
\r
74 - (let* ((parsed (mail-header-parse-address address))
\r
75 - (address (car parsed))
\r
76 - (name (cdr parsed)))
\r
77 - ;; Remove double quotes. They might be required during transport,
\r
78 - ;; but we don't need to see them.
\r
80 - (setq name (replace-regexp-in-string "\"" "" name)))
\r
81 + (let (p-name p-address)
\r
82 + ;; It would be convenient to use `mail-header-parse-address',
\r
83 + ;; but that expects un-decoded mailbox parts, whereas our
\r
84 + ;; mailbox parts are already decoded (and hence may contain
\r
85 + ;; UTF-8). Given that notmuch should handle most of the awkward
\r
86 + ;; cases, some simple string deconstruction should be sufficient
\r
89 + ;; "User <user@dom.ain>" style.
\r
90 + ((string-match "\\(.*\\) <\\(.*\\)>" address)
\r
91 + (setq p-name (match-string 1 address)
\r
92 + p-address (match-string 2 address)))
\r
94 + ;; "<user@dom.ain>" style.
\r
95 + ((string-match "<\\(.*\\)>" address)
\r
96 + (setq p-address (match-string 1 address)))
\r
98 + ;; Everything else.
\r
100 + (setq p-address address)))
\r
102 + ;; Remove outer double quotes. They might be required during
\r
103 + ;; transport, but we don't need to see them.
\r
104 + (when (and p-name
\r
105 + (string-match "^\"\\(.*\\)\"$" p-name))
\r
106 + (setq p-name (match-string 1 p-name)))
\r
108 ;; If the address is 'foo@bar.com <foo@bar.com>' then show just
\r
110 - (when (string= name address)
\r
115 - (concat name " <" address ">")))
\r
116 + (when (string= p-name p-address)
\r
117 + (setq p-name nil))
\r
119 + ;; If no name results, return just the address.
\r
122 + ;; Otherwise format the name and address together.
\r
123 + (concat p-name " <" p-address ">")))
\r
126 (defun notmuch-show-insert-headerline (headers date tags depth)
\r