discussion and development of piem
 help / color / mirror / code / Atom feed
From: Xinglu Chen <public@yoctocell.xyz>
To: piem@inbox.kyleam.com
Subject: [PATCH v2] notmuch: Configure mailing list archive links
Date: Sat, 06 Feb 2021 09:44:17 +0100	[thread overview]
Message-ID: <8e8677cde716973081232aa65a37fa2fc621b15f.1612600790.git.public@yoctocell.xyz> (raw)
In-Reply-To: <2ffe23775ec008feb763e24c29786fc5feddb975.1612544763.git.public@yoctocell.xyz>

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`.
Changes from v1:

- Use `piem-notmuch-get-inbox` instead of writing my own thing.

- Give a user error if there is not url for the inbox.

- Do not set `notmuch-show-stash-mlarchive-link-default`, instead add
  info in `piem-notmuch-mode` docstring that suggests the user to set
  the variable on their own.

 piem-notmuch.el | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/piem-notmuch.el b/piem-notmuch.el
index 5c0cd62..2d6c5a3 100644
--- a/piem-notmuch.el
+++ b/piem-notmuch.el
@@ -106,12 +106,29 @@ (defun piem-notmuch-am-ready-mbox ()
                     (insert patch)))
+(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-notmuch-get-inbox))
+         (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))))
 (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 till determine
+the archive url by reading the `piem-inboxes’ variable.  You can
+also set `notmuch-show-shas-mlarchive-link-default' to \"piem\"
+to make this the default behavior when calling
   :global t
   :init-value nil
   (if piem-notmuch-mode
@@ -119,11 +136,16 @@ (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)))
     (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)

  parent reply	other threads:[~2021-02-06  8:44 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Xinglu Chen [this message]
2021-02-06 15:58   ` [PATCH v2] " Kyle Meyer
2021-02-06 16:17     ` Xinglu Chen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information: https://git.kyleam.com/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8e8677cde716973081232aa65a37fa2fc621b15f.1612600790.git.public@yoctocell.xyz \
    --to=public@yoctocell.xyz \
    --cc=piem@inbox.kyleam.com \


* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox


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).