notmuch webmails
[notmuch-archives.git] / 97 / e8125b65feca7a033e64d6320c631a9fc53aec
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 DA119431FBC\r
6         for <notmuch@notmuchmail.org>; Sat,  1 Dec 2012 10:02:32 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0.201\r
10 X-Spam-Level: \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 n8icWqiga9Pr for <notmuch@notmuchmail.org>;\r
18         Sat,  1 Dec 2012 10:02:28 -0800 (PST)\r
19 Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com\r
20         [209.85.212.175]) (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 AEA2F431FAF\r
23         for <notmuch@notmuchmail.org>; Sat,  1 Dec 2012 10:02:28 -0800 (PST)\r
24 Received: by mail-wi0-f175.google.com with SMTP id hm11so311437wib.2\r
25         for <notmuch@notmuchmail.org>; Sat, 01 Dec 2012 10:02:26 -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:in-reply-to:references;\r
28         bh=ympdeC/o4fZ6SmBzltIHNjNZqD4u6/PHfobJlLeV5K0=;\r
29         b=KRq9XB2NfRpZ6B6FyQBypOjqEnFsbat5s97ILqWHFp0pbFqQpTR99FEaw4fb2MYaRC\r
30         fCuS8RQHDB00w5BYOdLtLTlQq/aTtsfmbEu0dLtyYdbiUaukzqXqdXR7tgrzCQVr+vU2\r
31         s/124DzCt9LMfAOBWuhva9+hx6H4bnzbIE8JRWP0i5w9/yhZMTF99wZH+K5Zf/rqWXl7\r
32         Nl1MGGbYH2ivXuxw/IHH9X/ppQdAh+9pZoLWkWFsxy7vG5ZYvcmpGYj82+YVoloDMWSX\r
33         o3MpLvWfJuIk+F0GilHwKxmMXDTaArQ7PVa5j8OfANxQ21jetCvUOJnYZ5mp26eOgTxp\r
34         hcww==\r
35 Received: by 10.216.143.232 with SMTP id l82mr1658662wej.181.1354384946185;\r
36         Sat, 01 Dec 2012 10:02:26 -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 p2sm4388286wic.7.2012.12.01.10.02.24\r
39         (version=TLSv1/SSLv3 cipher=OTHER);\r
40         Sat, 01 Dec 2012 10:02:25 -0800 (PST)\r
41 From: Mark Walters <markwalters1009@gmail.com>\r
42 To: notmuch@notmuchmail.org\r
43 Subject: [PATCH v2] contrib: pick: use notmuch-clean-address\r
44 Date: Sat,  1 Dec 2012 18:02:02 +0000\r
45 Message-Id: <1354384922-14237-1-git-send-email-markwalters1009@gmail.com>\r
46 X-Mailer: git-send-email 1.7.9.1\r
47 In-Reply-To: <m28v9hhmhw.fsf@guru.guru-group.fi>\r
48 References: <m28v9hhmhw.fsf@guru.guru-group.fi>\r
49 X-BeenThere: notmuch@notmuchmail.org\r
50 X-Mailman-Version: 2.1.13\r
51 Precedence: list\r
52 List-Id: "Use and development of the notmuch mail system."\r
53         <notmuch.notmuchmail.org>\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
55         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
57 List-Post: <mailto:notmuch@notmuchmail.org>\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
60         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
61 X-List-Received-Date: Sat, 01 Dec 2012 18:02:33 -0000\r
62 \r
63 Now notmuch-clean-address is split out in show pick can use that (with a small\r
64 wrapper).\r
65 ---\r
66 A neater version following Tomi's suggestion.\r
67 \r
68  contrib/notmuch-pick/notmuch-pick.el |   63 ++++-----------------------------\r
69  1 files changed, 8 insertions(+), 55 deletions(-)\r
70 \r
71 diff --git a/contrib/notmuch-pick/notmuch-pick.el b/contrib/notmuch-pick/notmuch-pick.el\r
72 index eca1cba..a5005be 100644\r
73 --- a/contrib/notmuch-pick/notmuch-pick.el\r
74 +++ b/contrib/notmuch-pick/notmuch-pick.el\r
75 @@ -35,7 +35,6 @@\r
76  (declare-function notmuch-show "notmuch-show" (&rest args))\r
77  (declare-function notmuch-tag "notmuch" (query &rest tags))\r
78  (declare-function notmuch-show-strip-re "notmuch-show" (subject))\r
79 -(declare-function notmuch-show-clean-address "notmuch-show" (parsed-address))\r
80  (declare-function notmuch-show-spaces-n "notmuch-show" (n))\r
81  (declare-function notmuch-read-query "notmuch" (prompt))\r
82  (declare-function notmuch-read-tag-changes "notmuch" (&optional initial-input &rest search-terms))\r
83 @@ -528,62 +527,16 @@ than only the current message."\r
84           (message (format "Command '%s' exited abnormally with code %d"\r
85                            shell-command exit-code)))))))\r
86  \r
87 -;; Shamelessly stolen from notmuch-show.el: should be unified.\r
88  (defun notmuch-pick-clean-address (address)\r
89 -  "Try to clean a single email ADDRESS for display.  Return\r
90 +  "Try to clean a single email ADDRESS for display. Return\r
91 +AUTHOR_NAME if present, otherwise return AUTHOR_EMAIL. Return\r
92  unchanged ADDRESS if parsing fails."\r
93 -  (condition-case nil\r
94 -    (let (p-name p-address)\r
95 -      ;; It would be convenient to use `mail-header-parse-address',\r
96 -      ;; but that expects un-decoded mailbox parts, whereas our\r
97 -      ;; mailbox parts are already decoded (and hence may contain\r
98 -      ;; UTF-8). Given that notmuch should handle most of the awkward\r
99 -      ;; cases, some simple string deconstruction should be sufficient\r
100 -      ;; here.\r
101 -      (cond\r
102 -       ;; "User <user@dom.ain>" style.\r
103 -       ((string-match "\\(.*\\) <\\(.*\\)>" address)\r
104 -       (setq p-name (match-string 1 address)\r
105 -             p-address (match-string 2 address)))\r
106 -\r
107 -       ;; "<user@dom.ain>" style.\r
108 -       ((string-match "<\\(.*\\)>" address)\r
109 -       (setq p-address (match-string 1 address)))\r
110 -\r
111 -       ;; Everything else.\r
112 -       (t\r
113 -       (setq p-address address)))\r
114 -\r
115 -      (when p-name\r
116 -       ;; Remove elements of the mailbox part that are not relevant for\r
117 -       ;; display, even if they are required during transport:\r
118 -       ;;\r
119 -       ;; Backslashes.\r
120 -       (setq p-name (replace-regexp-in-string "\\\\" "" p-name))\r
121 -\r
122 -       ;; Outer single and double quotes, which might be nested.\r
123 -       (loop\r
124 -        with start-of-loop\r
125 -        do (setq start-of-loop p-name)\r
126 -\r
127 -        when (string-match "^\"\\(.*\\)\"$" p-name)\r
128 -        do (setq p-name (match-string 1 p-name))\r
129 -\r
130 -        when (string-match "^'\\(.*\\)'$" p-name)\r
131 -        do (setq p-name (match-string 1 p-name))\r
132 -\r
133 -        until (string= start-of-loop p-name)))\r
134 -\r
135 -      ;; If the address is 'foo@bar.com <foo@bar.com>' then show just\r
136 -      ;; 'foo@bar.com'.\r
137 -      (when (string= p-name p-address)\r
138 -       (setq p-name nil))\r
139 -\r
140 -      ;; If we have a name return that otherwise return the address.\r
141 -      (if (not p-name)\r
142 -         p-address\r
143 -       p-name))\r
144 -    (error address)))\r
145 +  (let* ((clean-address (notmuch-clean-address address))\r
146 +        (p-address (car clean-address))\r
147 +        (p-name (cdr clean-address)))\r
148 +\r
149 +    ;; If we have a name return that otherwise return the address.\r
150 +    (or p-name p-address)))\r
151  \r
152  (defun notmuch-pick-insert-field (field format-string msg)\r
153    (let* ((headers (plist-get msg :headers))\r
154 -- \r
155 1.7.9.1\r
156 \r