From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:267::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms12 with LMTPS id WLYWOgkSxmGCLwAAsNZ9tg (envelope-from ) for ; Fri, 24 Dec 2021 18:31:37 +0000 Received: from out0.migadu.com ([2001:41d0:2:267::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id cPooNQkSxmFpagAA1q6Kng (envelope-from ) for ; Fri, 24 Dec 2021 18:31:37 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kyleam.com; s=key1; t=1640370697; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to; bh=MDQibcMgL7LEKO6badLzkrKazT/acxoi2MVGsYif+64=; b=L6N5Pl00EvOHhmE5cdJc02w1Un7iIPcRijDrOLnOJfHTfJSHFbWY44F4uOQSXGZtV6zO+Y QChE0yohU+1qSdAQz7j9NJs2uptFoo87780CBLMIcFQSBYX+LatKEpwlOl7MvFAxzeCPUa iLuWHEzKBQMXKKse3vN0pNscnMJmeVXRBaulsMhgBZeOZXn2OEFuVEhO7N0sUN1Ecc9i9L 9wQ2vIz2qK8rgwHrXQ+uMkMV3TQTzZXHoAe9FU53f/6r6VEPpe/eu41bLxqAVMNAVWcbLJ WIoru+FgdgHIZylWq94rggjrY8hdpaMzNGifvDr1cxTjOsic5yG1nKp3wxxSeQ== From: Kyle Meyer To: Leo Cc: piem@inbox.kyleam.com Subject: Re: [PATCH v4] Add user option for specifying path to notmuch-extract-patch In-Reply-To: <20211221191527.11819-1-sourcehut@relevant-information.com> Date: Fri, 24 Dec 2021 13:31:30 -0500 Message-ID: <87fsqhg8hp.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Migadu-Auth-User: kyleam.com X-TUID: uUOgLgObx0A8 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.