diff --git a/modules/email/notmuch/autoload.el b/modules/email/notmuch/autoload.el index 5a4917c6f..174df2dc4 100644 --- a/modules/email/notmuch/autoload.el +++ b/modules/email/notmuch/autoload.el @@ -92,6 +92,25 @@ (start-process-shell-command "email" nil (format "xdg-open '%s'" temp)))) +;;;###autoload +(defun +notmuch/show-filter-thread () + "Show the current thread with a different filter" + (interactive) + (setq notmuch-show-query-context (notmuch-read-query "Filter thread: ")) + (notmuch-show-refresh-view t)) + +;;;###autoload +(defun +notmuch-expand-only-unread-h () + (interactive) + (let ((unread nil) + (open (notmuch-show-get-message-ids-for-open-messages))) + (notmuch-show-mapc (lambda () + (when (member "unread" (notmuch-show-get-tags)) + (setq unread t)))) + (when unread + (let ((notmuch-show-hook (remove '+notmuch/expand-only-unread-hook notmuch-show-hook))) + (notmuch-show-filter-thread "tag:unread"))))) + ;; ;; Advice diff --git a/modules/email/notmuch/config.el b/modules/email/notmuch/config.el index 67656bea8..95a7e2400 100644 --- a/modules/email/notmuch/config.el +++ b/modules/email/notmuch/config.el @@ -42,6 +42,9 @@ ;; (setq-hook! 'notmuch-show-mode-hook line-spacing 0) + ;; only unfold unread messages in thread by default + (add-hook 'notmuch-show-hook '+notmuch-expand-only-unread-h) + (add-hook 'doom-real-buffer-functions #'notmuch-interesting-buffer) (advice-add #'notmuch-start-notmuch-sentinel :around #'+notmuch-dont-confirm-on-kill-process-a)