Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / 8d / 4b5b83d9fd003705a57f3bf35081877636cd11
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 4A747431FAF\r
6         for <notmuch@notmuchmail.org>; Fri,  4 Jul 2014 09:31:56 -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: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\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 9Nk4hNV6MFuP for <notmuch@notmuchmail.org>;\r
16         Fri,  4 Jul 2014 09:31:51 -0700 (PDT)\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 A9F8B431FAE\r
19         for <notmuch@notmuchmail.org>; Fri,  4 Jul 2014 09:31:50 -0700 (PDT)\r
20 Received: from guru.guru-group.fi (localhost [IPv6:::1])\r
21         by guru.guru-group.fi (Postfix) with ESMTP id 2F3A8100033;\r
22         Fri,  4 Jul 2014 19:31:34 +0300 (EEST)\r
23 From: Tomi Ollila <tomi.ollila@iki.fi>\r
24 To: Sebastian Lipp <bacuh@riseup.net>, Jed Brown <jed@59A2.org>,\r
25         Karl Fogel <kfogel@red-bean.com>, Daniel Bergey <bergey@alum.mit.edu>\r
26 Subject: Re: [PATCH] emacs: add missing paren to fix defun\r
27         in      notmuch-address.el.\r
28 In-Reply-To:\r
29  <87pphmc604.fsf@verb.i-did-not-set--mail-host-address--so-tickle-me>\r
30 References: <87wqsfik5l.fsf@floss.red-bean.com>\r
31         <87mwtah2hd.fsf@zancas.localnet>\r
32         <877gkeau42.fsf@floss.red-bean.com>\r
33         <m2ppy5v3mc.fsf@guru.guru-group.fi> <8738v1jtzc.fsf@nikula.org>\r
34         <87k3odgutd.fsf@zancas.localnet> <87ip3wbj7g.fsf@mcs.anl.gov>\r
35         <m2hajgxli5.fsf@guru.guru-group.fi>\r
36         <87vc7vgbym.fsf@zancas.localnet>\r
37         <m2ehejykb1.fsf@guru.guru-group.fi>\r
38         <87pphmc604.fsf@verb.i-did-not-set--mail-host-address--so-tickle-me>\r
39 User-Agent: Notmuch/0.18.1+25~gdaf4b6f (http://notmuchmail.org) Emacs/24.3.1\r
40         (x86_64-unknown-linux-gnu)\r
41 X-Face: HhBM'cA~<r"^Xv\KRN0P{vn'Y"Kd;zg_y3S[4)KSN~s?O\"QPoL\r
42         $[Xv_BD:i/F$WiEWax}R(MPS`^UaptOGD`*/=@\1lKoVa9tnrg0TW?"r7aRtgk[F\r
43         !)g;OY^,BjTbr)Np:%c_o'jj,Z\r
44 Date: Fri, 04 Jul 2014 19:31:33 +0300\r
45 Message-ID: <m2pphlhyqi.fsf@guru.guru-group.fi>\r
46 MIME-Version: 1.0\r
47 Content-Type: text/plain\r
48 Cc: notmuch@notmuchmail.org\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: Fri, 04 Jul 2014 16:31:56 -0000\r
62 \r
63 On Fri, Jul 04 2014, Sebastian Lipp <bacuh@riseup.net> wrote:\r
64 \r
65 > Tomi Ollila <tomi.ollila@iki.fi> writes:\r
66 >> On Tue, Apr 09 2013, David Bremner wrote:\r
67 >>> There seems to be a few warnings:\r
68 >>>\r
69 >>> In notmuch-bbdb/snarf-from:\r
70 >>> notmuch-address.el:116:26:Warning: reference to free variable\r
71 >>>     `bbdb-get-addresses-headers'\r
72 >>>\r
73 >>> In notmuch-bbdb/snarf-to:\r
74 >>> notmuch-address.el:122:29:Warning: reference to free variable\r
75 >>>     `bbdb-get-addresses-headers'\r
76 >>>\r
77 >>> In end of data:\r
78 >>> notmuch-address.el:143:1:Warning: the following functions are not known to be\r
79 >>>     defined: bbdb-get-addresses, bbdb-update-records, notmuch-show-get-header\r
80 >>>\r
81 >>> Do we need a few defvars?\r
82 >>\r
83 >> For the above set, something like:\r
84 >>\r
85 >> (defvar bbdb-get-addresses-headers)\r
86 >>\r
87 >> (declare-function notmuch-show-get-header "notmuch-show" (header &optional props))\r
88 >>\r
89 >> (declare-function bbdb-get-addresses "bbdb-com" \r
90 >>   (only-first-address\r
91 >>    uninteresting-senders\r
92 >>    get-header-content-function\r
93 >>    &rest get-header-content-function-args))\r
94 >>\r
95 >> (declare-function bbdb-update-records "bbdb-com" (addrs auto-create-p offer-to-create))\r
96 >\r
97 > As I'd like to see this in notmuch I made the change. The patch is\r
98 > attached. As it is my first contribution to notmuch at all: Just tell me\r
99 > if I'm supposed to do it in any other way.\r
100 >\r
101 > LG\r
102 > basti\r
103 \r
104 I saved this patch with 'w' in emacs mua -- and have to remove '>' From the\r
105 first line so that 'git am' could recognize it. \r
106 \r
107 There was one whitespace error -- I reapplied with\r
108 \r
109 git am --whitespace=fix ~/0001-emacs-functions-to-import-sender-or-recipient-into-B.patch\r
110 \r
111 more inline (in addition to Karl's good comments)\r
112 \r
113 IMO all of that can be in one patch...\r
114 \r
115 >>From 522e4294258e6392a02c923b4b7e78a898986fca Mon Sep 17 00:00:00 2001\r
116 > From: Daniel Bergey <bergey@alum.mit.edu>\r
117 > Date: Mon, 8 Apr 2013 19:55:04 -0500\r
118 > Subject: [PATCH] emacs: functions to import sender or recipient into BBDB [v3]\r
119 >\r
120 >>From a show buffer, notmuch-bbdb/snarf-from imports the sender into\r
121 \r
122 Interestingly the line above was lost when I applied the patch -- \r
123 probably '>From' somehow borke git am... -- should git am be more capable\r
124 there (or would the required heuristics pass the tolerance threshold) ?\r
125 \r
126 > bbdb.  notmuch-bbdb/snarf-to imports all recipients.  Newly imported\r
127 > contacts are reported in the minibuffer / Messages buffer.\r
128 >\r
129 > Both functions use the BBDB parser to recognize email address formats.\r
130 >\r
131 > [v3] Fixes a few warnings as suggested by Tomi Ollila in\r
132 >      id:87vc7vgbym.fsf@zancas.localnet\r
133 > [v2] Fixes missing close parenthesis in original.\r
134 >      Spotted by Karl Fogel <kfogel@red-bean.com>.\r
135 > ---\r
136 >  emacs/notmuch-address.el | 53 ++++++++++++++++++++++++++++++++++++++++++++++++\r
137 >  1 file changed, 53 insertions(+)\r
138 >\r
139 > diff --git a/emacs/notmuch-address.el b/emacs/notmuch-address.el\r
140 > index fa65cd5..ee7b169 100644\r
141 > --- a/emacs/notmuch-address.el\r
142 > +++ b/emacs/notmuch-address.el\r
143 > @@ -113,6 +113,59 @@ to know how address selection is made by default."\r
144 >  (when (notmuch-address-locate-command notmuch-address-command)\r
145 >    (notmuch-address-message-insinuate))\r
146 >  \r
147 > +;; functions to add sender / recipients to BBDB\r
148 > +\r
149 > +(defvar bbdb-get-addresses-headers)\r
150 \r
151 It would be nice to have comment where bbdb-get-addresses-headers is defined.\r
152 \r
153 > +\r
154 > +(declare-function notmuch-show-get-header "notmuch-show" (header &optional props))\r
155 > +\r
156 > +(declare-function bbdb-get-addresses "bbdb-com" \r
157 > +  (only-first-address\r
158 > +   uninteresting-senders\r
159 > +   get-header-content-function\r
160 > +   &rest get-header-content-function-args))\r
161 > +\r
162 > +(declare-function bbdb-update-records "bbdb-com" (addrs auto-create-p offer-to-create))\r
163 > +\r
164 > +(defun notmuch-bbdb/snarf-headers (headers)\r
165 > +  ;; Helper function to avoid code duplication in the two below\r
166 > +  ;; headers should have the same format as bbdb-get-addresses-headers\r
167 > +\r
168 > +  ;; bbdb-get-addresses reads these\r
169 > +  ;; Ugh, pass-by-global\r
170 \r
171 Somehow this comment section looks a bit odd -- is it the empty line there,\r
172 or just that (at least part of) it is not docstring.\r
173 \r
174 > +  (let ((addrs (bbdb-get-addresses nil nil 'notmuch-bbdb/get-header-content))\r
175 > +     (bbdb-get-addresses-headers headers) ; headers to read\r
176 > +     (bbdb-gag-messages t)) ; suppress m/n processed message)\r
177 > +    (bbdb-update-records addrs t t)))\r
178 > +\r
179 > +(defun notmuch-bbdb/snarf-from ()\r
180 > +  "Import the sender of the current message into BBDB"\r
181 > +  (interactive)\r
182 > +  (notmuch-bbdb/snarf-headers\r
183 > +   (list (assoc 'authors bbdb-get-addresses-headers))))\r
184 > +\r
185 > +(defun notmuch-bbdb/snarf-to ()\r
186 > +  "Import all recipients of the current message into BBDB"\r
187 > +  (interactive)\r
188 > +  (notmuch-bbdb/snarf-headers\r
189 > +   (list (assoc 'recipients bbdb-get-addresses-headers))))\r
190 > +\r
191 > +(defvar notmuch-bbdb/header-by-name\r
192 > +  ;; both are case sensitive\r
193 > +  '( ("From" . :From)\r
194 > +     ("To" . :To)\r
195 > +     ("CC" . :Cc)\r
196 > +     ("BCC" . :Bcc)\r
197 > +     ("Resent-From" . nil)\r
198 > +     ("Reply-To" . nil)\r
199 > +     ("Resent-To" . nil)\r
200 > +     ("Resent-CC" . nil))\r
201 > +  "Alist for dispatching header symbols as used by notmuch-show-get-header\r
202 > +from strings as used by bbdb-get-addresses")\r
203 > +\r
204 > +(defun notmuch-bbdb/get-header-content (name)\r
205 > +  (notmuch-show-get-header (cdr (assoc name notmuch-bbdb/header-by-name))))\r
206 > +\r
207 >  ;;\r
208 >  \r
209 >  (provide 'notmuch-address)\r
210 > -- \r
211 > 2.0.1\r
212 \r
213 Tomi\r