summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeo <sourcehut@relevant-information.com>2021-12-21 20:15:27 +0100
committerKyle Meyer <kyle@kyleam.com>2021-12-24 13:09:23 -0500
commit955abe41dc76d5a2bcddfc38c1267f9857660a35 (patch)
treee1b41b38ac9b21443475659e43328a983e12e0ed
parent3e5535304519c31453ec12037fcd33a4b4095a51 (diff)
downloadpiem-955abe41dc76d5a2bcddfc38c1267f9857660a35.tar.gz
Add user option for specifying path to notmuch-extract-patch
`notmuch-extract-patch` might not be available on PATH. This can be the case if the package wasn't installed through the distro package manager. [km] Added package-version keyword, and dropped if-let binding. Message-Id: <20211221191527.11819-1-sourcehut@relevant-information.com>
-rw-r--r--piem-notmuch.el41
1 files changed, 23 insertions, 18 deletions
diff --git a/piem-notmuch.el b/piem-notmuch.el
index b48cf70..71d56f7 100644
--- a/piem-notmuch.el
+++ b/piem-notmuch.el
@@ -38,6 +38,11 @@
"Notmuch integration for piem."
:group 'piem)
+(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)
(declare (indent 0) (debug (body)))
(let ((rv (make-symbol "rv")))
@@ -118,25 +123,25 @@ notmuch thread."
(= (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 ((cmd (executable-find "notmuch-extract-patch"))
- (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 cmd 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.