diff options
author | jao <jao@gnu.org> | 2022-03-03 22:15:37 +0000 |
---|---|---|
committer | jao <jao@gnu.org> | 2022-03-03 22:17:26 +0000 |
commit | 19fb23c3deda00df0346d7e17ff499a98ec72cbd (patch) | |
tree | 29c137df072007290f271b0344ec6fb5c1df4540 | |
parent | a2a9bb379e97085249287b29560f789c7ccc63a5 (diff) | |
download | elibs-19fb23c3deda00df0346d7e17ff499a98ec72cbd.tar.gz elibs-19fb23c3deda00df0346d7e17ff499a98ec72cbd.tar.bz2 |
mail: org links to follow gnus mails using notmuch as its registry
-rw-r--r-- | lib/net/jao-notmuch-gnus.el | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/net/jao-notmuch-gnus.el b/lib/net/jao-notmuch-gnus.el index 1951ae0..a84f94b 100644 --- a/lib/net/jao-notmuch-gnus.el +++ b/lib/net/jao-notmuch-gnus.el @@ -131,6 +131,35 @@ Example: (org-gnus-follow-link group message-id) (message "Couldn't get relevant infos for switching to Gnus.")))) + +;;;; Org links +(defun jao-notmuch-gnus--fname (id) + (let ((cmd (format "notmuch search --output=files id:%s" id))) + (car (split-string (shell-command-to-string cmd))))) + +(defun jao-notmuch-gnus-org-follow (id) + (when-let* ((fname (jao-notmuch-gnus--fname id)) + (group (jao-notmuch-gnus-file-to-group fname))) + (org-gnus-follow-link group id))) + +(defun jao-notmuch-gnus-org-store () + (when-let (d (or (when (derived-mode-p 'notmuch-show-mode 'notmuch-tree-mode) + (cons (notmuch-show-get-message-id) + (notmuch-show-get-subject))) + (when (derived-mode-p 'gnus-summary-mode 'gnus-article-mode) + (cons (jao-notmuch-gnus-message-id) + (gnus-summary-article-subject))))) + (org-link-store-props :type "mail" + :link (concat "mail:" (car d)) + :description (concat "Mail: " (cdr d))))) + +(org-link-set-parameters "mail" + :follow #'jao-notmuch-gnus-org-follow + :store #'jao-notmuch-gnus-org-store) + + +;;;; consult-notmuch + (with-eval-after-load "consult-notmuch" (defun jao-notmuch-gnus--open-candidate (candidate) "Open a notmuch-search completion candidate email in Gnus." |