From: sourcehut@relevant-information.com
To: piem@inbox.kyleam.com
Cc: sourcehut@relevant-information.com
Subject: [PATCH 1/1] piem-notmuch-am-ready-mbox: Add option to edit patches before applying them
Date: Wed, 8 Dec 2021 17:01:43 +0100 [thread overview]
Message-ID: <20211208160142.84085-2-sourcehut@relevant-information.com> (raw)
In-Reply-To: <20211208160142.84085-1-sourcehut@relevant-information.com>
From: <sourcehut@relevant-information.com>
---
piem-notmuch.el | 40 +++++++++++++++++++++++++++++++++++-----
1 file changed, 35 insertions(+), 5 deletions(-)
diff --git a/piem-notmuch.el b/piem-notmuch.el
index 8b2a353..2ad4ace 100644
--- a/piem-notmuch.el
+++ b/piem-notmuch.el
@@ -77,11 +77,35 @@ (defun piem-notmuch-mid-to-thread (mid)
"show" "--format=mbox" "--entire-thread=true"
(concat "id:" mid)))))
+(defun piem-notmuch-show-view-mbox-message (arg)
+ "View the mbox formatted version of the current message.
+
+Used for editing patches before applying them.
+
+With one universal prefix argument, view the entire thread instead. "
+ (interactive "P")
+ (let* ((id (notmuch-show-get-message-id))
+ (buf (get-buffer-create (concat "*notmuch-mbox-" id "*")))
+ (inhibit-read-only t))
+ (pop-to-buffer-same-window buf)
+ (erase-buffer)
+ (let ((coding-system-for-read 'no-conversion))
+ (if (equal '(4) arg)
+ (call-process notmuch-command nil t nil "show" "--entire-thread=true" "--format=mbox" id)
+ (call-process notmuch-command nil t nil "show" "--format=mbox" id)))
+ (goto-char (point-min))
+ (set-buffer-modified-p nil)
+ (setq buffer-read-only nil)
+ (view-buffer buf 'kill-buffer-if-not-modified)))
+
+
(defun piem-notmuch-am-ready-mbox ()
"Return a function that inserts an am-ready mbox.
If the buffer has any MIME parts that look like a patch, use
those parts' contents (in order) as the mbox. Otherwise, use the
-message itself if it looks like a patch."
+message itself if it looks like a patch. If a corresponding
+*notmuch-mbox- buffer exists, use that instead of fetching from
+the notmuch database."
(when (derived-mode-p 'notmuch-show-mode)
(let* ((handle (piem-notmuch--with-current-message
(mm-dissect-buffer)))
@@ -90,10 +114,16 @@ (defun piem-notmuch-am-ready-mbox ()
(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))))
+ (if-let ((buf (get-buffer (concat "*notmuch-mbox-" (notmuch-show-get-message-id) "*"))))
+ (let ((str (with-current-buffer buf
+ (buffer-substring-no-properties (point-min)
+ (point-max)))))
+ (lambda ()
+ (insert str)))
+ (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)))
--
2.31.0
next prev parent reply other threads:[~2021-12-08 16:04 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-08 16:01 Adding support for editing patches before applying them sourcehut
2021-12-08 16:01 ` sourcehut [this message]
2021-12-09 3:43 ` [PATCH 1/1] piem-notmuch-am-ready-mbox: Add option to edit " Kyle Meyer
2021-12-09 5:20 ` Kyle Meyer
2021-12-09 10:10 ` Leo
2021-12-09 13:00 ` Leo
2021-12-10 5:08 ` Kyle Meyer
2021-12-10 9:31 ` Leo
2021-12-11 21:44 ` Kyle Meyer
2021-12-16 20:05 ` [PATCH] Add ability " sourcehut
2021-12-17 5:58 ` Kyle Meyer
2021-12-21 14:02 ` [PATCH v2] " sourcehut
2021-12-24 18:32 ` Kyle Meyer
2021-12-27 16:07 ` Leo
2021-12-27 21:07 ` distributing piem via *ELPA Kyle Meyer
2021-12-27 21:30 ` Kyle Meyer
2021-12-09 3:38 ` Adding support for editing patches before applying them 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=20211208160142.84085-2-sourcehut@relevant-information.com \
--to=sourcehut@relevant-information.com \
--cc=piem@inbox.kyleam.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).