1 Return-Path: <tomi.ollila@iki.fi>
\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 70A99431FBD
\r
6 for <notmuch@notmuchmail.org>; Sat, 1 Dec 2012 06:32:03 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]
\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 aOpc+tkHjX+q for <notmuch@notmuchmail.org>;
\r
16 Sat, 1 Dec 2012 06:31:58 -0800 (PST)
\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])
\r
18 by olra.theworths.org (Postfix) with ESMTP id 8EB8C431FAF
\r
19 for <notmuch@notmuchmail.org>; Sat, 1 Dec 2012 06:31:58 -0800 (PST)
\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])
\r
21 by guru.guru-group.fi (Postfix) with ESMTP id D9D591000D0;
\r
22 Sat, 1 Dec 2012 16:31:55 +0200 (EET)
\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>
\r
24 To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org
\r
25 Subject: Re: [PATCH] contrib: pick: use notmuch-clean-address
\r
26 In-Reply-To: <1354369006-1793-1-git-send-email-markwalters1009@gmail.com>
\r
27 References: <1354369006-1793-1-git-send-email-markwalters1009@gmail.com>
\r
28 User-Agent: Notmuch/0.14+116~g29fcdb5 (http://notmuchmail.org) Emacs/24.2.1
\r
29 (x86_64-unknown-linux-gnu)
\r
30 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL
\r
31 $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F
\r
32 !)g;OY^,BjTbr)Np:%c_o'jj,Z
\r
33 Date: Sat, 01 Dec 2012 16:31:55 +0200
\r
34 Message-ID: <m28v9hhmhw.fsf@guru.guru-group.fi>
\r
36 Content-Type: text/plain
\r
37 X-BeenThere: notmuch@notmuchmail.org
\r
38 X-Mailman-Version: 2.1.13
\r
40 List-Id: "Use and development of the notmuch mail system."
\r
41 <notmuch.notmuchmail.org>
\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
43 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
45 List-Post: <mailto:notmuch@notmuchmail.org>
\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
49 X-List-Received-Date: Sat, 01 Dec 2012 14:32:03 -0000
\r
51 On Sat, Dec 01 2012, Mark Walters <markwalters1009@gmail.com> wrote:
\r
53 > Now notmuch-clean-address is split out in show pick can use that (with a small
\r
57 > This removes another 50 lines or so of duplicated code from notmuch-pick.
\r
63 > contrib/notmuch-pick/notmuch-pick.el | 65 +++++----------------------------
\r
64 > 1 files changed, 10 insertions(+), 55 deletions(-)
\r
66 > diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el
\r
67 > index 5f9e456..6871d7b 100644
\r
68 > --- a/contrib/notmuch-pick/notmuch-pick.el
\r
69 > +++ b/contrib/notmuch-pick/notmuch-pick.el
\r
71 > (declare-function notmuch-show "notmuch-show" (&rest args))
\r
72 > (declare-function notmuch-tag "notmuch" (query &rest tags))
\r
73 > (declare-function notmuch-show-strip-re "notmuch-show" (subject))
\r
74 > -(declare-function notmuch-show-clean-address "notmuch-show" (parsed-address))
\r
75 > (declare-function notmuch-show-spaces-n "notmuch-show" (n))
\r
76 > (declare-function notmuch-read-query "notmuch" (prompt))
\r
77 > (declare-function notmuch-read-tag-changes "notmuch" (&optional initial-input &rest search-terms))
\r
78 > @@ -521,62 +520,18 @@ than only the current message."
\r
79 > (message (format "Command '%s' exited abnormally with code %d"
\r
80 > shell-command exit-code)))))))
\r
82 > -;; Shamelessly stolen from notmuch-show.el: should be unified.
\r
83 > (defun notmuch-pick-clean-address (address)
\r
84 > - "Try to clean a single email ADDRESS for display. Return
\r
85 > + "Try to clean a single email ADDRESS for display. Return
\r
86 > +AUTHOR_NAME if present, otherwise return AUTHOR_EMAIL. Return
\r
87 > unchanged ADDRESS if parsing fails."
\r
88 > - (condition-case nil
\r
89 > - (let (p-name p-address)
\r
90 > - ;; It would be convenient to use `mail-header-parse-address',
\r
91 > - ;; but that expects un-decoded mailbox parts, whereas our
\r
92 > - ;; mailbox parts are already decoded (and hence may contain
\r
93 > - ;; UTF-8). Given that notmuch should handle most of the awkward
\r
94 > - ;; cases, some simple string deconstruction should be sufficient
\r
97 > - ;; "User <user@dom.ain>" style.
\r
98 > - ((string-match "\\(.*\\) <\\(.*\\)>" address)
\r
99 > - (setq p-name (match-string 1 address)
\r
100 > - p-address (match-string 2 address)))
\r
102 > - ;; "<user@dom.ain>" style.
\r
103 > - ((string-match "<\\(.*\\)>" address)
\r
104 > - (setq p-address (match-string 1 address)))
\r
106 > - ;; Everything else.
\r
108 > - (setq p-address address)))
\r
111 > - ;; Remove elements of the mailbox part that are not relevant for
\r
112 > - ;; display, even if they are required during transport:
\r
114 > - ;; Backslashes.
\r
115 > - (setq p-name (replace-regexp-in-string "\\\\" "" p-name))
\r
117 > - ;; Outer single and double quotes, which might be nested.
\r
119 > - with start-of-loop
\r
120 > - do (setq start-of-loop p-name)
\r
122 > - when (string-match "^\"\\(.*\\)\"$" p-name)
\r
123 > - do (setq p-name (match-string 1 p-name))
\r
125 > - when (string-match "^'\\(.*\\)'$" p-name)
\r
126 > - do (setq p-name (match-string 1 p-name))
\r
128 > - until (string= start-of-loop p-name)))
\r
130 > - ;; If the address is 'foo@bar.com <foo@bar.com>' then show just
\r
131 > - ;; 'foo@bar.com'.
\r
132 > - (when (string= p-name p-address)
\r
133 > - (setq p-name nil))
\r
135 > - ;; If we have a name return that otherwise return the address.
\r
136 > - (if (not p-name)
\r
139 > - (error address)))
\r
140 > + (let* ((clean-address (notmuch-clean-address address))
\r
141 > + (p-address (car clean-address))
\r
142 > + (p-name (cdr clean-address)))
\r
144 > + ;; If we have a name return that otherwise return the address.
\r
145 > + (if (not p-name)
\r
149 LGTM, but would this look so good... ?
\r
151 ;; If we have a name return that otherwise return the address.
\r
152 (or p-name p-address))
\r
158 > (defun notmuch-pick-insert-field (field format-string msg)
\r
159 > (let* ((headers (plist-get msg :headers))
\r
163 > _______________________________________________
\r
164 > notmuch mailing list
\r
165 > notmuch@notmuchmail.org
\r
166 > http://notmuchmail.org/mailman/listinfo/notmuch
\r