My “show all” functionality
Show both read and unread messages with TAB
.
(with-eval-after-load 'notmuch
(defun my-notmuch-search-show-read ()
"Suppress `unread' tag filtering in `notmuch-search'."
(interactive)
(when (boundp 'my-notmuch-search-showing-unread)
(user-error "Already showing read messages"))
(let ((buffer-name (concat (buffer-name) "/ALL")))
(if-let* ((buffer (get-buffer buffer-name)))
(switch-to-buffer buffer)
(progn
(notmuch-search-edit-search
(string-replace (format "%s" '(tag unread))
(format "%s" '(or (tag read) (not (tag read))))
(notmuch-search-get-query)))
(rename-buffer buffer-name)
(setq-local my-notmuch-search-showing-unread t))))))
(with-eval-after-load 'notmuch
(keymap-set notmuch-search-mode-map
"TAB"
#'my-notmuch-search-show-read))