From 8d69ec9c7ac4b4ee8a9a2df244ac6130a66979a9 Mon Sep 17 00:00:00 2001 From: jao Date: Sun, 4 Jul 2021 03:21:13 +0100 Subject: recovering explicit org-notmuch integration --- lib/net/jao-notmuch.el | 2 +- notmuch.org | 42 +++++++++++++++++++++++++++++++++++++----- 2 files changed, 38 insertions(+), 6 deletions(-) diff --git a/lib/net/jao-notmuch.el b/lib/net/jao-notmuch.el index f0659f6..bb57f57 100644 --- a/lib/net/jao-notmuch.el +++ b/lib/net/jao-notmuch.el @@ -156,7 +156,7 @@ (setq total (1+ total)) (when (or (member "unread" tags) (member "new" tags)) (setq cnt (1+ cnt))))) - (when cnt (format "%s out of %s messages left" cnt total))))) + (when cnt (format "%s / %s messages" cnt total))))) (defun jao-notmuch--tree-update-buffer-name (&optional n) (when-let ((n (or n (jao-notmuch--unread-count)))) diff --git a/notmuch.org b/notmuch.org index 651374f..768bec7 100644 --- a/notmuch.org +++ b/notmuch.org @@ -298,8 +298,40 @@ (with-eval-after-load "notmuch-hello" (define-key notmuch-hello-mode-map "f" #'jao-consult-notmuch-folder)) #+end_src -* org mode integration - #+begin_src emacs-lisp - (jao-load-path "ol-notmuch") - (use-package ol-notmuch :demand t) - #+end_src +* org mode + Stolen and adapted from [[https://gist.github.com/fedxa/fac592424473f1b70ea489cc64e08911][Fedor Bezrukov]]. + #+begin_src emacs-lisp + (with-eval-after-load "org" + (with-eval-after-load "notmuch" + (org-link-set-parameters "notmuch" + :follow 'org-notmuch-open + :store 'org-notmuch-store-link) + + (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." + (case major-mode + ((notmuch-show-mode notmuch-tree-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))))))) + #+end_src -- cgit v1.2.3