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 EDC1B429E34
\r
6 for <notmuch@notmuchmail.org>; Mon, 30 Jan 2012 07:00:04 -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 C8L2jqD6TRXW for <notmuch@notmuchmail.org>;
\r
16 Mon, 30 Jan 2012 07:00:04 -0800 (PST)
\r
17 Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com
\r
18 [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client
\r
19 certificate requested) by olra.theworths.org (Postfix) with ESMTPS id
\r
20 DB4CA431FBC for <notmuch@notmuchmail.org>; Mon, 30 Jan 2012 07:00:03 -0800
\r
22 Received: by wgbdt12 with SMTP id dt12so4091508wgb.2
\r
23 for <notmuch@notmuchmail.org>; Mon, 30 Jan 2012 07:00:01 -0800 (PST)
\r
24 Received: by 10.180.99.199 with SMTP id es7mr27969100wib.10.1327935601284;
\r
25 Mon, 30 Jan 2012 07:00:01 -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 fr8sm53142847wib.10.2012.01.30.06.59.59
\r
29 (version=TLSv1/SSLv3 cipher=OTHER);
\r
30 Mon, 30 Jan 2012 07:00:00 -0800 (PST)
\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)
\r
32 id 714ED9FDD7; Mon, 30 Jan 2012 14:59:58 +0000 (GMT)
\r
33 From: David Edmondson <dme@dme.org>
\r
34 To: notmuch@notmuchmail.org
\r
35 Subject: =?UTF-8?q?=5BPATCH=5D=20emacs=3A=20More=20address=20cleaning=2E?=
\r
36 Date: Mon, 30 Jan 2012 14:59:54 +0000
\r
37 Message-Id: <1327935594-14180-1-git-send-email-dme@dme.org>
\r
38 X-Mailer: git-send-email 1.7.8.3
\r
40 Content-Type: text/plain; charset=UTF-8
\r
41 Content-Transfer-Encoding: 8bit
\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, 30 Jan 2012 15:00:05 -0000
\r
56 Remove outer single-quotes from the mailbox part. Allow for multiple
\r
57 sets of nested single and double quotes.
\r
61 emacs/notmuch-show.el | 24 +++++++++++++++++-------
\r
62 test/emacs-address-cleaning.el | 8 ++++++++
\r
63 2 files changed, 25 insertions(+), 7 deletions(-)
\r
65 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
66 index 84ac624..7bfbda9 100644
\r
67 --- a/emacs/notmuch-show.el
\r
68 +++ b/emacs/notmuch-show.el
\r
69 @@ -315,15 +315,25 @@ unchanged ADDRESS if parsing fails."
\r
71 (setq p-address address)))
\r
73 - ;; Remove elements of the mailbox part that are not relevant for
\r
74 - ;; display, even if they are required during transport.
\r
76 - ;; Outer double quotes.
\r
77 - (when (string-match "^\"\\(.*\\)\"$" p-name)
\r
78 - (setq p-name (match-string 1 p-name)))
\r
80 + ;; Remove elements of the mailbox part that are not relevant for
\r
81 + ;; display, even if they are required during transport:
\r
84 - (setq p-name (replace-regexp-in-string "\\\\" "" p-name)))
\r
85 + (setq p-name (replace-regexp-in-string "\\\\" "" p-name))
\r
87 + ;; Outer single and double quotes, which might be nested.
\r
89 + with start-of-loop
\r
90 + do (setq start-of-loop p-name)
\r
92 + when (string-match "^\"\\(.*\\)\"$" p-name)
\r
93 + do (setq p-name (match-string 1 p-name))
\r
95 + when (string-match "^'\\(.*\\)'$" p-name)
\r
96 + do (setq p-name (match-string 1 p-name))
\r
98 + until (string= start-of-loop p-name)))
\r
100 ;; If the address is 'foo@bar.com <foo@bar.com>' then show just
\r
102 diff --git a/test/emacs-address-cleaning.el b/test/emacs-address-cleaning.el
\r
103 index 3b0b109..8423245 100644
\r
104 --- a/test/emacs-address-cleaning.el
\r
105 +++ b/test/emacs-address-cleaning.el
\r
106 @@ -21,11 +21,19 @@
\r
107 "foo (at home) <foo@bar.com>"
\r
108 "foo [at home] <foo@bar.com>"
\r
110 + "'Foo Bar' <foo@bar.com>"
\r
111 + "\"'Foo Bar'\" <foo@bar.com>"
\r
112 + "'\"Foo Bar\"' <foo@bar.com>"
\r
113 + "'\"'Foo Bar'\"' <foo@bar.com>"
\r
114 "Fred Dibna \\[extraordinaire\\] <fred@dibna.com>"))
\r
115 (expected '("ДБ <db-uknot@stop.me.uk>"
\r
116 "foo (at home) <foo@bar.com>"
\r
117 "foo [at home] <foo@bar.com>"
\r
119 + "Foo Bar <foo@bar.com>"
\r
120 + "Foo Bar <foo@bar.com>"
\r
121 + "Foo Bar <foo@bar.com>"
\r
122 + "Foo Bar <foo@bar.com>"
\r
123 "Fred Dibna [extraordinaire] <fred@dibna.com>"))
\r
124 (output (mapcar #'notmuch-show-clean-address input)))
\r
125 (notmuch-test-expect-equal output expected)))
\r