From 83cb95df351111abe8e8cd0d9c264158082e6081 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sun, 15 May 2022 23:22:41 -0400 Subject: piem-inject-thread-into-maildir: Let Lisp callers specify inbox 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 Link: https://yhetil.org/guix-devel/86sfpo5q8w.fsf@gmail.com Message-Id: <20220516032241.212199-1-kyle@kyleam.com> --- piem.el | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/piem.el b/piem.el index f91e3e6..e72f41b 100644 --- a/piem.el +++ b/piem.el @@ -772,26 +772,31 @@ is used as the value of `browse-url-browser-function'." (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 -- cgit v1.2.3