[PATCH v3 5/7] Introduce _notmuch_message_has_term()
[notmuch-archives.git] / 86 / 01fd22d0fed4d71e3406397347f96842f5b2f1
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 0D3DA431FBF\r
6         for <notmuch@notmuchmail.org>; Sat,  1 Mar 2014 01:37:34 -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: -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 4Gh0fp-L97fV for <notmuch@notmuchmail.org>;\r
17         Sat,  1 Mar 2014 01:37:29 -0800 (PST)\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 B7210431FAF\r
22         for <notmuch@notmuchmail.org>; Sat,  1 Mar 2014 01:37:28 -0800 (PST)\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 1WJgMG-0000S6-2P; Sat, 01 Mar 2014 09:37:24 +0000\r
27 Received: from 93-97-24-31.zone5.bethere.co.uk ([93.97.24.31] helo=localhost)\r
28         by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.71)\r
29         (envelope-from <m.walters@qmul.ac.uk>)\r
30         id 1WJgMF-000554-NF; Sat, 01 Mar 2014 09:37:23 +0000\r
31 From: Mark Walters <markwalters1009@gmail.com>\r
32 To: Austin Clements <amdragon@MIT.EDU>, notmuch@notmuchmail.org\r
33 Subject: Re: [PATCH v2] emacs: Simplify and fix\r
34  `notmuch-mua-prompt-for-sender'\r
35 In-Reply-To: <1393524654-20502-1-git-send-email-amdragon@mit.edu>\r
36 References: <87fvndfm3k.fsf@qmul.ac.uk>\r
37         <1393524654-20502-1-git-send-email-amdragon@mit.edu>\r
38 User-Agent: Notmuch/0.15.2+562~g339f306 (http://notmuchmail.org) Emacs/23.4.1\r
39         (x86_64-pc-linux-gnu)\r
40 Date: Sat, 01 Mar 2014 09:37:22 +0000\r
41 Message-ID: <87ob1q2ral.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: 93.97.24.31\r
45 X-QM-Geographic: According to ripencc,\r
46         this message was delivered by a machine in Britain (UK) (GB).\r
47 X-QM-SPAM-Info: Sender has good ham record.  :)\r
48 X-QM-Body-MD5: d9e6958e205d01ceeae768d0b26ac86f (of first 20000 bytes)\r
49 X-SpamAssassin-Score: 0.0\r
50 X-SpamAssassin-SpamBar: /\r
51 X-SpamAssassin-Report: The QM spam filters have analysed this message to\r
52         determine if it is\r
53         spam. We require at least 5.0 points to mark a message as spam.\r
54         This message scored 0.0 points. Summary of the scoring: \r
55         * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail\r
56         provider *      (markwalters1009[at]gmail.com)\r
57         *  0.0 AWL AWL: From: address is in the auto white-list\r
58 X-QM-Scan-Virus: ClamAV says the message is clean\r
59 X-BeenThere: notmuch@notmuchmail.org\r
60 X-Mailman-Version: 2.1.13\r
61 Precedence: list\r
62 List-Id: "Use and development of the notmuch mail system."\r
63         <notmuch.notmuchmail.org>\r
64 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
65         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
66 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
67 List-Post: <mailto:notmuch@notmuchmail.org>\r
68 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
69 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
70         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
71 X-List-Received-Date: Sat, 01 Mar 2014 09:37:34 -0000\r
72 \r
73 \r
74 This version is fine (thanks!). And the patch looks good to me too +1.\r
75 \r
76 Best wishes\r
77 \r
78 Mark\r
79 \r
80 \r
81 On Thu, 27 Feb 2014, Austin Clements <amdragon@MIT.EDU> wrote:\r
82 > `notmuch-mua-prompt-for-sender' is over-engineered and often wrong.\r
83 > It attempts to detect when all identities have the same name and\r
84 > specialize the prompt to just the email address part.  However, to do\r
85 > this it uses `mail-extract-address-components', which is meant for\r
86 > displaying email addresses, not general-purpose parsing, and hence\r
87 > performs many canonicalizations that can interfere with this use.  For\r
88 > example, configuring notmuch-identities to ("Austin\r
89 > <austin@example.com>"), will cause `notmuch-mua-prompt-for-sender' to\r
90 > lose the name part entirely and return " <austin@example.com>".\r
91 >\r
92 > This patch rewrites `notmuch-mua-prompt-for-sender' to simply prompt\r
93 > for a full identity when notmuch-identities is configured, or to\r
94 > prompt for a sender address when it isn't.\r
95 >\r
96 > The original code also did several strange things, like using `eval'\r
97 > and specifying that this function was interactive.  As a side-effect,\r
98 > this patch fixes these problems.  And it adds a docstring.\r
99 > ---\r
100 >\r
101 > Mark, is this better?\r
102 >\r
103 > emacs/notmuch-mua.el | 37 +++++++++++++------------------------\r
104 >  1 file changed, 13 insertions(+), 24 deletions(-)\r
105 >\r
106 > diff --git a/emacs/notmuch-mua.el b/emacs/notmuch-mua.el\r
107 > index f2df770..b16a10e 100644\r
108 > --- a/emacs/notmuch-mua.el\r
109 > +++ b/emacs/notmuch-mua.el\r
110 > @@ -286,30 +286,19 @@ the From: header is already filled in by notmuch."\r
111 >        (ad-activate 'ido-completing-read)))\r
112 >  \r
113 >  (defun notmuch-mua-prompt-for-sender ()\r
114 > -  (interactive)\r
115 > -  (let (name addresses one-name-only)\r
116 > -    ;; If notmuch-identities is non-nil, check if there is a fixed user name.\r
117 > -    (if notmuch-identities\r
118 > -     (let ((components (mapcar 'mail-extract-address-components notmuch-identities)))\r
119 > -       (setq name          (caar components)\r
120 > -             addresses     (mapcar 'cadr components)\r
121 > -             one-name-only (eval\r
122 > -                            (cons 'and\r
123 > -                                  (mapcar (lambda (identity)\r
124 > -                                            (string-equal name (car identity)))\r
125 > -                                          components)))))\r
126 > -      ;; If notmuch-identities is nil, use values from the notmuch configuration file.\r
127 > -      (setq name          (notmuch-user-name)\r
128 > -         addresses     (cons (notmuch-user-primary-email) (notmuch-user-other-email))\r
129 > -         one-name-only t))\r
130 > -    ;; Now prompt the user, either for an email address only or for a full identity.\r
131 > -    (if one-name-only\r
132 > -     (let ((address\r
133 > -            (ido-completing-read (concat "Sender address for " name ": ") addresses\r
134 > -                                 nil nil nil 'notmuch-mua-sender-history (car addresses))))\r
135 > -       (concat name " <" address ">"))\r
136 > -      (ido-completing-read "Send mail From: " notmuch-identities\r
137 > -                        nil nil nil 'notmuch-mua-sender-history (car notmuch-identities)))))\r
138 > +  "Prompt for a sender from the user's configured identities."\r
139 > +  (if notmuch-identities\r
140 > +      (ido-completing-read "Send mail from: " notmuch-identities\r
141 > +                        nil nil nil 'notmuch-mua-sender-history\r
142 > +                        (car notmuch-identities))\r
143 > +    (let* ((name (notmuch-user-name))\r
144 > +        (addrs (cons (notmuch-user-primary-email)\r
145 > +                     (notmuch-user-other-email)))\r
146 > +        (address\r
147 > +         (ido-completing-read (concat "Sender address for " name ": ") addrs\r
148 > +                              nil nil nil 'notmuch-mua-sender-history\r
149 > +                              (car addrs))))\r
150 > +      (concat name " <" address ">"))))\r
151 >  \r
152 >  (put 'notmuch-mua-new-mail 'notmuch-prefix-doc "... and prompt for sender")\r
153 >  (defun notmuch-mua-new-mail (&optional prompt-for-sender)\r
154 > -- \r
155 > 1.8.4.rc3\r