discussion and development of piem
 help / color / mirror / code / Atom feed
* [PATCH] piem-inject-thread-into-maildir: Let Lisp callers specify inbox
@ 2022-05-16  3:22 Kyle Meyer
  2022-05-16  7:11 ` zimoun
  0 siblings, 1 reply; 3+ messages in thread
From: Kyle Meyer @ 2022-05-16  3:22 UTC (permalink / raw)
  To: piem; +Cc: zimoun

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


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

* Re: [PATCH] piem-inject-thread-into-maildir: Let Lisp callers specify inbox
  2022-05-16  3:22 [PATCH] piem-inject-thread-into-maildir: Let Lisp callers specify inbox Kyle Meyer
@ 2022-05-16  7:11 ` zimoun
  2022-05-16 22:04   ` Kyle Meyer
  0 siblings, 1 reply; 3+ messages in thread
From: zimoun @ 2022-05-16  7:11 UTC (permalink / raw)
  To: Kyle Meyer; +Cc: piem

Hi Kyle,

On Mon, 16 May 2022 at 05:22, Kyle Meyer <kyle@kyleam.com> wrote:

> 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)
[...]
> base-commit: cbddebaa8e535e94d95510f02ebe8152c5d1a0b8

Cool!  It simplifies my config.  Thanks.

Cheers,
simon

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

* Re: [PATCH] piem-inject-thread-into-maildir: Let Lisp callers specify inbox
  2022-05-16  7:11 ` zimoun
@ 2022-05-16 22:04   ` Kyle Meyer
  0 siblings, 0 replies; 3+ messages in thread
From: Kyle Meyer @ 2022-05-16 22:04 UTC (permalink / raw)
  To: zimoun; +Cc: piem

zimoun writes:

> Hi Kyle,
>
> On Mon, 16 May 2022 at 05:22, Kyle Meyer <kyle@kyleam.com> wrote:
>
>> 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)
> [...]
>> base-commit: cbddebaa8e535e94d95510f02ebe8152c5d1a0b8
>
> Cool!  It simplifies my config.  Thanks.

Applied (83cb95d).  Thanks for the suggestion.

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

end of thread, other threads:[~2022-05-16 22:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-16  3:22 [PATCH] piem-inject-thread-into-maildir: Let Lisp callers specify inbox Kyle Meyer
2022-05-16  7:11 ` zimoun
2022-05-16 22:04   ` Kyle Meyer

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