[PATCH] configure: add --without-api-docs option
[notmuch-archives.git] / 79 / 6ab4cfb5da32a56d532e9c9c0fabda4572ca3c
1 Return-Path: <sojkam1@fel.cvut.cz>\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 5BE97431FD0\r
6         for <notmuch@notmuchmail.org>; Wed,  6 Jul 2011 04:34:27 -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 rKIKz2g6k6Lr for <notmuch@notmuchmail.org>;\r
16         Wed,  6 Jul 2011 04:34:25 -0700 (PDT)\r
17 Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36])\r
18         by olra.theworths.org (Postfix) with ESMTP id 768A4431FB6\r
19         for <notmuch@notmuchmail.org>; Wed,  6 Jul 2011 04:34:24 -0700 (PDT)\r
20 Received: from localhost (unknown [192.168.200.4])\r
21         by max.feld.cvut.cz (Postfix) with ESMTP id 7DE5F3CFE72;\r
22         Wed,  6 Jul 2011 13:34:23 +0200 (CEST)\r
23 X-Virus-Scanned: IMAP AMAVIS\r
24 Received: from max.feld.cvut.cz ([192.168.200.1])\r
25         by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new,\r
26         port 10044)\r
27         with ESMTP id YRJWG8tnnrsy; Wed,  6 Jul 2011 13:34:14 +0200 (CEST)\r
28 Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34])\r
29         by max.feld.cvut.cz (Postfix) with ESMTP id 21F7D19F3376;\r
30         Wed,  6 Jul 2011 13:34:14 +0200 (CEST)\r
31 Received: from steelpick.2x.cz (unknown [141.76.49.12])\r
32         (Authenticated sender: sojkam1)\r
33         by imap.feld.cvut.cz (Postfix) with ESMTPSA id 0B319FA004;\r
34         Wed,  6 Jul 2011 13:34:14 +0200 (CEST)\r
35 Received: from wsh by steelpick.2x.cz with local (Exim 4.76)\r
36         (envelope-from <sojkam1@fel.cvut.cz>)\r
37         id 1QeQMv-0002ul-LR; Wed, 06 Jul 2011 13:34:13 +0200\r
38 From: Michal Sojka <sojkam1@fel.cvut.cz>\r
39 To: Daniel Schoepe <daniel.schoepe@googlemail.com>, notmuch@notmuchmail.org\r
40 Subject: Re: [PATCH v3 1/2] emacs: User-defined sections in notmuch-hello\r
41 In-Reply-To: <1309883030-28899-2-git-send-email-daniel.schoepe@googlemail.com>\r
42 References: <1309379221-5617-1-git-send-email-daniel.schoepe@googlemail.com>\r
43         <1309883030-28899-1-git-send-email-daniel.schoepe@googlemail.com>\r
44         <1309883030-28899-2-git-send-email-daniel.schoepe@googlemail.com>\r
45 User-Agent: Notmuch/0.5-320-g02ea1cf (http://notmuchmail.org) Emacs/23.3.1\r
46         (x86_64-pc-linux-gnu)\r
47 Date: Wed, 06 Jul 2011 13:34:13 +0200\r
48 Message-ID: <87fwmjabii.fsf@steelpick.2x.cz>\r
49 MIME-Version: 1.0\r
50 Content-Type: text/plain; charset=us-ascii\r
51 X-BeenThere: notmuch@notmuchmail.org\r
52 X-Mailman-Version: 2.1.13\r
53 Precedence: list\r
54 List-Id: "Use and development of the notmuch mail system."\r
55         <notmuch.notmuchmail.org>\r
56 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
57         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
58 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
59 List-Post: <mailto:notmuch@notmuchmail.org>\r
60 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
61 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
62         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
63 X-List-Received-Date: Wed, 06 Jul 2011 11:34:27 -0000\r
64 \r
65 Hi,\r
66 \r
67 this is definitely better than the first version I was using! Thanks.\r
68 See other comments below.\r
69 \r
70 On Tue, 05 Jul 2011, Daniel Schoepe wrote:\r
71 > This patch makes the notmuch-hello screen fully customizable\r
72 > by allowing the user to add and remove arbitrary sections. It\r
73 > also provides some convenience functions for constructing sections,\r
74 > e.g. showing the unread message count for each tag.\r
75\r
76 > This is done by specifying a list of functions that will be run\r
77 > when notmuch-hello is invoked.\r
78 > ---\r
79 >  emacs/notmuch-hello.el |  609 +++++++++++++++++++++++++++++++-----------------\r
80 >  1 files changed, 393 insertions(+), 216 deletions(-)\r
81\r
82 > diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
83 > index 65fde75..9c18caa 100644\r
84 > --- a/emacs/notmuch-hello.el\r
85 > +++ b/emacs/notmuch-hello.el\r
86 > @@ -55,26 +55,6 @@\r
87 >    :type 'boolean\r
88 >    :group 'notmuch)\r
89 >  \r
90 > -(defcustom notmuch-hello-tag-list-make-query nil\r
91 > -  "Function or string to generate queries for the all tags list.\r
92 \r
93 I'm not sure it is a good thing to remove customizations that are\r
94 included in a released version. Some users may configure it and their\r
95 configuration disappear when they install a new version. Is there a way\r
96 to migrate this settings to a new, section-based one?\r
97 \r
98 > -This variable controls which query results are shown for each tag\r
99 > -in the \"all tags\" list. If nil, it will use all messages with\r
100 > -that tag. If this is set to a string, it is used as a filter for\r
101 > -messages having that tag (equivalent to \"tag:TAG and (THIS-VARIABLE)\").\r
102 > -Finally this can be a function that will be called for each tag and\r
103 > -should return a filter for that tag, or nil to hide the tag."\r
104 > -  :type '(choice (const :tag "All messages" nil)\r
105 > -              (const :tag "Unread messages" "tag:unread")\r
106 > -              (const :tag "Custom filter" string)\r
107 > -              (const :tag "Custom filter function" function))\r
108 > -  :group 'notmuch)\r
109 > -\r
110 > -(defcustom notmuch-hello-hide-tags nil\r
111 > -  "List of tags to be hidden in the \"all tags\"-section."\r
112 > -  :type '(repeat string)\r
113 > -  :group 'notmuch)\r
114 > -\r
115 >  (defface notmuch-hello-logo-background\r
116 >    '((((class color)\r
117 >        (background dark))\r
118 > @@ -123,6 +103,75 @@ Typically \",\" in the US and UK and \".\" in Europe."\r
119 >  \r
120 >  (defvar notmuch-hello-recent-searches nil)\r
121 >  \r
122 > +(define-widget 'notmuch-hello-tags-section 'lazy\r
123 > +  "Customize-type for notmuch-hello tag-list sections."\r
124 > +  :tag "Customized tag-list"\r
125 \r
126 This is IMHO still hard to understand only from looking at the\r
127 customization widget. Ideally, I'd like to see somewhere a paragraph\r
128 like this: "This displays a list of all tags, optionally hiding some of\r
129 them. It is also possible to filter the list of messages matching each\r
130 tag by an additional filter query. Similarly, the count of messages\r
131 displayed next to the buttons can be generated by applying another\r
132 filter to the tag query."\r
133 \r
134 Actually, when reading the above paragraph, it still seems a way too\r
135 complex. What about the following: I do not think it has sense to list\r
136 custom tags with zero counts - I think everybody would use\r
137 :hide-empty-tags all the time. Then, the result of listing all tags with\r
138 'notmuch search-tags', filtering them with 'filter' and throwing away\r
139 empty tags, would be the same as running 'notmuch search-tags filter'\r
140 and then finding the counts by 'notmuch count tag:TAG and filter'. One\r
141 of the advantage of this approach is that it would probably be faster to\r
142 generate the section, because you won't query the counts of all tags if\r
143 your filter matches only a few of them.\r
144 \r
145 Additionally, as I didn't read carefully your previous discussions about\r
146 the additional filter for counts, I do not see much use for it. If you\r
147 only want to see which tags has unread messages, you can simply add a\r
148 new section with (:make-query "tag:unread") and you would get what you\r
149 want. You can also disable all-tags sections.\r
150 \r
151 So my proposal is to forget about different queries for filters and\r
152 counts and having here only the following options: filter, hide-tags and\r
153 hide-if-empty.\r
154 \r
155 Then, the documentation would be simple: "This section displays buttons\r
156 for all tags of messages matching a FILTER. Optionally, some of these\r
157 tags may be hidden."\r
158 \r
159 Is there a use case, which is not covered by this?\r
160 \r
161 > +  :type\r
162 > +  (let ((opts\r
163 > +      '((:title (string :tag "Title for this section"))\r
164 > +        (:make-query (string :tag "Filter for each tag"))\r
165 > +        (:make-count (string :tag "Different query to generate counts"))\r
166 > +        (:hide-tags (repeat :tag "Tags that will be hidden" string))\r
167 \r
168 I can imagine, that :hide-tags could also be a (list of) regexp(es).\r
169 \r
170 > +        (:initially-hidden (boolean :tag "Hide this on startup?"))\r
171 \r
172 This is IMHO not needed here, as you always has to enable this section\r
173 manually.\r
174 \r
175 > +        (:hide-empty-tags (boolean :tag "Hide tags with no matching messages"))\r
176 > +        (:hide-if-empty (boolean :tag "Hide if empty")))))\r
177 > +    `(list (const :tag "" notmuch-hello-insert-tags-section)\r
178 > +        (plist :inline t :options ,opts))))\r
179 > +\r
180 > +(define-widget 'notmuch-hello-query-section 'lazy\r
181 > +  "Customize-type for custom saved-search-like sections"\r
182 > +  :tag "Customized queries section"\r
183 > +  :type\r
184 > +  '(list (const :tag "" notmuch-hello-insert-query-list)\r
185 > +      (string :tag "Title for this section")\r
186 > +      (repeat :tag "Queries"\r
187 > +              (cons (string :tag "Name") (string :tag "Query")))\r
188 > +      (plist :inline t\r
189 > +             :options\r
190 > +             ((:initially-hidden (boolean :tag "Hide this on startup?"))\r
191 \r
192 Not needed (see above).\r
193 \r
194 > +              (:hide-empty-tags\r
195 \r
196 Rename to :hide-empty-queries.\r
197 \r
198 > +               (boolean :tag "Hide tags with no matching messages"))\r
199 \r
200 Hide queries...\r
201 \r
202 > +              (:hide-if-empty (boolean :tag "Hide if empty"))))))\r
203 > +\r
204 > +(defcustom notmuch-hello-sections\r
205 > +  (list #'notmuch-hello-insert-header\r
206 > +     #'notmuch-hello-insert-saved-searches\r
207 > +     #'notmuch-hello-insert-search\r
208 > +     #'notmuch-hello-insert-recent-searches\r
209 > +     #'notmuch-hello-insert-alltags\r
210 > +     #'notmuch-hello-insert-footer)\r
211 > +  "Sections for notmuch-hello.\r
212 > +\r
213 > +Each entry of this list should be a function of no arguments that\r
214 > +should return if notmuch-hello-target is produced as part of its\r
215 \r
216 What is notmuch-hello-target? I guess I know what it is from reading the\r
217 code, but if I didn't read the code, this mentioning it here would be of\r
218 little value for me. Perhaps make the notmuch-hello-target clickable and\r
219 document it below.\r
220 \r
221 > +output and nil otherwise. For convenience an element can also be\r
222 > +a list of the form (FUNC ARG1 ARG2 .. ARGN) in which case FUNC\r
223 > +will be applied to the rest of the list.\r
224 > +\r
225 > +The functions will be run to construct the content of the\r
226 > +notmuch-hello buffer in the order they appear in this list."\r
227 > +  :group 'notmuch\r
228 > +  :type \r
229 > +  '(repeat\r
230 > +    (choice (function-item notmuch-hello-insert-header)\r
231 > +         (function-item notmuch-hello-insert-saved-searches)\r
232 > +         (function-item notmuch-hello-insert-search)\r
233 > +         (function-item notmuch-hello-insert-recent-searches)\r
234 > +         (function-item notmuch-hello-insert-alltags)\r
235 > +         (function-item notmuch-hello-insert-footer)\r
236 > +         (function-item notmuch-hello-insert-inbox)\r
237 > +         notmuch-hello-tags-section\r
238 > +         notmuch-hello-query-section\r
239 > +         (function :tag "Custom function"))))\r
240 > +\r
241 > +;; only defined to avoid compilation warnings about free variables\r
242 > +(defvar notmuch-hello-target nil)\r
243 \r
244 Add the documentation as discussed above. Additionally, it seems that\r
245 having only the label in this variable is not enough, since the same\r
246 label can appear in multiple sections. Perhaps, we need both the title\r
247 of the section and the label here.\r
248 \r
249 > +(defvar notmuch-hello-hidden-sections nil\r
250 > +  "List of query sections whose contents are hidden")\r
251 \r
252 "List of section titles whose...\r
253 \r
254 > +\r
255 > +(defvar notmuch-hello-first-run t)\r
256 > +\r
257 >  (defun notmuch-hello-remember-search (search)\r
258 >    (if (not (member search notmuch-hello-recent-searches))\r
259 >        (push search notmuch-hello-recent-searches))\r
260 > @@ -173,8 +222,8 @@ Typically \",\" in the US and UK and \".\" in Europe."\r
261 >      (message "Saved '%s' as '%s'." search name)\r
262 >      (notmuch-hello-update)))\r
263 >  \r
264 > -(defun notmuch-hello-longest-label (tag-alist)\r
265 > -  (or (loop for elem in tag-alist\r
266 > +(defun notmuch-hello-longest-label (searches-alist)\r
267 > +  (or (loop for elem in searches-alist\r
268 >           maximize (length (car elem)))\r
269 >        0))\r
270 >  \r
271 > @@ -238,12 +287,71 @@ should be. Returns a cons cell `(tags-per-line width)'."\r
272 >                                  (* tags-per-line (+ 9 1))))\r
273 >                          tags-per-line))))\r
274 >  \r
275 > -(defun notmuch-hello-insert-tags (tag-alist widest target)\r
276 > -  (let* ((tags-and-width (notmuch-hello-tags-per-line widest))\r
277 > +(defun notmuch-hello-filtered-query (query filter)\r
278 > +  "Constructs a query to search all messages matching QUERY and FILTER.\r
279 > +\r
280 > +If FILTER is a string, it is directly used in the returned query.\r
281 > +\r
282 > +If FILTER is a function, it is called with QUERY as a parameter and\r
283 > +the string it returns is used as the filter.\r
284 > +\r
285 > +Otherwise, FILTER is ignored.\r
286 > +"\r
287 > +  (cond\r
288 > +   ((functionp filter)\r
289 > +    (let ((result (funcall filter query)))\r
290 > +      (and result (concat query " and (" result ")"))))\r
291 > +   ((stringp filter)\r
292 > +    (concat query " and (" filter ")"))\r
293 > +   (t (concat query))))\r
294 > +\r
295 > +(defun notmuch-hello-query-counts (query-alist &rest options)\r
296 > +  "Compute list of counts of matched messages from QUERY-ALIST.\r
297 > +\r
298 > +QUERY-ALIST must be a list containing elements of the form (NAME . QUERY)\r
299 > +or (NAME QUERY COUNT-QUERY). If the latter form is used,\r
300 > +COUNT-QUERY specifies an alternate query to be used to generate\r
301 > +the count for the associated query.\r
302 > +\r
303 > +The result is the list of elements of the form (NAME QUERY COUNT).\r
304 > +\r
305 > +The values :hide-empty-searches, :make-query and :make-count from\r
306 > +options will be handled as specified for\r
307 > +`notmuch-hello-insert-searches'."\r
308 > +  (notmuch-remove-if-not\r
309 > +   #'identity\r
310 > +   (mapcar\r
311 > +    (lambda (elem)\r
312 > +      (let* ((name (car elem))\r
313 > +          (query-and-count (if (consp (cdr elem))\r
314 > +                               ;; do we have a different query for the message count?\r
315 > +                               (cons (second elem) (third elem))\r
316 > +                             (cons (cdr elem) (cdr elem))))\r
317 > +          (message-count\r
318 > +           (string-to-number\r
319 > +            (notmuch-saved-search-count\r
320 > +             (notmuch-hello-filtered-query (cdr query-and-count)\r
321 > +                                           (or (plist-get options :make-count)\r
322 > +                                              (plist-get options :make-query)))))))\r
323 > +     (and (or (not (plist-get options :hide-empty-searches)) (> message-count 0))\r
324 > +        (list name (notmuch-hello-filtered-query\r
325 > +                    (car query-and-count) (plist-get options :make-query))\r
326 > +              message-count))))\r
327 > +    query-alist)))\r
328 > +\r
329 > +(defun notmuch-hello-insert-buttons (searches)\r
330 > +  "Insert buttons for SEARCHES.\r
331 > +\r
332 > +SEARCHES must be a list containing lists of the form (NAME QUERY COUNT), where\r
333 > +QUERY is the query to start when the button for the corresponding entry is\r
334 > +activated. COUNT should be the number of messages matching the query.\r
335 > +Such a list can be computed with `notmuch-hello-query-counts'."\r
336 > +  (let* ((widest (notmuch-hello-longest-label searches))\r
337 > +      (tags-and-width (notmuch-hello-tags-per-line widest))\r
338 >        (tags-per-line (car tags-and-width))\r
339 >        (widest (cdr tags-and-width))\r
340 >        (count 0)\r
341 > -      (reordered-list (notmuch-hello-reflect tag-alist tags-per-line))\r
342 > +      (reordered-list (notmuch-hello-reflect searches tags-per-line))\r
343 >        ;; Hack the display of the buttons used.\r
344 >        (widget-push-button-prefix "")\r
345 >        (widget-push-button-suffix "")\r
346 > @@ -253,13 +361,13 @@ should be. Returns a cons cell `(tags-per-line width)'."\r
347 >      (mapc (lambda (elem)\r
348 >           ;; (not elem) indicates an empty slot in the matrix.\r
349 >           (when elem\r
350 > -           (let* ((name (car elem))\r
351 > -                  (query (cdr elem))\r
352 > +           (let* ((name (first elem))\r
353 > +                  (query (second elem))\r
354 > +                  (count (third elem))\r
355 >                    (formatted-name (format "%s " name)))\r
356 >               (widget-insert (format "%8s "\r
357 > -                                    (notmuch-hello-nice-number\r
358 > -                                     (string-to-number (notmuch-saved-search-count query)))))\r
359 > -             (if (string= formatted-name target)\r
360 > +                                    (notmuch-hello-nice-number count)))\r
361 > +             (if (string= formatted-name notmuch-hello-target)\r
362 >                   (setq found-target-pos (point-marker)))\r
363 >               (widget-create 'push-button\r
364 >                              :notify #'notmuch-hello-widget-search\r
365 > @@ -277,7 +385,7 @@ should be. Returns a cons cell `(tags-per-line width)'."\r
366 >           (setq count (1+ count))\r
367 >           (if (eq (% count tags-per-line) 0)\r
368 >               (widget-insert "\n")))\r
369 > -       reordered-list)\r
370 > +       searches)\r
371 >  \r
372 >      ;; If the last line was not full (and hence did not include a\r
373 >      ;; carriage return), insert one now.\r
374 > @@ -325,59 +433,268 @@ should be. Returns a cons cell `(tags-per-line width)'."\r
375 >  (fset 'notmuch-hello-mode-map notmuch-hello-mode-map)\r
376 >  \r
377 >  (defun notmuch-hello-mode ()\r
378 > - "Major mode for convenient notmuch navigation. This is your entry portal into notmuch.\r
379 > +  "Major mode for convenient notmuch navigation. This is your entry portal into notmuch.\r
380 >  \r
381 >  Complete list of currently available key bindings:\r
382 >  \r
383 >  \\{notmuch-hello-mode-map}"\r
384 > - (interactive)\r
385 > - (kill-all-local-variables)\r
386 > - (use-local-map notmuch-hello-mode-map)\r
387 > - (setq major-mode 'notmuch-hello-mode\r
388 > -       mode-name "notmuch-hello")\r
389 > - ;;(setq buffer-read-only t)\r
390 > -)\r
391 > -\r
392 > -(defun notmuch-hello-generate-tag-alist ()\r
393 > +  (interactive)\r
394 > +  (kill-all-local-variables)\r
395 > +  (use-local-map notmuch-hello-mode-map)\r
396 > +  (setq major-mode 'notmuch-hello-mode\r
397 > +     mode-name "notmuch-hello")\r
398 > +  ;;(setq buffer-read-only t)\r
399 \r
400 Don't we want to get rid of this line?\r
401 \r
402 > +  )\r
403 > +\r
404 > +(defun notmuch-hello-generate-tag-alist (&optional hide-tags filter-query filter-count)\r
405 >    "Return an alist from tags to queries to display in the all-tags section."\r
406 >    (notmuch-remove-if-not\r
407 > -   #'cdr\r
408 > +   #'identity\r
409 >     (mapcar (lambda (tag)\r
410 > -          (cons tag\r
411 > -                (cond\r
412 > -                 ((functionp notmuch-hello-tag-list-make-query)\r
413 > -                  (concat "tag:" tag " and ("\r
414 > -                          (funcall notmuch-hello-tag-list-make-query tag) ")"))\r
415 > -                 ((stringp notmuch-hello-tag-list-make-query)\r
416 > -                  (concat "tag:" tag " and ("\r
417 > -                          notmuch-hello-tag-list-make-query ")"))\r
418 > -                 (t (concat "tag:" tag)))))\r
419 > +          (let ((query (notmuch-hello-filtered-query (concat "tag:" tag)\r
420 > +                                                     filter-query)))\r
421 > +            (when query\r
422 > +              (if filter-count\r
423 > +                  (list tag (notmuch-hello-filtered-query tag filter-query)\r
424 > +                        (notmuch-hello-filtered-query (concat "tag:" tag)\r
425 > +                                                      filter-count))\r
426 > +                (cons tag (notmuch-hello-filtered-query\r
427 > +                           (concat "tag:" tag) filter-query))))))\r
428 >          (notmuch-remove-if-not\r
429 >           (lambda (tag)\r
430 > -           (not (member tag notmuch-hello-hide-tags)))\r
431 > +           (not (member tag hide-tags)))\r
432 >           (process-lines notmuch-command "search-tags")))))\r
433 >  \r
434 > +(defun notmuch-hello-insert-header ()\r
435 > +  "Insert the default notmuch-hello header."\r
436 > +  (when notmuch-show-logo\r
437 > +    (let ((image notmuch-hello-logo))\r
438 > +      ;; The notmuch logo uses transparency. That can display poorly\r
439 > +      ;; when inserting the image into an emacs buffer (black logo on\r
440 > +      ;; a black background), so force the background colour of the\r
441 > +      ;; image. We use a face to represent the colour so that\r
442 > +      ;; `defface' can be used to declare the different possible\r
443 > +      ;; colours, which depend on whether the frame has a light or\r
444 > +      ;; dark background.\r
445 > +      (setq image (cons 'image\r
446 > +                     (append (cdr image)\r
447 > +                             (list :background (face-background 'notmuch-hello-logo-background)))))\r
448 > +      (insert-image image))\r
449 > +    (widget-insert "  "))\r
450 > +\r
451 > +  (widget-insert "Welcome to ")\r
452 > +  ;; Hack the display of the links used.\r
453 > +  (let ((widget-link-prefix "")\r
454 > +     (widget-link-suffix ""))\r
455 > +    (widget-create 'link\r
456 > +                :notify (lambda (&rest ignore)\r
457 > +                          (browse-url notmuch-hello-url))\r
458 > +                :help-echo "Visit the notmuch website."\r
459 > +                "notmuch")\r
460 > +    (widget-insert ". ")\r
461 > +    (widget-insert "You have ")\r
462 > +    (widget-create 'link\r
463 > +                :notify (lambda (&rest ignore)\r
464 > +                          (notmuch-hello-update))\r
465 > +                :help-echo "Refresh"\r
466 > +                (notmuch-hello-nice-number\r
467 > +                 (string-to-number (car (process-lines notmuch-command "count")))))\r
468 > +    (widget-insert " messages.")))\r
469 \r
470 Perhaps you want to end this (and also all other) section with an empty\r
471 line so that the order of sections doesn't matter. I use sections in\r
472 this order: header, inbox, saved-searches and there is no space between\r
473 header and inbox and two spaces between inbox and saved-searches.\r
474 \r
475 > +(defun notmuch-hello-insert-saved-searches ()\r
476 > +  "Insert the saved-searches section."\r
477 > +  (let ((searches (notmuch-hello-query-counts\r
478 > +               notmuch-saved-searches\r
479 > +               :hide-empty-searches (not notmuch-show-empty-saved-searches)))\r
480 > +     found-target-pos final-target-pos)\r
481 > +    (when searches\r
482 > +      (widget-insert "\nSaved searches: ")\r
483 \r
484 And here you want to remove the "\n" from the beginning.\r
485 \r
486 > +      (widget-create 'push-button\r
487 > +                  :notify (lambda (&rest ignore)\r
488 > +                            (customize-variable 'notmuch-saved-searches))\r
489 > +                  "edit")\r
490 > +      (widget-insert "\n\n")\r
491 > +      (setq final-target-pos (point-marker))\r
492 > +      (let ((start (point)))\r
493 > +     (setq found-target-pos\r
494 > +           (notmuch-hello-insert-buttons searches))\r
495 > +     (if found-target-pos\r
496 > +         (setq final-target-pos found-target-pos))\r
497 > +     (indent-rigidly start (point) notmuch-hello-indent)\r
498 > +     final-target-pos))))\r
499 > +\r
500 > +(defun notmuch-hello-insert-search ()\r
501 > +  "Insert a search widget."\r
502 > +  (widget-insert "Search: ")\r
503 > +  (setq notmuch-hello-search-bar-marker (point-marker))\r
504 > +  (widget-create 'editable-field\r
505 > +              ;; Leave some space at the start and end of the\r
506 > +              ;; search boxes.\r
507 > +              :size (max 8 (- (window-width) notmuch-hello-indent\r
508 > +                              (length "Search: ")))\r
509 > +              :action (lambda (widget &rest ignore)\r
510 > +                        (notmuch-hello-search (widget-value widget)))))\r
511 > +\r
512 > +(defun notmuch-hello-insert-recent-searches ()\r
513 > +  "Insert recent searches."\r
514 > +  (when notmuch-hello-recent-searches\r
515 > +    (widget-insert "\nRecent searches: ")\r
516 > +    (widget-create 'push-button\r
517 > +                :notify (lambda (&rest ignore)\r
518 > +                          (setq notmuch-hello-recent-searches nil)\r
519 > +                          (notmuch-hello-update))\r
520 > +                "clear")\r
521 > +    (widget-insert "\n\n")\r
522 > +    (let ((start (point))\r
523 > +       (nth 0))\r
524 > +      (mapc '(lambda (search)\r
525 > +            (let ((widget-symbol (intern (format "notmuch-hello-search-%d" nth))))\r
526 > +              (set widget-symbol\r
527 > +                   (widget-create 'editable-field\r
528 > +                                  ;; Don't let the search boxes be\r
529 > +                                  ;; less than 8 characters wide.\r
530 > +                                  :size (max 8\r
531 > +                                             (- (window-width)\r
532 > +                                                ;; Leave some space\r
533 > +                                                ;; at the start and\r
534 > +                                                ;; end of the\r
535 > +                                                ;; boxes.\r
536 > +                                                (* 2 notmuch-hello-indent)\r
537 > +                                                ;; 1 for the space\r
538 > +                                                ;; before the\r
539 > +                                                ;; `[save]' button. 6\r
540 > +                                                ;; for the `[save]'\r
541 > +                                                ;; button.\r
542 > +                                                1 6))\r
543 > +                                  :action (lambda (widget &rest ignore)\r
544 > +                                            (notmuch-hello-search (widget-value widget)))\r
545 > +                                  search))\r
546 > +              (widget-insert " ")\r
547 > +              (widget-create 'push-button\r
548 > +                             :notify (lambda (widget &rest ignore)\r
549 > +                                       (notmuch-hello-add-saved-search widget))\r
550 > +                             :notmuch-saved-search-widget widget-symbol\r
551 > +                             "save"))\r
552 > +            (widget-insert "\n")\r
553 > +            (setq nth (1+ nth)))\r
554 > +         notmuch-hello-recent-searches)\r
555 > +      (indent-rigidly start (point) notmuch-hello-indent))))\r
556 > +\r
557 > +(defun notmuch-hello-insert-searches (title query-alist &rest options)\r
558 > +  "Insert a section with TITLE showing a list of buttons made from QUERY-ALIST.\r
559 > +\r
560 > +QUERY-ALIST must be a list containing elements of the form (NAME . QUERY)\r
561 > +or (NAME QUERY COUNT-QUERY). If the latter form is used,\r
562 > +COUNT-QUERY specifies an alternate query to be used to generate\r
563 > +the count for the associated item.\r
564 > +\r
565 > +Supports the following entries in OPTIONS as a plist:\r
566 > +:initially-hidden - if non-nil, section will be hidden on startup\r
567 > +:hide-empty-searches - hide buttons with no matching messages\r
568 > +:hide-if-empty - hide if no buttons would be shown\r
569 > +   (only makes sense with :hide-empty-searches)\r
570 > +:make-query - This can be a function that takes a tag as its argument and\r
571 > +    returns a filter to be used for the query for that tag or nil to hide the\r
572 > +    tag. This can also be a string that is used as a filter for messages with that tag.\r
573 > +:make-count - Seperate query to generate the count that should be displayed for each\r
574 > +    tag. Accepts the same values as :make-query"\r
575 \r
576 Again, I'm not sure that the distinction between the normal query and\r
577 count query is needed now.\r
578 \r
579 > +  (widget-insert title)\r
580 > +  (if (and notmuch-hello-first-run (plist-get options :initially-hidden))\r
581 > +      (add-to-list 'notmuch-hello-hidden-sections title))\r
582 > +  (let ((is-hidden (member title notmuch-hello-hidden-sections))\r
583 > +     (start (point)))\r
584 > +    (if is-hidden\r
585 > +     (widget-create 'push-button\r
586 > +                    :notify `(lambda (widget &rest ignore)\r
587 > +                               (setq notmuch-hello-hidden-sections\r
588 > +                                     (delete ,title notmuch-hello-hidden-sections))\r
589 > +                               (notmuch-hello-update))\r
590 > +                    "show")\r
591 > +      (widget-create 'push-button\r
592 > +                  :notify `(lambda (widget &rest ignore)\r
593 > +                             (add-to-list 'notmuch-hello-hidden-sections\r
594 > +                                          ,title)\r
595 > +                             (notmuch-hello-update))\r
596 > +                  "hide"))\r
597 > +    (widget-insert "\n")\r
598 > +    (let (target-pos\r
599 > +       (searches (apply 'notmuch-hello-query-counts query-alist options)))\r
600 > +      (when (and (not is-hidden)\r
601 > +            (or (not (plist-get options :hide-if-empty))\r
602 > +               searches))\r
603 > +     (widget-insert "\n")\r
604 > +     (setq target-pos\r
605 > +           (notmuch-hello-insert-buttons searches))\r
606 > +     (indent-rigidly start (point) notmuch-hello-indent)\r
607 > +     target-pos))))\r
608 > +\r
609 > +(defun notmuch-hello-insert-tags-section (&optional title &rest options)\r
610 > +  "Insert a section displaying all tags and message counts for each.\r
611 > +\r
612 > +TITLE defaults to \"All tags: \".\r
613 > +Allowed options are those accepted by `notmuch-hello-insert-searches' and the\r
614 > +following:\r
615 > +\r
616 > +:hide-tags - List of tags that should be excluded."\r
617 > +  (apply 'notmuch-hello-insert-searches\r
618 > +      (or title "All tags: ")\r
619 > +      (notmuch-hello-generate-tag-alist\r
620 > +       (plist-get options :hide-tags)\r
621 > +       (plist-get options :make-query)\r
622 > +       (plist-get options :make-count))\r
623 > +      options))\r
624 > +\r
625 > +(defun notmuch-hello-insert-inbox ()\r
626 > +  "Show an entry for each saved search and inboxed messages for each tag"\r
627 > +  (notmuch-hello-insert-searches "What's in your inbox: "\r
628 > +                              (append\r
629 > +                               (notmuch-saved-searches)\r
630 > +                               (notmuch-hello-generate-tag-alist))\r
631 > +                              :make-query "tag:inbox"\r
632 > +                              :hide-empty-searches t))\r
633 > +\r
634 > +(defun notmuch-hello-insert-alltags ()\r
635 > +  "Insert a section displaying all tags and associated message counts"\r
636 > +  (notmuch-hello-insert-tags-section nil :initially-hidden\r
637 > +                                  (not notmuch-show-all-tags-list)))\r
638 > +\r
639 > +(defun notmuch-hello-insert-footer ()\r
640 > +  "Insert the notmuch-hello footer."\r
641 > +  (let ((start (point)))\r
642 > +    (widget-insert "Type a search query and hit RET to view matching threads.\n")\r
643 > +    (when notmuch-hello-recent-searches\r
644 > +      (widget-insert "Hit RET to re-submit a previous search. Edit it first if you like.\n")\r
645 > +      (widget-insert "Save recent searches with the `save' button.\n"))\r
646 > +    (when notmuch-saved-searches\r
647 > +      (widget-insert "Edit saved searches with the `edit' button.\n"))\r
648 > +    (widget-insert "Hit RET or click on a saved search or tag name to view matching threads.\n")\r
649 > +    (widget-insert "`=' refreshes this screen. `s' jumps to the search box. `q' to quit.\n")\r
650 > +    (let ((fill-column (- (window-width) notmuch-hello-indent)))\r
651 > +      (center-region start (point)))))\r
652 \r
653 I might be useful to include here a link to the customization of this\r
654 page. Maybe, it would be useful to have notmuch-hello subgroup in\r
655 customization interface and link to this group. But creation of the\r
656 subgroup should be definitely in a separate patch.\r
657 \r
658 Thanks again for such a great functionality.\r
659 \r
660 -Michal\r