aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2024-02-04 14:54:47 -0500
committerKyle Meyer <kyle@kyleam.com>2024-02-11 22:37:54 -0500
commit8abe70c235f8c8b77f7fe7f57a56068dd44c905a (patch)
tree78b93432d23b4c1852cb10eeff16a3d25894aa35
parent4256eb8b62f81f1f755184bbe245b3155f723a5a (diff)
downloadpiem-master.tar.gz
*-am-ready-mbox: Don't require PATCH prefixHEADmaster
All of the *-am-ready-mbox functions expect inline patches to have a '[... PATCH ...]' in the subject. In cases where a patch is sent without that prefix, a piem-am caller gets an unhelpful "Could not find am-ready mbox for current buffer" in response to piem-am-ready-mbox returning nil. To support these (hopefully rare) cases, drop the "has patch prefix?" guard from all the *-am-ready-mbox functions. A caller is requesting to extract a patch from the current buffer, and the "is the current buffer in the right mode?" check should be sufficient for an am-ready-mbox function to decide whether it should be responsible for generating the mbox. This added flexibility increases a caller's ability to apply invalid patches. As with the previously possible cases, the output buffer will give a clear error, but the caller will need to abort the git-am sequence and clean up the branch. That seems reasonable given that, in addition to the initial explicit request, an interactive piem-am caller needs to "confirm" applying through the prompts, making it more difficult to get to that state unintentionally. Reported-by: Leo <git@relevant-information.com> Link: https://inbox.kyleam.com/piem/87fry9hn9u.fsf@ Message-ID: <87ttmo57js.fsf@kyleam.com>
-rw-r--r--piem-gnus.el8
-rw-r--r--piem-notmuch.el12
2 files changed, 6 insertions, 14 deletions
diff --git a/piem-gnus.el b/piem-gnus.el
index 7120512..b6dc672 100644
--- a/piem-gnus.el
+++ b/piem-gnus.el
@@ -130,12 +130,8 @@ looks like a patch."
(when-let ((patch (with-current-buffer gnus-article-buffer
(save-restriction
(widen)
- (and (string-match-p
- piem-patch-subject-re
- (mail-decode-encoded-word-string
- (message-field-value "subject")))
- (buffer-substring-no-properties
- (point-min) (point-max)))))))
+ (buffer-substring-no-properties
+ (point-min) (point-max))))))
(cons (lambda () (insert patch))
"mbox"))))))
diff --git a/piem-notmuch.el b/piem-notmuch.el
index 493b724..9077ec8 100644
--- a/piem-notmuch.el
+++ b/piem-notmuch.el
@@ -100,12 +100,10 @@ looks like a patch."
(n-attachments (notmuch-count-attachments handle))
patches)
(if (= n-attachments 0)
- (when (string-match-p piem-patch-subject-re
- (notmuch-show-get-subject))
- (let ((id (notmuch-show-get-message-id)))
- (lambda ()
- (call-process notmuch-command nil t nil
- "show" "--format=mbox" id))))
+ (let ((id (notmuch-show-get-message-id)))
+ (lambda ()
+ (call-process notmuch-command nil t nil
+ "show" "--format=mbox" id)))
(notmuch-foreach-mime-part
(lambda (p)
(when-let ((patch (piem-am-extract-attached-patch p)))
@@ -125,8 +123,6 @@ Use the message itself if it looks like a patch using
notmuch-extract-patch to get the latest patch series from the
notmuch thread."
(when (and (derived-mode-p 'notmuch-show-mode)
- (string-match-p piem-patch-subject-re
- (notmuch-show-get-subject))
(= (notmuch-count-attachments
(piem-notmuch--with-current-message
(mm-dissect-buffer)))