discussion and development of piem
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: piem@inbox.kyleam.com
Cc: zimoun <zimon.toutoune@gmail.com>
Subject: [PATCH] piem-inject-thread-into-maildir: Let Lisp callers specify inbox
Date: Sun, 15 May 2022 23:22:41 -0400	[thread overview]
Message-ID: <20220516032241.212199-1-kyle@kyleam.com> (raw)

piem-inject-thread-into-maildir expects to be able to determine the
inbox by calling piem-inbox.  That's fine for interactive use, but
wrapper functions may want to determine the inbox in another way.

Suggested-by: zimoun <zimon.toutoune@gmail.com>
Link: https://yhetil.org/guix-devel/86sfpo5q8w.fsf@gmail.com
---
 piem.el | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/piem.el b/piem.el
index f91e3e64..e72f41b6 100644
--- a/piem.el
+++ b/piem.el
@@ -772,26 +772,31 @@ (defun piem--write-mbox-to-maildir (maildir-directory)
     (cons n-added n-skipped)))
 
 ;;;###autoload
-(defun piem-inject-thread-into-maildir (mid &optional message-only)
+(defun piem-inject-thread-into-maildir (mid &optional inbox message-only)
   "Inject thread containing MID into `piem-inbox-maildir-directory'.
 
-If prefix argument MESSAGE-ONLY is non-nil, inject just the
-message for MID, not the entire thread.
+Download the message from the :url value configured for INBOX in
+`piem-inboxes'.  INBOX is passed to
+`piem-inbox-maildir-directory' to determine where to inject the
+message.  If INBOX is nil, the inbox returned by `piem-inbox' is
+used.
 
-This function depends on :url being configured for entries in
-`piem-inboxes'."
+If prefix argument MESSAGE-ONLY is non-nil, inject just the
+message for MID, not the entire thread."
   (interactive
    (list (or (piem-mid)
              (user-error "No message ID found for the current buffer"))
+         nil
          current-prefix-arg))
-  (let ((maildir-directory (piem-inbox-maildir-directory)))
+  (let* ((inbox (or inbox (piem-inbox)))
+         (maildir-directory (piem-inbox-maildir-directory inbox)))
     (cond
      ((not maildir-directory)
       (user-error "No directory returned by `piem-inbox-maildir-directory'"))
      ((not (piem-maildir-dir-is-maildir-p maildir-directory))
       (user-error
        "Does not look like a Maildir directory: %s" maildir-directory)))
-    (let ((url (concat (piem-mid-url mid)
+    (let ((url (concat (piem-mid-url mid inbox)
                        (if message-only "/raw" "/t.mbox.gz"))))
       (piem-with-url-contents url
         (unless message-only

base-commit: cbddebaa8e535e94d95510f02ebe8152c5d1a0b8
-- 
2.36.0


             reply	other threads:[~2022-05-16  3:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-16  3:22 Kyle Meyer [this message]
2022-05-16  7:11 ` [PATCH] piem-inject-thread-into-maildir: Let Lisp callers specify inbox zimoun
2022-05-16 22:04   ` Kyle Meyer

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  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=20220516032241.212199-1-kyle@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=piem@inbox.kyleam.com \
    --cc=zimon.toutoune@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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

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