]> git.notmuchmail.org Git - notmuch/blob - notmuch.el
notmuch.el: Make the magic spacebar archive a thread in the end.
[notmuch] / notmuch.el
1 ; notmuch.el --- run notmuch within emacs
2 ;
3 ; Copyright © Carl Worth
4 ;
5 ; This file is part of Notmuch.
6 ;
7 ; Notmuch is free software: you can redistribute it and/or modify it
8 ; under the terms of the GNU General Public License as published by
9 ; the Free Software Foundation, either version 3 of the License, or
10 ; (at your option) any later version.
11 ;
12 ; Notmuch is distributed in the hope that it will be useful, but
13 ; WITHOUT ANY WARRANTY; without even the implied warranty of
14 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 ; General Public License for more details.
16 ;
17 ; You should have received a copy of the GNU General Public License
18 ; along with Notmuch.  If not, see <http://www.gnu.org/licenses/>.
19 ;
20 ; Authors: Carl Worth <cworth@cworth.org>
21
22 (defvar notmuch-show-mode-map
23   (let ((map (make-sparse-keymap)))
24     ; I don't actually want all of these toggle commands occupying
25     ; keybindings. They steal valuable key-binding space, are hard
26     ; to remember, and act globally rather than locally.
27     ;
28     ; Will be much preferable to switch to direct manipulation for
29     ; toggling visibility of these components. Probably using
30     ; overlays-at to query and manipulate the current overlay.
31     (define-key map "a" 'notmuch-show-archive-thread)
32     (define-key map "b" 'notmuch-show-toggle-body-read-visible)
33     (define-key map "c" 'notmuch-show-toggle-citations-visible)
34     (define-key map "h" 'notmuch-show-toggle-headers-visible)
35     (define-key map "n" 'notmuch-show-mark-read-then-next-message)
36     (define-key map "p" 'notmuch-show-previous-message)
37     (define-key map "q" 'kill-this-buffer)
38     (define-key map "s" 'notmuch-show-toggle-signatures-visible)
39     (define-key map "x" 'kill-this-buffer)
40     (define-key map "+" 'notmuch-show-add-tag)
41     (define-key map "-" 'notmuch-show-remove-tag)
42     (define-key map " " 'notmuch-show-advance-marking-read-and-archiving)
43     map)
44   "Keymap for \"notmuch show\" buffers.")
45 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
46
47 (defvar notmuch-show-message-begin-regexp    "\fmessage{")
48 (defvar notmuch-show-message-end-regexp      "\fmessage}")
49 (defvar notmuch-show-header-begin-regexp     "\fheader{")
50 (defvar notmuch-show-header-end-regexp       "\fheader}")
51 (defvar notmuch-show-body-begin-regexp       "\fbody{")
52 (defvar notmuch-show-body-end-regexp         "\fbody}")
53 (defvar notmuch-show-attachment-begin-regexp "\fattachment{")
54 (defvar notmuch-show-attachment-end-regexp   "\fattachment}")
55 (defvar notmuch-show-part-begin-regexp       "\fpart{")
56 (defvar notmuch-show-part-end-regexp         "\fpart}")
57 (defvar notmuch-show-marker-regexp "\f\\(message\\|header\\|body\\|attachment\\|part\\)[{}].*$")
58
59 (defvar notmuch-show-id-regexp "ID: \\(.*\\)$")
60 (defvar notmuch-show-tags-regexp "(\\([^)]*\\))$")
61
62 (defun notmuch-show-get-message-id ()
63   (save-excursion
64     (beginning-of-line)
65     (if (not (looking-at notmuch-show-message-begin-regexp))
66         (re-search-backward notmuch-show-message-begin-regexp))
67     (re-search-forward notmuch-show-id-regexp)
68     (buffer-substring (match-beginning 1) (match-end 1))))
69
70 (defun notmuch-show-set-tags (tags)
71   (save-excursion
72     (beginning-of-line)
73     (if (not (looking-at notmuch-show-message-begin-regexp))
74         (re-search-backward notmuch-show-message-begin-regexp))
75     (re-search-forward notmuch-show-tags-regexp)
76     (let ((inhibit-read-only t)
77           (beg (match-beginning 1))
78           (end (match-end 1)))
79       (delete-region beg end)
80       (goto-char beg)
81       (insert (mapconcat 'identity tags " ")))))
82
83 (defun notmuch-show-get-tags ()
84   (save-excursion
85     (beginning-of-line)
86     (if (not (looking-at notmuch-show-message-begin-regexp))
87         (re-search-backward notmuch-show-message-begin-regexp))
88     (re-search-forward notmuch-show-tags-regexp)
89     (split-string (buffer-substring (match-beginning 1) (match-end 1)))))
90
91 (defun notmuch-show-add-tag (tag)
92   (interactive "sTag to add: ")
93   (notmuch-call-notmuch-process "tag" (concat "+" tag) (concat "id:" (notmuch-show-get-message-id)))
94   (notmuch-show-set-tags (delete-dups (sort (cons tag (notmuch-show-get-tags)) 'string<))))
95
96 (defun notmuch-show-remove-tag (tag)
97   (interactive "sTag to remove: ")
98   (notmuch-call-notmuch-process "tag" (concat "-" tag) (concat "id:" (notmuch-show-get-message-id)))
99   (notmuch-show-set-tags (delete tag (notmuch-show-get-tags))))
100
101 (defun notmuch-show-archive-thread ()
102   "Archive each message currrently shown by removing the \"inbox\" tag from each.
103
104 This command is safe from any race condition of new messages
105 being delivered to the same thread. It does not archive the
106 entire thread, but only the messages shown in the current
107 buffer."
108   (interactive)
109   (save-excursion
110     (goto-char (point-min))
111     (while (not (eobp))
112       (notmuch-show-remove-tag "inbox")
113       (if (not (eobp))
114           (forward-char))
115       (if (not (re-search-forward notmuch-show-message-begin-regexp nil t))
116           (goto-char (point-max))))))
117
118 (defun notmuch-show-move-to-current-message-summary-line ()
119   "Move to the beginning of the one-line summary of the current message.
120
121 This gives us a stable place to move to and work from since the
122 summary line is always visible. This is important since moving to
123 an invisible location is unreliable, (the main command loop moves
124 point either forward or backward to the next visible character
125 when a command ends with point on an invisible character).
126
127 Emits an error if point is not within a valid message, (that is
128 not pattern of `notmuch-show-message-begin-regexp' could be found
129 by searching backward)."
130   (beginning-of-line)
131   (if (not (looking-at notmuch-show-message-begin-regexp))
132       (if (re-search-backward notmuch-show-message-begin-regexp nil t)
133           (forward-line 2)
134         (error "Not within a valid message."))
135     (forward-line 2)))
136
137 (defun notmuch-show-next-message ()
138   "Advance to the beginning of the next message in the buffer.
139
140 Moves to the beginning of the current message if already on the
141 last message in the buffer."
142   (interactive)
143   (notmuch-show-move-to-current-message-summary-line)
144   (re-search-forward notmuch-show-message-begin-regexp nil t)
145   (notmuch-show-move-to-current-message-summary-line)
146   (recenter 0))
147
148 (defun notmuch-show-find-next-message ()
149   "Returns the position of the next message in the buffer.
150
151 Or the beginning of the current message if already within the last
152 message in the buffer."
153   ; save-excursion doesn't save our window position
154   ; save-window-excursion doesn't save point
155   ; Looks like we have to use both.
156   (save-excursion
157     (save-window-excursion
158       (notmuch-show-next-message)
159       (point))))
160
161 (defun notmuch-show-previous-message ()
162   "Backup to the beginning of the previous message in the buffer.
163
164 If within a message rather than at the beginning of it, then
165 simply move to the beginning of the current message."
166   (interactive)
167   (let ((start (point)))
168     (notmuch-show-move-to-current-message-summary-line)
169     (if (not (< (point) start))
170         ; Go backward twice to skip the current message's marker
171         (progn
172           (re-search-backward notmuch-show-message-begin-regexp nil t)
173           (re-search-backward notmuch-show-message-begin-regexp nil t)
174           (notmuch-show-move-to-current-message-summary-line)
175           ))
176     (recenter 0)))
177
178 (defun notmuch-show-mark-read-then-next-message ()
179   "Remove unread tag from current message, then advance to next message."
180   (interactive)
181   (if (member "unread" (notmuch-show-get-tags))
182       (notmuch-show-remove-tag "unread"))
183   (notmuch-show-next-message))
184
185 (defun notmuch-show-advance-marking-read-and-archiving ()
186   "Advance through buffer, marking read and archiving.
187
188 This command is intended to be one of the simplest ways to
189 process a thread of email. It does the following:
190
191 If the current message in the thread is not yet fully visible,
192 scroll by a near screenful to read more of the message.
193
194 Otherwise, (the end of the current message is already within the
195 current window), remove the \"unread\" tag from the current
196 message and advance to the next message.
197
198 Finally, if there is no further message to advance to, and this
199 last message is already read, then archive the entire current
200 thread, (remove the \"inbox\" tag from each message)."
201   (interactive)
202   (let ((next (notmuch-show-find-next-message))
203         (unread (member "unread" (notmuch-show-get-tags))))
204     (if (and (not unread)
205              (equal next (point)))
206         (notmuch-show-archive-thread)
207       (if (< (notmuch-show-find-next-message) (window-end))
208           (notmuch-show-mark-read-then-next-message)
209         (scroll-up nil)))))
210
211 (defun notmuch-show-markup-citations-region (beg end)
212   (goto-char beg)
213   (beginning-of-line)
214   (while (< (point) end)
215     (let ((beg-sub (point)))
216       (if (looking-at ">")
217           (progn
218             (while (looking-at ">")
219               (next-line))
220             (let ((overlay (make-overlay beg-sub (point))))
221               (overlay-put overlay 'invisible 'notmuch-show-citation)
222               (overlay-put overlay 'before-string
223                            (concat "[" (number-to-string (count-lines beg-sub (point)))
224                                    " quoted lines.]")))))
225       (if (looking-at "--[ ]?$")
226           (let ((overlay (make-overlay beg-sub end)))
227             (overlay-put overlay 'invisible 'notmuch-show-signature)
228             (overlay-put overlay 'before-string
229                          (concat "[" (number-to-string (count-lines beg-sub (point)))
230                                  "-line signature.]"))
231             (goto-char end)))
232       (next-line))))
233
234 (defun notmuch-show-markup-body ()
235   (re-search-forward notmuch-show-body-begin-regexp)
236   (next-line 1)
237   (beginning-of-line)
238   (let ((beg (point)))
239     (re-search-forward notmuch-show-body-end-regexp)
240     (let ((end (match-beginning 0)))
241       (notmuch-show-markup-citations-region beg end)
242       (if (not (member "unread" (notmuch-show-get-tags)))
243           (overlay-put (make-overlay beg end)
244                        'invisible 'notmuch-show-body-read)))))
245
246 (defun notmuch-show-markup-header ()
247   (re-search-forward notmuch-show-header-begin-regexp)
248   (next-line 2)
249   (beginning-of-line)
250   (let ((beg (point)))
251     (re-search-forward notmuch-show-header-end-regexp)
252     (overlay-put (make-overlay beg (match-beginning 0))
253                  'invisible 'notmuch-show-header)))
254
255 (defun notmuch-show-markup-message ()
256   (if (re-search-forward notmuch-show-message-begin-regexp nil t)
257       (progn
258         (notmuch-show-markup-header)
259         (notmuch-show-markup-body))
260     (goto-char (point-max))))
261
262 (defun notmuch-show-hide-markers ()
263   (save-excursion
264     (goto-char (point-min))
265     (while (not (eobp))
266       (if (re-search-forward notmuch-show-marker-regexp nil t)
267           (progn
268             (overlay-put (make-overlay (match-beginning 0) (+ (match-end 0) 1))
269                          'invisible 'notmuch-show-marker))
270         (goto-char (point-max))))))
271
272 (defun notmuch-show-markup-messages ()
273   (save-excursion
274     (goto-char (point-min))
275     (while (not (eobp))
276       (notmuch-show-markup-message)))
277   (notmuch-show-hide-markers))
278
279 (defun notmuch-show-toggle-citations-visible ()
280   "Toggle visibility of citations"
281   (interactive)
282   (if notmuch-show-citations-visible
283       (add-to-invisibility-spec 'notmuch-show-citation)
284     (remove-from-invisibility-spec 'notmuch-show-citation))
285   (set 'notmuch-show-citations-visible (not notmuch-show-citations-visible))
286   ; Need to force the redisplay for some reason
287   (force-window-update)
288   (redisplay t))
289
290 (defun notmuch-show-toggle-signatures-visible ()
291   "Toggle visibility of signatures"
292   (interactive)
293   (if notmuch-show-signatures-visible
294       (add-to-invisibility-spec 'notmuch-show-signature)
295     (remove-from-invisibility-spec 'notmuch-show-signature))
296   (set 'notmuch-show-signatures-visible (not notmuch-show-signatures-visible))
297   ; Need to force the redisplay for some reason
298   (force-window-update)
299   (redisplay t))
300
301 (defun notmuch-show-toggle-headers-visible ()
302   "Toggle visibility of header fields"
303   (interactive)
304   (if notmuch-show-headers-visible
305       (add-to-invisibility-spec 'notmuch-show-header)
306     (remove-from-invisibility-spec 'notmuch-show-header))
307   (set 'notmuch-show-headers-visible (not notmuch-show-headers-visible))
308   ; Need to force the redisplay for some reason
309   (force-window-update)
310   (redisplay t))
311
312 (defun notmuch-show-toggle-body-read-visible ()
313   "Toggle visibility of message bodies of read messages"
314   (interactive)
315   (if notmuch-show-body-read-visible
316       (add-to-invisibility-spec 'notmuch-show-body-read)
317     (remove-from-invisibility-spec 'notmuch-show-body-read))
318   (set 'notmuch-show-body-read-visible (not notmuch-show-body-read-visible))
319   ; Need to force the redisplay for some reason
320   (force-window-update)
321   (redisplay t))
322
323 ;;;###autoload
324 (defun notmuch-show-mode ()
325   "Major mode for viewing a thread with notmuch.
326
327 This buffer contains the results of the \"notmuch show\" command
328 for displaying a single thread of email from your email archives.
329
330 By default, various components of email messages, (citations,
331 signatures, already-read messages), are invisible to help you
332 focus on the most important things, (new text from unread
333 messages). See the various commands below for toggling the
334 visibility of hidden components.
335
336 The `notmuch-show-next-message' and
337 `notmuch-show-previous-message' commands, (bound to 'n' and 'p by
338 default), allow you to navigate to the next and previous
339 messages. Each time you navigate away from a message with
340 `notmuch-show-next-message' the current message will have its
341 \"unread\" tag removed.
342
343 You can add or remove tags from the current message with '+' and
344 '-'.  You can also archive all messages in the current
345 view, (remove the \"inbox\" tag from each), with
346 `notmuch-show-archive-thread' (bound to 'a' by default).
347
348 \\{notmuch-show-mode-map}"
349   (interactive)
350   (kill-all-local-variables)
351   (set (make-local-variable 'notmuch-show-headers-visible) t)
352   (notmuch-show-toggle-headers-visible)
353   (set (make-local-variable 'notmuch-show-body-read-visible) t)
354   (notmuch-show-toggle-body-read-visible)
355   (set (make-local-variable 'notmuch-show-citations-visible) t)
356   (notmuch-show-toggle-citations-visible)
357   (set (make-local-variable 'notmuch-show-signatures-visible) t)
358   (notmuch-show-toggle-signatures-visible)
359   (add-to-invisibility-spec 'notmuch-show-marker)
360   (use-local-map notmuch-show-mode-map)
361   (setq major-mode 'notmuch-show-mode
362         mode-name "notmuch-show")
363   (setq buffer-read-only t))
364
365 (defun notmuch-show (thread-id)
366   "Run \"notmuch show\" with the given thread ID and display results."
367   (interactive "sNotmuch show: ")
368   (let ((buffer (get-buffer-create (concat "*notmuch-show-" thread-id "*"))))
369     (switch-to-buffer buffer)
370     (notmuch-show-mode)
371     (let ((proc (get-buffer-process (current-buffer)))
372           (inhibit-read-only t))
373       (if proc
374           (error "notmuch search process already running for query `%s'" query)
375         )
376       (erase-buffer)
377       (goto-char (point-min))
378       (save-excursion
379         (call-process "notmuch" nil t nil "show" thread-id)
380         (notmuch-show-markup-messages)
381         )
382       )))
383
384 (defvar notmuch-search-mode-map
385   (let ((map (make-sparse-keymap)))
386     (define-key map "a" 'notmuch-search-archive-thread)
387     (define-key map "b" 'scroll-down)
388     (define-key map "f" 'notmuch-search-filter)
389     (define-key map "n" 'next-line)
390     (define-key map "p" 'previous-line)
391     (define-key map "q" 'kill-this-buffer)
392     (define-key map "s" 'notmuch-search)
393     (define-key map "t" 'notmuch-search-filter-by-tag)
394     (define-key map "x" 'kill-this-buffer)
395     (define-key map "\r" 'notmuch-search-show-thread)
396     (define-key map "+" 'notmuch-search-add-tag)
397     (define-key map "-" 'notmuch-search-remove-tag)
398     (define-key map "<" 'beginning-of-buffer)
399     (define-key map ">" 'notmuch-search-goto-last-thread)
400     (define-key map "=" 'notmuch-search-refresh-view)
401     (define-key map "\M->" 'notmuch-search-goto-last-thread)
402     (define-key map " " 'scroll-up)
403     (define-key map (kbd "<DEL>") 'scroll-down)
404     map)
405   "Keymap for \"notmuch search\" buffers.")
406 (fset 'notmuch-search-mode-map notmuch-search-mode-map)
407
408 (defun notmuch-search-goto-last-thread (&optional arg)
409   "Move point to the last thread in the buffer."
410   (interactive "^P")
411   (end-of-buffer arg)
412   (beginning-of-line))
413
414 ;;;###autoload
415 (defun notmuch-search-mode ()
416   "Major mode for searching mail with notmuch.
417
418 This buffer contains the results of a \"notmuch search\" of your
419 email archives. Each line in the buffer represents a single
420 thread giving a relative date for the thread and a subject.
421
422 Pressing RET on any line displays that thread. The '+' and '-'
423 keys can be used to add or remove tags from a thread. The 'a' key
424 is a convenience key for archiving a thread (removing the
425 \"inbox\" tag).
426
427 Other useful commands are `notmuch-search-filter' for filtering
428 the current search based on an additional query string,
429 `notmuch-search-filter-by-tag' for filtering to include only
430 messages with a given tag, and `notmuch-search' to execute a new,
431 global search.
432
433 \\{notmuch-search-mode-map}"
434   (interactive)
435   (kill-all-local-variables)
436   (make-local-variable 'notmuch-search-query-string)
437   (set (make-local-variable 'scroll-preserve-screen-position) t)
438   (add-to-invisibility-spec 'notmuch-search)
439   (use-local-map notmuch-search-mode-map)
440   (setq major-mode 'notmuch-search-mode
441         mode-name "notmuch-search")
442   (setq buffer-read-only t))
443
444 (defun notmuch-search-find-thread-id ()
445   (save-excursion
446     (beginning-of-line)
447     (let ((beg (point)))
448       (re-search-forward "[a-fA-F0-9]*")
449       (filter-buffer-substring beg (point)))))
450
451 (defun notmuch-search-markup-this-thread-id ()
452   (beginning-of-line)
453   (let ((beg (point)))
454     (re-search-forward "[a-fA-F0-9]*")
455     (forward-char)
456     (overlay-put (make-overlay beg (point)) 'invisible 'notmuch-search)))
457
458 (defun notmuch-search-markup-thread-ids ()
459   (save-excursion
460     (goto-char (point-min))
461     (while (not (eobp))
462       (notmuch-search-markup-this-thread-id)
463       (next-line))))
464
465 (defun notmuch-search-hide-thread-ids ()
466   (interactive)
467   (add-to-invisibility-spec 'notmuch-search)
468   (force-window-update)
469   (redisplay t))
470
471 (defun notmuch-search-show-thread-ids ()
472   (interactive)
473   (remove-from-invisibility-spec 'notmuch-search)
474   (force-window-update)
475   (redisplay t))
476
477 (defun notmuch-search-show-thread ()
478   (interactive)
479   (notmuch-show (notmuch-search-find-thread-id)))
480
481 (defun notmuch-call-notmuch-process (&rest args)
482   (let ((error-buffer (get-buffer-create "*Notmuch errors*")))
483     (with-current-buffer error-buffer
484         (erase-buffer))
485     (if (eq (apply 'call-process "notmuch" nil error-buffer nil args) 0)
486         (point)
487       (progn
488         (with-current-buffer error-buffer
489           (let ((beg (point-min))
490                 (end (- (point-max) 1)))
491             (error (buffer-substring beg end))
492             ))))))
493
494 (defun notmuch-search-set-tags (tags)
495   (save-excursion
496     (end-of-line)
497     (re-search-backward "(")
498     (forward-char)
499     (let ((beg (point))
500           (inhibit-read-only t))
501       (re-search-forward ")")
502       (backward-char)
503       (let ((end (point)))
504         (delete-region beg end)
505         (insert (mapconcat  'identity tags " "))))))
506
507 (defun notmuch-search-get-tags ()
508   (save-excursion
509     (end-of-line)
510     (re-search-backward "(")
511     (let ((beg (+ (point) 1)))
512       (re-search-forward ")")
513       (let ((end (- (point) 1)))
514         (split-string (buffer-substring beg end))))))
515
516 (defun notmuch-search-add-tag (tag)
517   (interactive "sTag to add: ")
518   (notmuch-call-notmuch-process "tag" (concat "+" tag) (concat "thread:" (notmuch-search-find-thread-id)))
519   (notmuch-search-set-tags (delete-dups (sort (cons tag (notmuch-search-get-tags)) 'string<))))
520
521 (defun notmuch-search-remove-tag (tag)
522   (interactive "sTag to remove: ")
523   (notmuch-call-notmuch-process "tag" (concat "-" tag) (concat "thread:" (notmuch-search-find-thread-id)))
524   (notmuch-search-set-tags (delete tag (notmuch-search-get-tags))))
525
526 (defun notmuch-search-archive-thread ()
527   "Archive the current thread (remove its \"inbox\" tag).
528
529 This function advances point to the next line when finished."
530   (interactive)
531   (notmuch-search-remove-tag "inbox")
532   (next-line))
533
534 (defun notmuch-search (query)
535   "Run \"notmuch search\" with the given query string and display results."
536   (interactive "sNotmuch search: ")
537   (let ((buffer (get-buffer-create (concat "*notmuch-search-" query "*"))))
538     (switch-to-buffer buffer)
539     (notmuch-search-mode)
540     (set 'notmuch-search-query-string query)
541     (let ((proc (get-buffer-process (current-buffer)))
542           (inhibit-read-only t))
543       (if proc
544           (error "notmuch search process already running for query `%s'" query)
545         )
546       (erase-buffer)
547       (goto-char (point-min))
548       (save-excursion
549         (call-process "notmuch" nil t nil "search" query)
550         (notmuch-search-markup-thread-ids)
551         ; A well-behaved program ends its output with a newline, but we
552         ; don't actually want the blank line at the end of the file.
553         (goto-char (point-max))
554         (if (looking-at "^$")
555             (delete-backward-char 1)
556           )
557         ))))
558
559 (defun notmuch-search-refresh-view ()
560   "Refresh the current view.
561
562 Kills the current buffer and runs a new search with the same
563 query string as the current search. If the current thread is in
564 the new search results, then point will be placed on the same
565 thread. Otherwise, point will be moved to attempt to be in the
566 same relative position within the new buffer."
567   (interactive)
568   (let ((here (point))
569         (thread (notmuch-search-find-thread-id))
570         (query notmuch-search-query-string))
571     (kill-this-buffer)
572     (notmuch-search query)
573     (goto-char (point-min))
574     (if (re-search-forward (concat "^" thread) nil t)
575         (beginning-of-line)
576       (goto-char here))))
577
578 (defun notmuch-search-filter (query)
579   "Filter the current search results based on an additional query string.
580
581 Runs a new search matching only messages that match both the
582 current search results AND the additional query string provided."
583   (interactive "sFilter search: ")
584   (notmuch-search (concat notmuch-search-query-string " and " query)))
585
586 (defun notmuch-search-filter-by-tag (tag)
587   "Filter the current search results based on a single tag.
588
589 Runs a new search matching only messages that match both the
590 current search results AND that are tagged with the given tag."
591   (interactive "sFilter by tag: ")
592   (notmuch-search (concat notmuch-search-query-string " and tag:" tag)))
593
594 (defun notmuch ()
595   "Run notmuch to display all mail with tag of 'inbox'"
596   (interactive)
597   (notmuch-search "tag:inbox"))
598
599 (provide 'notmuch)