1 ; notmuch.el --- run notmuch within emacs
3 ; Copyright © Carl Worth
5 ; This file is part of Notmuch.
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.
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.
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/>.
20 ; Authors: Carl Worth <cworth@cworth.org>
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.
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-next-message)
36 (define-key map "p" 'notmuch-show-previous-message)
37 (define-key map (kbd "C-n") 'notmuch-show-next-line)
38 (define-key map (kbd "C-p") 'notmuch-show-previous-line)
39 (define-key map "q" 'kill-this-buffer)
40 (define-key map "s" 'notmuch-show-toggle-signatures-visible)
41 (define-key map "x" 'kill-this-buffer)
42 (define-key map "+" 'notmuch-show-add-tag)
43 (define-key map "-" 'notmuch-show-remove-tag)
44 (define-key map " " 'notmuch-show-advance-marking-read-and-archiving)
46 "Keymap for \"notmuch show\" buffers.")
47 (fset 'notmuch-show-mode-map notmuch-show-mode-map)
49 (defvar notmuch-show-message-begin-regexp "
\fmessage{")
50 (defvar notmuch-show-message-end-regexp "
\fmessage}")
51 (defvar notmuch-show-header-begin-regexp "
\fheader{")
52 (defvar notmuch-show-header-end-regexp "
\fheader}")
53 (defvar notmuch-show-body-begin-regexp "
\fbody{")
54 (defvar notmuch-show-body-end-regexp "
\fbody}")
55 (defvar notmuch-show-attachment-begin-regexp "
\fattachment{")
56 (defvar notmuch-show-attachment-end-regexp "
\fattachment}")
57 (defvar notmuch-show-part-begin-regexp "
\fpart{")
58 (defvar notmuch-show-part-end-regexp "
\fpart}")
59 (defvar notmuch-show-marker-regexp "
\f\\(message\\|header\\|body\\|attachment\\|part\\)[{}].*$")
61 (defvar notmuch-show-id-regexp "ID: \\(.*\\)$")
62 (defvar notmuch-show-tags-regexp "(\\([^)]*\\))$")
64 ; XXX: This should be a generic function in emacs somewhere, not here
65 (defun point-invisible-p ()
66 "Return whether the character at point is invisible.
68 Here visibility is determined by `buffer-invisibility-spec' and
69 the invisible property of any overlays for point. It doesn't have
70 anything to do with whether point is currently being displayed
71 within the current window."
72 (let ((prop (get-char-property (point) 'invisible)))
73 (if (eq buffer-invisibility-spec t)
75 (or (memq prop buffer-invisibility-spec)
76 (assq prop buffer-invisibility-spec)))))
78 (defun notmuch-show-next-line ()
79 "Like builtin `next-line' but ensuring we end on a visible character.
81 By advancing forward until reaching a visible character.
83 Unlike builtin `next-line' this version accepts no arguments."
85 (set 'this-command 'next-line)
86 (call-interactively 'next-line)
87 (while (point-invisible-p)
90 (defun notmuch-show-previous-line ()
91 "Like builtin `previous-line' but ensuring we end on a visible character.
93 By advancing forward until reaching a visible character.
95 Unlike builtin `next-line' this version accepts no arguments."
97 (set 'this-command 'previous-line)
98 (call-interactively 'previous-line)
99 (while (point-invisible-p)
102 (defun notmuch-show-get-message-id ()
105 (if (not (looking-at notmuch-show-message-begin-regexp))
106 (re-search-backward notmuch-show-message-begin-regexp))
107 (re-search-forward notmuch-show-id-regexp)
108 (buffer-substring (match-beginning 1) (match-end 1))))
110 (defun notmuch-show-set-tags (tags)
113 (if (not (looking-at notmuch-show-message-begin-regexp))
114 (re-search-backward notmuch-show-message-begin-regexp))
115 (re-search-forward notmuch-show-tags-regexp)
116 (let ((inhibit-read-only t)
117 (beg (match-beginning 1))
119 (delete-region beg end)
121 (insert (mapconcat 'identity tags " ")))))
123 (defun notmuch-show-get-tags ()
126 (if (not (looking-at notmuch-show-message-begin-regexp))
127 (re-search-backward notmuch-show-message-begin-regexp))
128 (re-search-forward notmuch-show-tags-regexp)
129 (split-string (buffer-substring (match-beginning 1) (match-end 1)))))
131 (defun notmuch-show-add-tag (tag)
132 (interactive "sTag to add: ")
133 (notmuch-call-notmuch-process "tag" (concat "+" tag) (concat "id:" (notmuch-show-get-message-id)))
134 (notmuch-show-set-tags (delete-dups (sort (cons tag (notmuch-show-get-tags)) 'string<))))
136 (defun notmuch-show-remove-tag (tag)
137 (interactive "sTag to remove: ")
138 (let ((tags (notmuch-show-get-tags)))
139 (if (member tag tags)
141 (notmuch-call-notmuch-process "tag" (concat "-" tag) (concat "id:" (notmuch-show-get-message-id)))
142 (notmuch-show-set-tags (delete tag tags))))))
144 (defun notmuch-show-archive-thread ()
145 "Archive each message in thread, and show next thread from search.
147 Archive each message currrently shown by removing the \"inbox\"
148 tag from each. Then kill this buffer and show the next thread
149 from the search from which this thread was originally shown.
151 Note: This command is safe from any race condition of new messages
152 being delivered to the same thread. It does not archive the
153 entire thread, but only the messages shown in the current
157 (goto-char (point-min))
159 (notmuch-show-remove-tag "inbox")
162 (if (not (re-search-forward notmuch-show-message-begin-regexp nil t))
163 (goto-char (point-max)))))
164 (let ((parent-buffer notmuch-show-parent-buffer))
168 (switch-to-buffer parent-buffer)
169 (notmuch-search-show-thread)))))
171 (defun notmuch-show-move-to-current-message-summary-line ()
172 "Move to the beginning of the one-line summary of the current message.
174 This gives us a stable place to move to and work from since the
175 summary line is always visible. This is important since moving to
176 an invisible location is unreliable, (the main command loop moves
177 point either forward or backward to the next visible character
178 when a command ends with point on an invisible character).
180 Emits an error if point is not within a valid message, (that is
181 not pattern of `notmuch-show-message-begin-regexp' could be found
182 by searching backward)."
184 (if (not (looking-at notmuch-show-message-begin-regexp))
185 (if (re-search-backward notmuch-show-message-begin-regexp nil t)
187 (error "Not within a valid message."))
190 (defun notmuch-show-last-message-p ()
191 "Predicate testing whether point is within the last message."
192 (save-window-excursion
194 (notmuch-show-move-to-current-message-summary-line)
195 (not (re-search-forward notmuch-show-message-begin-regexp nil t)))))
197 (defun notmuch-show-message-unread-p ()
198 "Preficate testing whether current message is unread."
199 (member "unread" (notmuch-show-get-tags)))
201 (defun notmuch-show-next-message ()
202 "Advance to the beginning of the next message in the buffer.
204 Moves to the last visible character of the current message if
205 already on the last message in the buffer."
207 (notmuch-show-move-to-current-message-summary-line)
208 (if (re-search-forward notmuch-show-message-begin-regexp nil t)
209 (notmuch-show-move-to-current-message-summary-line)
210 (goto-char (- (point-max) 1))
211 (while (point-invisible-p)
215 (defun notmuch-show-find-next-message ()
216 "Returns the position of the next message in the buffer.
218 Or the position of the last visible character of the current
219 message if already within the last message in the buffer."
220 ; save-excursion doesn't save our window position
221 ; save-window-excursion doesn't save point
222 ; Looks like we have to use both.
224 (save-window-excursion
225 (notmuch-show-next-message)
228 (defun notmuch-show-next-unread-message ()
229 "Advance to the beginning of the next unread message in the buffer.
231 Moves to the last visible character of the current message if
232 there are no more unread messages past the current point."
233 (notmuch-show-next-message)
234 (while (and (not (notmuch-show-last-message-p))
235 (not (notmuch-show-message-unread-p)))
236 (notmuch-show-next-message))
237 (if (not (notmuch-show-message-unread-p))
238 (notmuch-show-next-message)))
240 (defun notmuch-show-previous-message ()
241 "Backup to the beginning of the previous message in the buffer.
243 If within a message rather than at the beginning of it, then
244 simply move to the beginning of the current message."
246 (let ((start (point)))
247 (notmuch-show-move-to-current-message-summary-line)
248 (if (not (< (point) start))
249 ; Go backward twice to skip the current message's marker
251 (re-search-backward notmuch-show-message-begin-regexp nil t)
252 (re-search-backward notmuch-show-message-begin-regexp nil t)
253 (notmuch-show-move-to-current-message-summary-line)
257 (defun notmuch-show-mark-read-then-next-unread-message ()
258 "Remove unread tag from current message, then advance to next unread message."
260 (notmuch-show-remove-tag "unread")
261 (notmuch-show-next-unread-message))
263 (defun notmuch-show-advance-marking-read-and-archiving ()
264 "Advance through buffer, marking read and archiving.
266 This command is intended to be one of the simplest ways to
267 process a thread of email. It does the following:
269 If the current message in the thread is not yet fully visible,
270 scroll by a near screenful to read more of the message.
272 Otherwise, (the end of the current message is already within the
273 current window), remove the \"unread\" tag (if present) from the
274 current message and advance to the next message.
276 Finally, if there is no further message to advance to, and this
277 last message is already read, then archive the entire current
278 thread, (remove the \"inbox\" tag from each message). Also kill
279 this buffer, and display the next thread from the search from
280 which this thread was originally shown."
282 (let ((next (notmuch-show-find-next-message))
283 (unread (notmuch-show-message-unread-p)))
284 (if (> next (window-end))
287 (notmuch-show-mark-read-then-next-unread-message)
288 (if (notmuch-show-last-message-p)
289 (notmuch-show-archive-thread)
290 (notmuch-show-next-unread-message))))))
292 (defun notmuch-show-markup-citations-region (beg end)
295 (while (< (point) end)
296 (let ((beg-sub (point)))
299 (while (looking-at ">")
301 (let ((overlay (make-overlay beg-sub (point))))
302 (overlay-put overlay 'invisible 'notmuch-show-citation)
303 (overlay-put overlay 'before-string
304 (concat "[" (number-to-string (count-lines beg-sub (point)))
305 " quoted lines.]")))))
306 (if (looking-at "--[ ]?$")
307 (let ((overlay (make-overlay beg-sub end)))
308 (overlay-put overlay 'invisible 'notmuch-show-signature)
309 (overlay-put overlay 'before-string
310 (concat "[" (number-to-string (count-lines beg-sub (point)))
311 "-line signature.]"))
315 (defun notmuch-show-markup-body ()
316 (re-search-forward notmuch-show-body-begin-regexp)
320 (re-search-forward notmuch-show-body-end-regexp)
321 (let ((end (match-beginning 0)))
322 (notmuch-show-markup-citations-region beg end)
323 (if (not (notmuch-show-message-unread-p))
324 (overlay-put (make-overlay beg end)
325 'invisible 'notmuch-show-body-read)))))
327 (defun notmuch-show-markup-header ()
328 (re-search-forward notmuch-show-header-begin-regexp)
332 (re-search-forward notmuch-show-header-end-regexp)
333 (overlay-put (make-overlay beg (match-beginning 0))
334 'invisible 'notmuch-show-header)))
336 (defun notmuch-show-markup-message ()
337 (if (re-search-forward notmuch-show-message-begin-regexp nil t)
339 (notmuch-show-markup-header)
340 (notmuch-show-markup-body))
341 (goto-char (point-max))))
343 (defun notmuch-show-hide-markers ()
345 (goto-char (point-min))
347 (if (re-search-forward notmuch-show-marker-regexp nil t)
349 (overlay-put (make-overlay (match-beginning 0) (+ (match-end 0) 1))
350 'invisible 'notmuch-show-marker))
351 (goto-char (point-max))))))
353 (defun notmuch-show-markup-messages ()
355 (goto-char (point-min))
357 (notmuch-show-markup-message)))
358 (notmuch-show-hide-markers))
360 (defun notmuch-show-toggle-citations-visible ()
361 "Toggle visibility of citations"
363 (if notmuch-show-citations-visible
364 (add-to-invisibility-spec 'notmuch-show-citation)
365 (remove-from-invisibility-spec 'notmuch-show-citation))
366 (set 'notmuch-show-citations-visible (not notmuch-show-citations-visible))
367 ; Need to force the redisplay for some reason
368 (force-window-update)
371 (defun notmuch-show-toggle-signatures-visible ()
372 "Toggle visibility of signatures"
374 (if notmuch-show-signatures-visible
375 (add-to-invisibility-spec 'notmuch-show-signature)
376 (remove-from-invisibility-spec 'notmuch-show-signature))
377 (set 'notmuch-show-signatures-visible (not notmuch-show-signatures-visible))
378 ; Need to force the redisplay for some reason
379 (force-window-update)
382 (defun notmuch-show-toggle-headers-visible ()
383 "Toggle visibility of header fields"
385 (if notmuch-show-headers-visible
386 (add-to-invisibility-spec 'notmuch-show-header)
387 (remove-from-invisibility-spec 'notmuch-show-header))
388 (set 'notmuch-show-headers-visible (not notmuch-show-headers-visible))
389 ; Need to force the redisplay for some reason
390 (force-window-update)
393 (defun notmuch-show-toggle-body-read-visible ()
394 "Toggle visibility of message bodies of read messages"
396 (if notmuch-show-body-read-visible
397 (add-to-invisibility-spec 'notmuch-show-body-read)
398 (remove-from-invisibility-spec 'notmuch-show-body-read))
399 (set 'notmuch-show-body-read-visible (not notmuch-show-body-read-visible))
400 ; Need to force the redisplay for some reason
401 (force-window-update)
405 (defun notmuch-show-mode ()
406 "Major mode for viewing a thread with notmuch.
408 This buffer contains the results of the \"notmuch show\" command
409 for displaying a single thread of email from your email archives.
411 By default, various components of email messages, (citations,
412 signatures, already-read messages), are invisible to help you
413 focus on the most important things, (new text from unread
414 messages). See the various commands below for toggling the
415 visibility of hidden components.
417 The `notmuch-show-next-message' and
418 `notmuch-show-previous-message' commands, (bound to 'n' and 'p by
419 default), allow you to navigate to the next and previous
420 messages. Each time you navigate away from a message with
421 `notmuch-show-next-message' the current message will have its
422 \"unread\" tag removed.
424 You can add or remove tags from the current message with '+' and
425 '-'. You can also archive all messages in the current
426 view, (remove the \"inbox\" tag from each), with
427 `notmuch-show-archive-thread' (bound to 'a' by default).
429 \\{notmuch-show-mode-map}"
431 (kill-all-local-variables)
432 (set (make-local-variable 'notmuch-show-headers-visible) t)
433 (notmuch-show-toggle-headers-visible)
434 (set (make-local-variable 'notmuch-show-body-read-visible) t)
435 (notmuch-show-toggle-body-read-visible)
436 (set (make-local-variable 'notmuch-show-citations-visible) t)
437 (notmuch-show-toggle-citations-visible)
438 (set (make-local-variable 'notmuch-show-signatures-visible) t)
439 (notmuch-show-toggle-signatures-visible)
440 (add-to-invisibility-spec 'notmuch-show-marker)
441 (use-local-map notmuch-show-mode-map)
442 (setq major-mode 'notmuch-show-mode
443 mode-name "notmuch-show")
444 (setq buffer-read-only t))
446 (defun notmuch-show (thread-id &optional parent-buffer)
447 "Run \"notmuch show\" with the given thread ID and display results.
449 The optional PARENT-BUFFER is the notmuch-search buffer from
450 which this notmuch-show command was executed, (so that the next
451 thread from that buffer can be show when done with this one)."
452 (interactive "sNotmuch show: ")
453 (let ((buffer (get-buffer-create (concat "*notmuch-show-" thread-id "*"))))
454 (switch-to-buffer buffer)
456 (set (make-local-variable 'notmuch-show-parent-buffer) parent-buffer)
457 (let ((proc (get-buffer-process (current-buffer)))
458 (inhibit-read-only t))
460 (error "notmuch search process already running for query `%s'" query)
463 (goto-char (point-min))
465 (call-process "notmuch" nil t nil "show" thread-id)
466 (notmuch-show-markup-messages)
468 ; Move straight to the first unread message
469 (if (not (notmuch-show-message-unread-p))
471 (notmuch-show-next-unread-message)
472 ; But if there are no unread messages, go back to the
473 ; beginning of the buffer.
474 (if (not (notmuch-show-message-unread-p))
475 (goto-char (point-min)))))
478 (defvar notmuch-search-mode-map
479 (let ((map (make-sparse-keymap)))
480 (define-key map "a" 'notmuch-search-archive-thread)
481 (define-key map "b" 'scroll-down)
482 (define-key map "f" 'notmuch-search-filter)
483 (define-key map "n" 'next-line)
484 (define-key map "p" 'previous-line)
485 (define-key map "q" 'kill-this-buffer)
486 (define-key map "s" 'notmuch-search)
487 (define-key map "t" 'notmuch-search-filter-by-tag)
488 (define-key map "x" 'kill-this-buffer)
489 (define-key map (kbd "RET") 'notmuch-search-show-thread)
490 (define-key map "+" 'notmuch-search-add-tag)
491 (define-key map "-" 'notmuch-search-remove-tag)
492 (define-key map "<" 'beginning-of-buffer)
493 (define-key map ">" 'notmuch-search-goto-last-thread)
494 (define-key map "=" 'notmuch-search-refresh-view)
495 (define-key map "\M->" 'notmuch-search-goto-last-thread)
496 (define-key map " " 'scroll-up)
497 (define-key map (kbd "<DEL>") 'scroll-down)
499 "Keymap for \"notmuch search\" buffers.")
500 (fset 'notmuch-search-mode-map notmuch-search-mode-map)
502 (defun notmuch-search-goto-last-thread (&optional arg)
503 "Move point to the last thread in the buffer."
509 (defun notmuch-search-mode ()
510 "Major mode for searching mail with notmuch.
512 This buffer contains the results of a \"notmuch search\" of your
513 email archives. Each line in the buffer represents a single
514 thread giving a relative date for the thread and a subject.
516 Pressing RET on any line displays that thread. The '+' and '-'
517 keys can be used to add or remove tags from a thread. The 'a' key
518 is a convenience key for archiving a thread (removing the
521 Other useful commands are `notmuch-search-filter' for filtering
522 the current search based on an additional query string,
523 `notmuch-search-filter-by-tag' for filtering to include only
524 messages with a given tag, and `notmuch-search' to execute a new,
527 \\{notmuch-search-mode-map}"
529 (kill-all-local-variables)
530 (make-local-variable 'notmuch-search-query-string)
531 (set (make-local-variable 'scroll-preserve-screen-position) t)
532 (add-to-invisibility-spec 'notmuch-search)
533 (use-local-map notmuch-search-mode-map)
534 (setq major-mode 'notmuch-search-mode
535 mode-name "notmuch-search")
536 (setq buffer-read-only t))
538 (defun notmuch-search-find-thread-id ()
542 (re-search-forward "[a-fA-F0-9]*")
543 (filter-buffer-substring beg (point)))))
545 (defun notmuch-search-markup-this-thread-id ()
548 (re-search-forward "[a-fA-F0-9]*")
550 (overlay-put (make-overlay beg (point)) 'invisible 'notmuch-search)))
552 (defun notmuch-search-markup-thread-ids ()
554 (goto-char (point-min))
556 (notmuch-search-markup-this-thread-id)
559 (defun notmuch-search-hide-thread-ids ()
561 (add-to-invisibility-spec 'notmuch-search)
562 (force-window-update)
565 (defun notmuch-search-show-thread-ids ()
567 (remove-from-invisibility-spec 'notmuch-search)
568 (force-window-update)
571 (defun notmuch-search-show-thread ()
573 (let ((thread-id (notmuch-search-find-thread-id)))
575 (if (> (length thread-id) 0)
576 (notmuch-show thread-id (current-buffer))
577 (error "End of search results"))))
579 (defun notmuch-call-notmuch-process (&rest args)
580 (let ((error-buffer (get-buffer-create "*Notmuch errors*")))
581 (with-current-buffer error-buffer
583 (if (eq (apply 'call-process "notmuch" nil error-buffer nil args) 0)
586 (with-current-buffer error-buffer
587 (let ((beg (point-min))
588 (end (- (point-max) 1)))
589 (error (buffer-substring beg end))
592 (defun notmuch-search-set-tags (tags)
595 (re-search-backward "(")
598 (inhibit-read-only t))
599 (re-search-forward ")")
602 (delete-region beg end)
603 (insert (mapconcat 'identity tags " "))))))
605 (defun notmuch-search-get-tags ()
608 (re-search-backward "(")
609 (let ((beg (+ (point) 1)))
610 (re-search-forward ")")
611 (let ((end (- (point) 1)))
612 (split-string (buffer-substring beg end))))))
614 (defun notmuch-search-add-tag (tag)
615 (interactive "sTag to add: ")
616 (notmuch-call-notmuch-process "tag" (concat "+" tag) (concat "thread:" (notmuch-search-find-thread-id)))
617 (notmuch-search-set-tags (delete-dups (sort (cons tag (notmuch-search-get-tags)) 'string<))))
619 (defun notmuch-search-remove-tag (tag)
620 (interactive "sTag to remove: ")
621 (notmuch-call-notmuch-process "tag" (concat "-" tag) (concat "thread:" (notmuch-search-find-thread-id)))
622 (notmuch-search-set-tags (delete tag (notmuch-search-get-tags))))
624 (defun notmuch-search-archive-thread ()
625 "Archive the current thread (remove its \"inbox\" tag).
627 This function advances point to the next line when finished."
629 (notmuch-search-remove-tag "inbox")
632 (defun notmuch-search (query)
633 "Run \"notmuch search\" with the given query string and display results."
634 (interactive "sNotmuch search: ")
635 (let ((buffer (get-buffer-create (concat "*notmuch-search-" query "*"))))
636 (switch-to-buffer buffer)
637 (notmuch-search-mode)
638 (set 'notmuch-search-query-string query)
639 (let ((proc (get-buffer-process (current-buffer)))
640 (inhibit-read-only t))
642 (error "notmuch search process already running for query `%s'" query)
645 (goto-char (point-min))
647 (call-process "notmuch" nil t nil "search" query)
648 (notmuch-search-markup-thread-ids)
651 (defun notmuch-search-refresh-view ()
652 "Refresh the current view.
654 Kills the current buffer and runs a new search with the same
655 query string as the current search. If the current thread is in
656 the new search results, then point will be placed on the same
657 thread. Otherwise, point will be moved to attempt to be in the
658 same relative position within the new buffer."
661 (thread (notmuch-search-find-thread-id))
662 (query notmuch-search-query-string))
664 (notmuch-search query)
665 (goto-char (point-min))
666 (if (re-search-forward (concat "^" thread) nil t)
670 (defun notmuch-search-filter (query)
671 "Filter the current search results based on an additional query string.
673 Runs a new search matching only messages that match both the
674 current search results AND the additional query string provided."
675 (interactive "sFilter search: ")
676 (notmuch-search (concat notmuch-search-query-string " and " query)))
678 (defun notmuch-search-filter-by-tag (tag)
679 "Filter the current search results based on a single tag.
681 Runs a new search matching only messages that match both the
682 current search results AND that are tagged with the given tag."
683 (interactive "sFilter by tag: ")
684 (notmuch-search (concat notmuch-search-query-string " and tag:" tag)))
687 "Run notmuch to display all mail with tag of 'inbox'"
689 (notmuch-search "tag:inbox"))