aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2022-05-15 23:22:41 -0400
committerKyle Meyer <kyle@kyleam.com>2022-05-16 18:03:34 -0400
commit83cb95df351111abe8e8cd0d9c264158082e6081 (patch)
tree0d95af200781f7f237f9b91a44492bd09f109d09
parentcbddebaa8e535e94d95510f02ebe8152c5d1a0b8 (diff)
downloadpiem-83cb95df351111abe8e8cd0d9c264158082e6081.tar.gz
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 <zimon.toutoune@gmail.com> Link: https://yhetil.org/guix-devel/86sfpo5q8w.fsf@gmail.com Message-Id: <20220516032241.212199-1-kyle@kyleam.com>
-rw-r--r--piem.el19
1 files 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