discussion and development of piem
 help / color / mirror / code / Atom feed
From: Kyle Meyer <kyle@kyleam.com>
To: Leo <sourcehut@relevant-information.com>
Cc: piem@inbox.kyleam.com
Subject: Re: [PATCH v4] Add user option for specifying path to notmuch-extract-patch
Date: Fri, 24 Dec 2021 13:31:30 -0500	[thread overview]
Message-ID: <87fsqhg8hp.fsf@kyleam.com> (raw)
In-Reply-To: <20211221191527.11819-1-sourcehut@relevant-information.com>

Thanks for the update.

Leo writes:

> +(defcustom piem-notmuch-extract-patch-executable "notmuch-extract-patch"
> +  "Which notmuch-extract-patch executable to use."
> +  :type 'string)

Looks good.  I'll add a package-version keyword on apply.

> @@ -120,8 +124,7 @@ (defun piem-notmuch-extract-patch-am-ready-mbox ()
>                    (mm-dissect-buffer))) 0))
>      (let ((thread-id notmuch-show-thread-id))
>        (lambda ()
> -        (if-let ((cmd (executable-find "notmuch-extract-patch"))
> -                 (tid
> +        (if-let ((tid
>                    ;; Copied from mailscripts.el
>                    ;;
>                    ;; If `notmuch-show' was called with a notmuch query rather
> @@ -134,7 +137,7 @@ (defun piem-notmuch-extract-patch-am-ready-mbox ()
>                    (if (string= (substring thread-id 0 7) "thread:")
>                        thread-id
>                      (concat "thread:{" thread-id "}"))))
> -            (call-process cmd nil t nil
> +            (call-process piem-notmuch-extract-patch-executable nil t nil
>                            tid)
>            (user-error "The executable notmuch-extract-patch was not found"))))))

This user-error is no longer accurate because it would only be signaled
if notmuch-show-thread-id is unexpectedly nil.  I've amended your patch
to drop this if-let binding, moving the tid binding outside the lambda.

Pushed (955abe41) with the changes below on top.

diff --git a/piem-notmuch.el b/piem-notmuch.el
index 34231a50..71d56f7e 100644
--- a/piem-notmuch.el
+++ b/piem-notmuch.el
@@ -40,6 +40,7 @@ (defgroup piem-notmuch nil
 
 (defcustom piem-notmuch-extract-patch-executable "notmuch-extract-patch"
   "Which notmuch-extract-patch executable to use."
+  :package-version '(piem . "0.4.0")
   :type 'string)
 
 (defmacro piem-notmuch--with-current-message (&rest body)
@@ -122,24 +123,25 @@ (defun piem-notmuch-extract-patch-am-ready-mbox ()
              (= (notmuch-count-attachments
                  (piem-notmuch--with-current-message
                   (mm-dissect-buffer))) 0))
-    (let ((thread-id notmuch-show-thread-id))
+    (let* ((thread-id
+            (or notmuch-show-thread-id
+                (error "bug: notmuch-show-thread-id unexpectedly nil")))
+           (tid
+            ;; Copied from mailscripts.el
+            ;;
+            ;; If `notmuch-show' was called with a notmuch query rather
+            ;; than a thread ID, as `org-notmuch-follow-link' in
+            ;; org-notmuch.el does, then `notmuch-show-thread-id' might
+            ;; be an arbitrary notmuch query instead of a thread ID.  We
+            ;; need to wrap such a query in thread:{} before passing it
+            ;; to notmuch-extract-patch(1), or we might not get a whole
+            ;; thread extracted (e.g. if the query is just id:foo)
+            (if (string= (substring thread-id 0 7) "thread:")
+                thread-id
+              (concat "thread:{" thread-id "}"))))
       (lambda ()
-        (if-let ((tid
-                  ;; Copied from mailscripts.el
-                  ;;
-                  ;; If `notmuch-show' was called with a notmuch query rather
-                  ;; than a thread ID, as `org-notmuch-follow-link' in
-                  ;; org-notmuch.el does, then `notmuch-show-thread-id' might
-                  ;; be an arbitrary notmuch query instead of a thread ID.  We
-                  ;; need to wrap such a query in thread:{} before passing it
-                  ;; to notmuch-extract-patch(1), or we might not get a whole
-                  ;; thread extracted (e.g. if the query is just id:foo)
-                  (if (string= (substring thread-id 0 7) "thread:")
-                      thread-id
-                    (concat "thread:{" thread-id "}"))))
-            (call-process piem-notmuch-extract-patch-executable nil t nil
-                          tid)
-          (user-error "The executable notmuch-extract-patch was not found"))))))
+        (call-process piem-notmuch-extract-patch-executable nil t nil
+                      tid)))))
 
 (defun piem-notmuch-show-get-public-inbox-link (mid)
   "Given the message-id MID, return the public-inbox url.

  reply	other threads:[~2021-12-24 18:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-14 15:09 [PATCH v2] Use notmuch-extract-patch if available leo
2021-12-15  5:16 ` Kyle Meyer
2021-12-15  5:22   ` Kyle Meyer
2021-12-16 19:32   ` [PATCH v3 1/2] Support preparing am-ready mbox via notmuch-extract-patch sourcehut
2021-12-16 19:32     ` [PATCH v3 2/2] Add user option for specifying path to notmuch-extract-patch sourcehut
2021-12-17  5:22       ` Kyle Meyer
2021-12-21 19:15         ` [PATCH v4] " Leo
2021-12-24 18:31           ` Kyle Meyer [this message]
2021-12-17  5:15     ` [PATCH v3 1/2] Support preparing am-ready mbox via notmuch-extract-patch 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=87fsqhg8hp.fsf@kyleam.com \
    --to=kyle@kyleam.com \
    --cc=piem@inbox.kyleam.com \
    --cc=sourcehut@relevant-information.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).