1 Return-Path: <dme@dme.org>
\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 13B54431FAF
\r
6 for <notmuch@notmuchmail.org>; Tue, 6 May 2014 22:41:17 -0700 (PDT)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 BP6Ag7QvHZGR for <notmuch@notmuchmail.org>;
\r
16 Tue, 6 May 2014 22:41:09 -0700 (PDT)
\r
17 Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com
\r
18 [209.85.212.174]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id 66773431FAE
\r
21 for <notmuch@notmuchmail.org>; Tue, 6 May 2014 22:41:09 -0700 (PDT)
\r
22 Received: by mail-wi0-f174.google.com with SMTP id r20so5159190wiv.7
\r
23 for <notmuch@notmuchmail.org>; Tue, 06 May 2014 22:41:08 -0700 (PDT)
\r
24 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
\r
25 d=1e100.net; s=20130820;
\r
26 h=x-gm-message-state:to:subject:in-reply-to:references:user-agent
\r
27 :from:date:message-id:mime-version:content-type;
\r
28 bh=9gYY1AklvGOyLb82qlMxrA+ZrZzHcdXYFy7VKm0UXnQ=;
\r
29 b=MWRT+Muwhyb50ZtkFgcf8KS3FGTg0+8W3+Yh0z1oGg85PZKfUKCa/OlCzEA3O6UQ6z
\r
30 le7mJ7uo+3Ez9OVIH8IAv/KvapVYcVWGKbTnr56AyMtp4uNkUlZDV0nUDEFHEtipKsVB
\r
31 9eAvJUctzxo1vog8eo29NLNCD0fwBgs9kccTfIx763EJQ5s6jYqMC+AQkR1NkHyBPT/b
\r
32 p+cJMVFF8Pm3gptxB3xNbqh7kIEc1WFq06K7j0ocDw9vhWOk0zlsRBDNSoBU1JGZ2Rq5
\r
33 01DUCYG0zd8nrallxNTuNbq0/ndgUa6RGmqdJxAYqggvHfwkvAecwAi0v0gNBlM2lYM+
\r
36 ALoCoQmwgMqnLp//agE5DxHcEirbsmOLIXzdVoReiBjK15/AtSVHcoDHIFPF6PSPWmx4I8aP31R5
\r
37 X-Received: by 10.180.77.165 with SMTP id t5mr24607705wiw.38.1399441267998;
\r
38 Tue, 06 May 2014 22:41:07 -0700 (PDT)
\r
39 Received: from localhost (disaster-area.hh.sledj.net. [81.149.164.25])
\r
40 by mx.google.com with ESMTPSA id
\r
41 fz11sm11958155wic.4.2014.05.06.22.41.05 for <multiple recipients>
\r
42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
\r
43 Tue, 06 May 2014 22:41:06 -0700 (PDT)
\r
44 To: Mark Walters <markwalters1009@gmail.com>, notmuch@notmuchmail.org
\r
45 Subject: Re: [PATCH] emacs: hello: allow arbitrary lisp for generating the
\r
47 In-Reply-To: <1399402132-1030-1-git-send-email-markwalters1009@gmail.com>
\r
48 References: <1399402132-1030-1-git-send-email-markwalters1009@gmail.com>
\r
49 User-Agent: Notmuch/0.18~rc1 (http://notmuchmail.org) Emacs/24.3.1
\r
50 (x86_64-pc-linux-gnu)
\r
51 From: David Edmondson <dme@dme.org>
\r
52 Date: Wed, 07 May 2014 06:41:00 +0100
\r
53 Message-ID: <cun8uqegn83.fsf@hotblack-desiato.hh.sledj.net>
\r
55 Content-Type: multipart/signed; boundary="=-=-=";
\r
56 micalg=pgp-sha1; protocol="application/pgp-signature"
\r
57 X-BeenThere: notmuch@notmuchmail.org
\r
58 X-Mailman-Version: 2.1.13
\r
60 List-Id: "Use and development of the notmuch mail system."
\r
61 <notmuch.notmuchmail.org>
\r
62 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
63 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
64 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
65 List-Post: <mailto:notmuch@notmuchmail.org>
\r
66 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
67 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
68 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
69 X-List-Received-Date: Wed, 07 May 2014 05:41:17 -0000
\r
72 Content-Type: text/plain
\r
73 Content-Transfer-Encoding: quoted-printable
\r
75 Looks good, two nits:
\r
77 On Tue, May 06 2014, Mark Walters <markwalters1009@gmail.com> wrote:
\r
78 > This allows a function to be given for the count-query of a saved
\r
79 > search. The function will be called with the query plist as an
\r
80 > argument to generate the count shown and should return either a string
\r
81 > or a number to be displayed as the count.
\r
83 > If this option is a function then its query will not be part of the
\r
84 > normal bacth query used so it may make notmuch-hello slower to
\r
90 > There was some discussion on irc today about notmuch hello being slow
\r
91 > (because it can make a lot of queries). This extends the new
\r
92 > saved-searches :count-query option to allow aribtrary lisp functions.
\r
94 > Thus a user could configure some searches to be (lambda (elem) "--")
\r
95 > so that these searches do not have a count executed and just display
\r
96 > "--". Alternatively (and at the risk of some slow down) they could
\r
97 > configure them to be my-notmuch-count where
\r
99 > (defun my-notmuch-count (elem)
\r
101 > (notmuch-hello-nice-number
\r
102 > (string-to-number
\r
104 > (process-lines notmuch-command "count" "--output=3Dmessages"
\r
105 > (plist-get elem :query)))))
\r
107 > (notmuch-hello-nice-number
\r
108 > (string-to-number
\r
110 > (process-lines notmuch-command "count" "--output=3Dthreads"
\r
111 > (plist-get elem :query)))))))
\r
113 > which would display messages/threads for that particular query.
\r
115 > Maybe the interface is too complicated but I can actually imagine
\r
116 > using this (possibly even both of the above for different of my saved
\r
125 > emacs/notmuch-hello.el | 41 ++++++++++++++++++++++++++---------------
\r
126 > 1 file changed, 26 insertions(+), 15 deletions(-)
\r
128 > diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el
\r
129 > index 3de5238..877c84f 100644
\r
130 > --- a/emacs/notmuch-hello.el
\r
131 > +++ b/emacs/notmuch-hello.el
\r
132 > @@ -85,7 +85,7 @@ (define-widget 'notmuch-saved-search-plist 'list
\r
133 > (group :format "%v" :inline t (const :format " Query: " :query) (stri=
\r
135 > (checklist :inline t
\r
137 > - (group :format "%v" :inline t (const :format "Count-Query: " :cou=
\r
138 nt-query) (string :format "%v"))
\r
139 > + (group :format "%v" :inline t (const :format "Count-Query: " :cou=
\r
140 nt-query) (sexp :format "%v"))
\r
141 > (group :format "%v" :inline t (const :format "" :sort-order)
\r
142 > (choice :tag " Sort Order"
\r
143 > (const :tag "Default" nil)
\r
144 > @@ -101,9 +101,12 @@ (defcustom notmuch-saved-searches '((:name "inbox" :=
\r
147 > :name Name of the search (required).
\r
148 > :query Search to run (required).
\r
149 > - :count-query Optional extra query to generate the count
\r
150 > - shown. If not present then the :query property
\r
152 > + :count-query Optional extra lisp to generate the count
\r
154 "Optional function to generate the count"
\r
156 > + shown. If it is a string then it is a query
\r
157 > + string for generating the count. If it is a
\r
158 > + function then the function is called with the
\r
159 > + query plist as a parameter. If it is nil or not
\r
160 > + present then the :query property is used.
\r
161 > :sort-order Specify the sort order to be used for the search.
\r
162 > Possible values are 'oldest-first 'newest-first or
\r
163 > nil. Nil means use the default sort order.
\r
164 > @@ -493,13 +496,14 @@ (defun notmuch-hello-query-counts (query-list &rest=
\r
166 > (dolist (elem query-list nil)
\r
167 > (let ((count-query (or (notmuch-saved-search-get elem :count-query)
\r
168 > (notmuch-saved-search-get elem :query))))
\r
170 > - (replace-regexp-in-string
\r
172 > - (notmuch-hello-filtered-query count-query
\r
173 > - (or (plist-get options :filter-count)
\r
174 > - (plist-get options :filter))))
\r
176 > + (unless (functionp count-query)
\r
178 > + (replace-regexp-in-string
\r
180 > + (notmuch-hello-filtered-query count-query
\r
181 > + (or (plist-get options :filter-count)
\r
182 > + (plist-get options :filter))))
\r
185 > (unless (=3D (call-process-region (point-min) (point-max) notmuch-co=
\r
187 > t t nil "count" "--batch") 0)
\r
188 > @@ -515,12 +519,17 @@ (defun notmuch-hello-query-counts (query-list &rest=
\r
192 > (let* ((elem-plist (notmuch-hello-saved-search-to-plist elem))
\r
193 > + (count-query (plist-get elem-plist :count-query))
\r
194 > (search-query (plist-get elem-plist :query))
\r
195 > (filtered-query (notmuch-hello-filtered-query
\r
196 > search-query (plist-get options :filter)))
\r
197 > - (message-count (prog1 (read (current-buffer))
\r
198 > - (forward-line 1))))
\r
199 > - (when (and filtered-query (or (plist-get options :show-empty-searches=
\r
200 ) (> message-count 0)))
\r
201 > + (message-count (if (functionp count-query)
\r
202 > + (funcall count-query elem-plist)
\r
203 > + (prog1 (read (current-buffer))
\r
204 > + (forward-line 1)))))
\r
205 > + (when (and filtered-query (or (plist-get options :show-empty-searches)
\r
206 > + (not (integerp message-count))
\r
207 > + (> message-count 0)))
\r
208 > (setq elem-plist (plist-put elem-plist :query filtered-query))
\r
209 > (plist-put elem-plist :count message-count))))
\r
211 > @@ -559,7 +568,9 @@ (defun notmuch-hello-insert-buttons (searches)
\r
212 > (otherwise notmuch-search-oldest-first)))
\r
213 > (msg-count (plist-get elem :count)))
\r
214 > (widget-insert (format "%8s "
\r
215 > - (notmuch-hello-nice-number msg-count)))
\r
216 > + (if (stringp msg-count)
\r
218 > + (notmuch-hello-nice-number msg-count))))
\r
219 > (widget-create 'push-button
\r
220 > :notify #'notmuch-hello-widget-search
\r
221 > :notmuch-search-terms query
\r
225 > _______________________________________________
\r
226 > notmuch mailing list
\r
227 > notmuch@notmuchmail.org
\r
228 > http://notmuchmail.org/mailman/listinfo/notmuch
\r
231 Content-Type: application/pgp-signature; name="signature.asc"
\r
233 -----BEGIN PGP SIGNATURE-----
\r
236 iKYEARECAGYFAlNpx2xfFIAAAAAALgAoaXNzdWVyLWZwckBub3RhdGlvbnMub3Bl
\r
237 bnBncC5maWZ0aGhvcnNlbWFuLm5ldDc1M0Y5NDJDMEExNjc3MDE4OURGMUYyMDY5
\r
238 RUNEMEFCRjA0OTY1MTYACgkQaezQq/BJZRanBACfVaWh9QqXpXtPes4ky1sHEw3T
\r
239 CbMAn3gKHCtxjT+/SsuZyyuSmXVmWqAP
\r
241 -----END PGP SIGNATURE-----
\r