1 Return-Path: <markwalters1009@gmail.com>
\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 A30C5431FBC
\r
6 for <notmuch@notmuchmail.org>; Sat, 1 Dec 2012 05:37:01 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0.201 tagged_above=-999 required=5
\r
12 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,
\r
13 FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,
\r
14 RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
15 Received: from olra.theworths.org ([127.0.0.1])
\r
16 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
17 with ESMTP id hNFpmczpmLYU for <notmuch@notmuchmail.org>;
\r
18 Sat, 1 Dec 2012 05:36:57 -0800 (PST)
\r
19 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com
\r
20 [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
21 (No client certificate requested)
\r
22 by olra.theworths.org (Postfix) with ESMTPS id 76C75431FAF
\r
23 for <notmuch@notmuchmail.org>; Sat, 1 Dec 2012 05:36:57 -0800 (PST)
\r
24 Received: by mail-we0-f181.google.com with SMTP id t11so574798wey.26
\r
25 for <notmuch@notmuchmail.org>; Sat, 01 Dec 2012 05:36:56 -0800 (PST)
\r
26 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
27 h=from:to:cc:subject:date:message-id:x-mailer;
\r
28 bh=NeVOK7Gxn+TVJdqHGZu9cNOTsKbO72fbIbwv18UJAqI=;
\r
29 b=WycOk7Kv5mxCSEDkhWKetTfj+87qUd8yKNTGp+LDUk3g8v3ZloWqKEbXBLAy4PMlZS
\r
30 AnfSGAMVOSp9r/sv2RMW9ROgD6JDL2MsGn0CPx3yYE1OFU+1VBqQzmvSKjqs3W06bBEW
\r
31 iE7tywQltiI5F8OVJ3dRFQEqhxOGtsjQB31HMG9Zmui/LWdsitJYXN4v/kbaWTFPnk9j
\r
32 ZCcLsL8zA2UMlBmJpxOpqjoCG6V4S1jBB3fp+3OVJLylbpZRK9+E0uptLHw1l6iAcZAt
\r
33 g+6F6+cuPTruxWZvmAOrX27nbx3Z2Ix0MLmKnCxLNiY00METaCyO+SKcdBKzb6tT2KG7
\r
35 Received: by 10.180.107.197 with SMTP id he5mr2194037wib.1.1354369015064;
\r
36 Sat, 01 Dec 2012 05:36:55 -0800 (PST)
\r
37 Received: from localhost (93-97-24-31.zone5.bethere.co.uk. [93.97.24.31])
\r
38 by mx.google.com with ESMTPS id d9sm3085732wiw.0.2012.12.01.05.36.53
\r
39 (version=TLSv1/SSLv3 cipher=OTHER);
\r
40 Sat, 01 Dec 2012 05:36:54 -0800 (PST)
\r
41 From: Mark Walters <markwalters1009@gmail.com>
\r
42 To: notmuch@notmuchmail.org
\r
43 Subject: [PATCH] contrib: pick: use notmuch-clean-address
\r
44 Date: Sat, 1 Dec 2012 13:36:46 +0000
\r
45 Message-Id: <1354369006-1793-1-git-send-email-markwalters1009@gmail.com>
\r
46 X-Mailer: git-send-email 1.7.9.1
\r
47 X-BeenThere: notmuch@notmuchmail.org
\r
48 X-Mailman-Version: 2.1.13
\r
50 List-Id: "Use and development of the notmuch mail system."
\r
51 <notmuch.notmuchmail.org>
\r
52 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
54 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
55 List-Post: <mailto:notmuch@notmuchmail.org>
\r
56 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
57 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
58 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
59 X-List-Received-Date: Sat, 01 Dec 2012 13:37:01 -0000
\r
61 Now notmuch-clean-address is split out in show pick can use that (with a small
\r
65 This removes another 50 lines or so of duplicated code from notmuch-pick.
\r
71 contrib/notmuch-pick/notmuch-pick.el | 65 +++++----------------------------
\r
72 1 files changed, 10 insertions(+), 55 deletions(-)
\r
74 diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el
\r
75 index 5f9e456..6871d7b 100644
\r
76 --- a/contrib/notmuch-pick/notmuch-pick.el
\r
77 +++ b/contrib/notmuch-pick/notmuch-pick.el
\r
79 (declare-function notmuch-show "notmuch-show" (&rest args))
\r
80 (declare-function notmuch-tag "notmuch" (query &rest tags))
\r
81 (declare-function notmuch-show-strip-re "notmuch-show" (subject))
\r
82 -(declare-function notmuch-show-clean-address "notmuch-show" (parsed-address))
\r
83 (declare-function notmuch-show-spaces-n "notmuch-show" (n))
\r
84 (declare-function notmuch-read-query "notmuch" (prompt))
\r
85 (declare-function notmuch-read-tag-changes "notmuch" (&optional initial-input &rest search-terms))
\r
86 @@ -521,62 +520,18 @@ than only the current message."
\r
87 (message (format "Command '%s' exited abnormally with code %d"
\r
88 shell-command exit-code)))))))
\r
90 -;; Shamelessly stolen from notmuch-show.el: should be unified.
\r
91 (defun notmuch-pick-clean-address (address)
\r
92 - "Try to clean a single email ADDRESS for display. Return
\r
93 + "Try to clean a single email ADDRESS for display. Return
\r
94 +AUTHOR_NAME if present, otherwise return AUTHOR_EMAIL. Return
\r
95 unchanged ADDRESS if parsing fails."
\r
96 - (condition-case nil
\r
97 - (let (p-name p-address)
\r
98 - ;; It would be convenient to use `mail-header-parse-address',
\r
99 - ;; but that expects un-decoded mailbox parts, whereas our
\r
100 - ;; mailbox parts are already decoded (and hence may contain
\r
101 - ;; UTF-8). Given that notmuch should handle most of the awkward
\r
102 - ;; cases, some simple string deconstruction should be sufficient
\r
105 - ;; "User <user@dom.ain>" style.
\r
106 - ((string-match "\\(.*\\) <\\(.*\\)>" address)
\r
107 - (setq p-name (match-string 1 address)
\r
108 - p-address (match-string 2 address)))
\r
110 - ;; "<user@dom.ain>" style.
\r
111 - ((string-match "<\\(.*\\)>" address)
\r
112 - (setq p-address (match-string 1 address)))
\r
114 - ;; Everything else.
\r
116 - (setq p-address address)))
\r
119 - ;; Remove elements of the mailbox part that are not relevant for
\r
120 - ;; display, even if they are required during transport:
\r
123 - (setq p-name (replace-regexp-in-string "\\\\" "" p-name))
\r
125 - ;; Outer single and double quotes, which might be nested.
\r
127 - with start-of-loop
\r
128 - do (setq start-of-loop p-name)
\r
130 - when (string-match "^\"\\(.*\\)\"$" p-name)
\r
131 - do (setq p-name (match-string 1 p-name))
\r
133 - when (string-match "^'\\(.*\\)'$" p-name)
\r
134 - do (setq p-name (match-string 1 p-name))
\r
136 - until (string= start-of-loop p-name)))
\r
138 - ;; If the address is 'foo@bar.com <foo@bar.com>' then show just
\r
139 - ;; 'foo@bar.com'.
\r
140 - (when (string= p-name p-address)
\r
141 - (setq p-name nil))
\r
143 - ;; If we have a name return that otherwise return the address.
\r
147 - (error address)))
\r
148 + (let* ((clean-address (notmuch-clean-address address))
\r
149 + (p-address (car clean-address))
\r
150 + (p-name (cdr clean-address)))
\r
152 + ;; If we have a name return that otherwise return the address.
\r
157 (defun notmuch-pick-insert-field (field format-string msg)
\r
158 (let* ((headers (plist-get msg :headers))
\r