diff options
author | Xinglu Chen <public@yoctocell.xyz> | 2021-02-06 09:44:17 +0100 |
---|---|---|
committer | Kyle Meyer <kyle@kyleam.com> | 2021-02-06 10:47:51 -0500 |
commit | fad8d59d5a7437411e96dc9e8addfb3e02e459d7 (patch) | |
tree | 9d15022e2b737bf9460d3734dfda20c4e4ca139e | |
parent | c468c6b6023436116f1d2377350a05cbbc4cc650 (diff) | |
download | piem-fad8d59d5a7437411e96dc9e8addfb3e02e459d7.tar.gz |
notmuch: Configure mailing list archive links
This adds an entry to `notmuch-show-stash-mlarchive-link-alist` that
reads the `piem-inboxes` variable and returns the public-inbox archive
url. This means that users don't have to manually add public-inbox
archive urls to `notmuch-show-stash-mlarchive-link-alist`.
[km: added explicit error when inbox not found and fixed a few typos]
Message-Id: <8e8677cde716973081232aa65a37fa2fc621b15f.1612600790.git.public@yoctocell.xyz>
-rw-r--r-- | piem-notmuch.el | 30 |
1 files changed, 27 insertions, 3 deletions
diff --git a/piem-notmuch.el b/piem-notmuch.el index 5c0cd62..27edfae 100644 --- a/piem-notmuch.el +++ b/piem-notmuch.el @@ -106,12 +106,31 @@ message itself if it looks like a patch." (insert patch))) "mbox")))))) +(defun piem-notmuch-show-get-public-inbox-link (mid) + "Given the message-id MID, return the public-inbox url. +This will lookup the url in the `piem-inboxes' variable." + (let* ((inbox (or (piem-notmuch-get-inbox) + (user-error "No inbox associated with current buffer"))) + (link (or (piem-inbox-get :url inbox) + (user-error "No url was found for %s" inbox)))) + (concat + (piem--ensure-trailing-slash link) + (piem-escape-mid mid)))) + ;;;###autoload (define-minor-mode piem-notmuch-mode "Toggle Notmuch support for piem. + With a prefix argument ARG, enable piem-notmuch mode if ARG is positive, and disable it otherwise. If called from Lisp, enable -the mode if ARG is omitted or nil." +the mode if ARG is omitted or nil. + +This will add a new entry to +`notmuch-show-stash-mlarchive-link-alist' which will determine +the archive url by reading the `piem-inboxes' variable. You can +also set `notmuch-show-stash-mlarchive-link-default' to \"piem\" +to make this the default behavior when calling +`notmuch-show-stash-mlarchive-link'." :global t :init-value nil (if piem-notmuch-mode @@ -119,11 +138,16 @@ the mode if ARG is omitted or nil." (add-hook 'piem-am-ready-mbox-functions #'piem-notmuch-am-ready-mbox) (add-hook 'piem-get-inbox-functions #'piem-notmuch-get-inbox) (add-hook 'piem-get-mid-functions #'piem-notmuch-get-mid) - (add-hook 'piem-mid-to-thread-functions #'piem-notmuch-mid-to-thread)) + (add-hook 'piem-mid-to-thread-functions #'piem-notmuch-mid-to-thread) + (add-to-list 'notmuch-show-stash-mlarchive-link-alist + '("piem" . piem-notmuch-show-get-public-inbox-link))) (remove-hook 'piem-am-ready-mbox-functions #'piem-notmuch-am-ready-mbox) (remove-hook 'piem-get-inbox-functions #'piem-notmuch-get-inbox) (remove-hook 'piem-get-mid-functions #'piem-notmuch-get-mid) - (remove-hook 'piem-mid-to-thread-functions #'piem-notmuch-mid-to-thread))) + (remove-hook 'piem-mid-to-thread-functions #'piem-notmuch-mid-to-thread) + (setq notmuch-show-stash-mlarchive-link-alist + (delete '("piem" . piem-notmuch-show-get-public-inbox-link) + notmuch-show-stash-mlarchive-link-alist)))) ;;; piem-notmuch.el ends here (provide 'piem-notmuch) |