fix(emacs): update notmuch integration

- Pin notmuch to the version that comes with Ubuntu and is installed with apt
- Add org-move capture integration
- Add unread message filter
This commit is contained in:
Ade Attwood 2021-11-21 12:36:45 +00:00
parent e8bbbae10a
commit 653c7af2ae
2 changed files with 45 additions and 4 deletions

View file

@ -101,6 +101,7 @@
;; Email ;; Email
"e" '(:ignore t :which-key "Email") "e" '(:ignore t :which-key "Email")
"ei" 'aa/notmuch-search-inbox "ei" 'aa/notmuch-search-inbox
"eu" 'aa/notmuch-search-inbox-unread
"es" 'counsel-notmuch "es" 'counsel-notmuch
"en" 'notmuch "en" 'notmuch
"ej" 'notmuch-jump-search "ej" 'notmuch-jump-search

View file

@ -6,6 +6,8 @@
;; licence that can be found in the LICENCE file or at ;; licence that can be found in the LICENCE file or at
;; https://www.practically.io/copyright/ ;; https://www.practically.io/copyright/
(require 'cl)
(defvar notmuch-message-deleted-tags '("+deleted" "-inbox" "-unread")) (defvar notmuch-message-deleted-tags '("+deleted" "-inbox" "-unread"))
(defun spacemacs/notmuch-search-archive-thread-down () (defun spacemacs/notmuch-search-archive-thread-down ()
@ -42,14 +44,26 @@
(interactive) (interactive)
(notmuch-search "tag:inbox")) (notmuch-search "tag:inbox"))
(use-package notmuch (defun aa/notmuch-search-inbox-unread ()
:defer t "Search the notmuch unread messages in the inbox."
:commands notmuch (interactive)
:config (notmuch-search "tag:inbox and tag:unread"))
(quelpa
'(notmuch :fetcher git
:url "https://git.notmuchmail.org/git/notmuch"
:commit "a59ef7d02cb229c2ec3569024918024003568aea"
:files ("emacs/*.el" "emacs/*.png"))
(setq notmuch-saved-searches '((:name "inbox" (setq notmuch-saved-searches '((:name "inbox"
:key "i" :key "i"
:query "tag:inbox" :query "tag:inbox"
:sort-order newest-first) :sort-order newest-first)
(:name "inbox-unread"
:key "iu"
:query "tag:inbox and tag:unread"
:sort-order newest-first)
(:name "unread" (:name "unread"
:key "u" :key "u"
:query "tag:unread" :query "tag:unread"
@ -80,3 +94,29 @@
"d" 'spacemacs/notmuch-message-delete-down)) "d" 'spacemacs/notmuch-message-delete-down))
(use-package counsel-notmuch :defer t) (use-package counsel-notmuch :defer t)
(defun org-notmuch-open (id)
"Visit the notmuch message or thread with id ID."
(notmuch-show id))
(defun org-notmuch-store-link ()
"Store a link to a notmuch mail message."
(cl-case major-mode
('notmuch-show-mode
;; Store link to the current message
(let* ((id (notmuch-show-get-message-id))
(link (concat "notmuch:" id))
(description (format "Mail: %s" (notmuch-show-get-subject))))
(org-store-link-props
:type "notmuch"
:link link
:description description)))
('notmuch-search-mode
;; Store link to the thread on the current line
(let* ((id (notmuch-search-find-thread-id))
(link (concat "notmuch:" id))
(description (format "Mail: %s" (notmuch-search-find-subject))))
(org-store-link-props
:type "notmuch"
:link link
:description description)))))