From: Kyle Meyer <kyle@kyleam.com>
To: sourcehut@relevant-information.com
Cc: piem@inbox.kyleam.com
Subject: Re: [PATCH 1/1] Use notmuch-extract-patch if available
Date: Sat, 11 Dec 2021 16:44:48 -0500 [thread overview]
Message-ID: <87mtl66ckv.fsf@kyleam.com> (raw)
In-Reply-To: <20211209204319.168897-2-sourcehut@relevant-information.com>
sourcehut@relevant-information.com writes (in cover letter):
> Instead of getting all the messages in the thread like my last patch I thought
> using notmuch-extract-patch would be cleaner. The code is adapted from
> elpa-mailscripts that is linked from the piem's documentation. It might be a
> good alternative to b4.
sourcehut@relevant-information.com writes (in commit message):
> notmuch-extract-patch is a command line tool from the elpa-mailscripts
> package that extracts patches from a thread. It's a useful way to
> extract the latest patch series from an email thread and filter out the
> replies and reviews.
It's been a little while since I've looked over mailscripts, but I think
it's got a lot of neat functionality (and in general am excited to see
work in this space). I obviously decided to focus piem's patch
extraction functionality around b4, but I'm happy to consider some
support for notmuch-extract-patch if there are people that 1) want to
use notmuch-extract-patch and 2) for whatever reason, prefer to use piem
rather than mailscripts.el.
> diff --git a/piem-notmuch.el b/piem-notmuch.el
> index 8b2a353..05c03ab 100644
> --- a/piem-notmuch.el
> +++ b/piem-notmuch.el
> @@ -81,7 +81,9 @@ (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 the executable
> +notmuch-extract-patch exists on the path, use that to get the
> +latest patch series from the notmuch thread."
> (when (derived-mode-p 'notmuch-show-mode)
> (let* ((handle (piem-notmuch--with-current-message
> (mm-dissect-buffer)))
> @@ -90,10 +92,25 @@ (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)))
> + (let ((id (notmuch-show-get-message-id))
> + (thread-id notmuch-show-thread-id))
> (lambda ()
> - (call-process notmuch-command nil t nil
> - "show" "--format=mbox" id))))
> + (if-let ((cmd (executable-find "notmuch-extract-patch"))
> + (tid
> + ;; 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 "}"))))
I believe this comment and (if ...) is coming straight from
mailscripts.el. You note in the cover letter that some of this is
copied from mailscripts.el, but I think there should be a code comment
as well.
However, I don't really understand why the condition is necessary.
Wouldn't always using
thread:{notmuch-show-get-message-id return value}
work?
> + (call-process cmd nil t nil
> + tid)
> + (call-process notmuch-command nil t nil
> + "show" "--format=mbox" id)))))
Rather than add this functionality to piem-notmuch-am-ready-mbox, I'd
prefer to add a dedicated function for notmuch-extract-patch. Then this
function can be added instead of (or even just ahead of)
piem-notmuch-am-ready-mbox in piem-am-ready-mbox-functions. Whether
that function is added to piem-am-ready-mbox-functions could be
controlled by a user option.
next prev parent reply other threads:[~2021-12-11 21:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-09 20:43 [PATCH 0/1] Use notmuch-extract-patch if available sourcehut
2021-12-09 20:43 ` [PATCH 1/1] " sourcehut
2021-12-11 21:44 ` Kyle Meyer [this message]
2021-12-12 9:44 ` Leo
2021-12-12 18:45 ` Kyle Meyer
2021-12-12 19:33 ` Sean Whitton
2021-12-12 19:49 ` Kyle Meyer
2021-12-14 19:12 ` Sean Whitton
2021-12-13 11:45 ` Leo
2021-12-14 11:36 ` Leo
2021-12-20 6:45 ` Sean Whitton
2021-12-12 19:26 ` Sean Whitton
2021-12-13 11:53 ` Leo
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=87mtl66ckv.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).