[PATCH] emacs: address completion, allow sender/recipient and filters
[notmuch-archives.git] / b6 / d71ad1317f2c6446a9614a28e4f10aea7c43cb
1 Return-Path: <m.walters@qmul.ac.uk>\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 F1775431FAF\r
6         for <notmuch@notmuchmail.org>; Tue, 31 Jul 2012 09:29:41 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -1.098\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5\r
12         tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001,\r
13         NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id GxIgzi2P+zAf for <notmuch@notmuchmail.org>;\r
17         Tue, 31 Jul 2012 09:29:41 -0700 (PDT)\r
18 Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6])\r
19         (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id 49A29431FAE\r
22         for <notmuch@notmuchmail.org>; Tue, 31 Jul 2012 09:29:41 -0700 (PDT)\r
23 Received: from smtp.qmul.ac.uk ([138.37.6.40])\r
24         by mail2.qmul.ac.uk with esmtp (Exim 4.71)\r
25         (envelope-from <m.walters@qmul.ac.uk>)\r
26         id 1SwFKF-0006PE-OB; Tue, 31 Jul 2012 17:29:39 +0100\r
27 Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223]\r
28         helo=localhost)\r
29         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69)\r
30         (envelope-from <m.walters@qmul.ac.uk>)\r
31         id 1SwFKF-00030G-EL; Tue, 31 Jul 2012 17:29:39 +0100\r
32 From: Mark Walters <markwalters1009@gmail.com>\r
33 To: Tomi Ollila <tomi.ollila@iki.fi>, notmuch@notmuchmail.org\r
34 Subject: [PATCH v2] emacs: Split the function notmuch-show-clean-address\r
35 In-Reply-To: <87boivzyls.fsf@qmul.ac.uk>\r
36 References: <87ehnw84e5.fsf@qmul.ac.uk> <m2mx2gl6d1.fsf@guru.guru-group.fi>\r
37         <87boivzyls.fsf@qmul.ac.uk>\r
38 User-Agent: Notmuch/0.13.2+96~g634443c (http://notmuchmail.org) Emacs/23.4.1\r
39         (x86_64-pc-linux-gnu)\r
40 Date: Tue, 31 Jul 2012 17:29:39 +0100\r
41 Message-ID: <878vdzzyfg.fsf@qmul.ac.uk>\r
42 MIME-Version: 1.0\r
43 Content-Type: text/plain; charset=us-ascii\r
44 X-Sender-Host-Address: 94.192.233.223\r
45 X-QM-SPAM-Info: Sender has good ham record.  :)\r
46 X-QM-Body-MD5: cb6b5d3f83cd6a3c9f674b46315cc3a3 (of first 20000 bytes)\r
47 X-SpamAssassin-Score: -1.8\r
48 X-SpamAssassin-SpamBar: -\r
49 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
50         determine if it is\r
51         spam. We require at least 5.0 points to mark a message as spam.\r
52         This message scored -1.8 points.\r
53         Summary of the scoring: \r
54         * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/,\r
55         *      medium trust\r
56         *      [138.37.6.40 listed in list.dnswl.org]\r
57         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
58         provider *      (markwalters1009[at]gmail.com)\r
59         * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay\r
60         *      domain\r
61         *  0.5 AWL AWL: From: address is in the auto white-list\r
62 X-QM-Scan-Virus: ClamAV says the message is clean\r
63 X-BeenThere: notmuch@notmuchmail.org\r
64 X-Mailman-Version: 2.1.13\r
65 Precedence: list\r
66 List-Id: "Use and development of the notmuch mail system."\r
67         <notmuch.notmuchmail.org>\r
68 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
69         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
70 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
71 List-Post: <mailto:notmuch@notmuchmail.org>\r
72 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
73 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
74         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
75 X-List-Received-Date: Tue, 31 Jul 2012 16:29:42 -0000\r
76 \r
77 \r
78 This function is also used by pick so split it out in preperation for\r
79 moving to lib. In fact, pick and show want a slightly different\r
80 combination of name and email on return so make the separated function\r
81 return them as a pair, and let show or pick extract the combination\r
82 they want from that.\r
83 ---\r
84  emacs/notmuch-show.el |   27 ++++++++++++++++++---------\r
85  1 files changed, 18 insertions(+), 9 deletions(-)\r
86 \r
87 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
88 index 6335d45..4ab6f92 100644\r
89 --- a/emacs/notmuch-show.el\r
90 +++ b/emacs/notmuch-show.el\r
91 @@ -351,9 +351,10 @@ operation on the contents of the current buffer."\r
92                                              'face 'notmuch-tag-face)\r
93                                  ")"))))))\r
94  \r
95 -(defun notmuch-show-clean-address (address)\r
96 -  "Try to clean a single email ADDRESS for display.  Return\r
97 -unchanged ADDRESS if parsing fails."\r
98 +(defun notmuch-clean-address (address)\r
99 +  "Try to clean a single email ADDRESS for display. Return a cons\r
100 +cell of (AUTHOR_EMAIL AUTHOR_NAME). Return (ADDRESS nil) if\r
101 +parsing fails."\r
102    (condition-case nil\r
103      (let (p-name p-address)\r
104        ;; It would be convenient to use `mail-header-parse-address',\r
105 @@ -401,12 +402,20 @@ unchanged ADDRESS if parsing fails."\r
106        (when (string= p-name p-address)\r
107         (setq p-name nil))\r
108  \r
109 -      ;; If no name results, return just the address.\r
110 -      (if (not p-name)\r
111 -         p-address\r
112 -       ;; Otherwise format the name and address together.\r
113 -       (concat p-name " <" p-address ">")))\r
114 -    (error address)))\r
115 +      (cons p-address p-name))\r
116 +    (error (cons address nil))))\r
117 +\r
118 +(defun notmuch-show-clean-address (address)\r
119 +  "Try to clean a single email ADDRESS for display.  Return\r
120 +unchanged ADDRESS if parsing fails."\r
121 +  (let* ((clean-address (notmuch-clean-address address))\r
122 +        (p-address (car clean-address))\r
123 +        (p-name (cdr clean-address)))\r
124 +    ;; If no name, return just the address.\r
125 +    (if (not p-name)\r
126 +       p-address\r
127 +      ;; Otherwise format the name and address together.\r
128 +      (concat p-name " <" p-address ">"))))\r
129  \r
130  (defun notmuch-show-insert-headerline (headers date tags depth)\r
131    "Insert a notmuch style headerline based on HEADERS for a\r
132 -- \r
133 1.7.9.1\r
134 \r