discussion and development of piem
 help / color / mirror / code / Atom feed
* [PATCH] notmuch: Configure mailing list archive links
@ 2021-02-05 17:10 Xinglu Chen
  2021-02-06  4:54 ` Kyle Meyer
  2021-02-06  8:44 ` [PATCH v2] " Xinglu Chen
  0 siblings, 2 replies; 6+ messages in thread
From: Xinglu Chen @ 2021-02-05 17:10 UTC (permalink / raw)
  To: piem

This adds an entry to `notmuch-show-stash-ml-archive-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-ml-archive-link-alist`.
---
You can run `notmuch-show-stash-mlarchive-link` on this message, and
paste the link in the browser to see it in action (assuming you have
configured `piem-inboxes`).

 piem-notmuch.el | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)

diff --git a/piem-notmuch.el b/piem-notmuch.el
index 5c0cd62..52d9198 100644
--- a/piem-notmuch.el
+++ b/piem-notmuch.el
@@ -106,6 +106,13 @@ (defun piem-notmuch-am-ready-mbox ()
                     (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 (piem-inbox-by-header-match))
+        (link (piem-inbox-get :url inbox)))
+    (concat link mid)))
+
 ;;;###autoload
 (define-minor-mode piem-notmuch-mode
   "Toggle Notmuch support for piem.
@@ -119,11 +126,18 @@ (define-minor-mode piem-notmuch-mode
         (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))
+        (setq notmuch-show-stash-mlarchive-link-default "piem"))
     (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))
+    (setq notmuch-show-stash-mlarchive-link-default "Gmane")))
 
 ;;; piem-notmuch.el ends here
 (provide 'piem-notmuch)
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-02-06 16:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-05 17:10 [PATCH] notmuch: Configure mailing list archive links Xinglu Chen
2021-02-06  4:54 ` Kyle Meyer
2021-02-06  8:07   ` Xinglu Chen
2021-02-06  8:44 ` [PATCH v2] " Xinglu Chen
2021-02-06 15:58   ` Kyle Meyer
2021-02-06 16:17     ` Xinglu Chen

Code repositories for project(s) associated with this public inbox

	https://git.kyleam.com/piem/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).