Applying patches directly from emails?
Tomi Ollila
tomi.ollila at iki.fi
Sun Aug 14 09:07:57 PDT 2016
On Sat, Aug 13 2016, Jani Nikula <jani at nikula.org> wrote:
> On Sun, 24 Jul 2016, Nicolas Petton <nicolas at petton.fr> wrote:
>> Daniel Kahn Gillmor <dkg at fifthhorseman.net> writes:
>>> If you're asking about notmuch-emacs, I just use "|" (or ". |" if a
>>> MIME subpart is the patch instead of the whole message) to pipe the
>>> patch into some command i care about.
>>
>> That'd work, but I was hoping for something more integrated.
>>
>> For Emacs development & GNUS, there's `debbugs-gnu-apply-patch', which,
>> given a root directory, will apply a patch, inlined or attached to the
>> email, to the Emacs repository.
>
> I find most projects have their own peculiarities, and I'm not convinced
> it's beneficial for notmuch-emacs to include code to do this. It's
> fairly trivial to write shell scripts to do that, and you can then pipe
> the message(s) to the script, doing the cd and any other things you want
> done as part of the process. Moreover, such scripts are useful for users
> of other MUAs as well.
>
> BR,
> Jani.
Jani is right that such a special feature is not something that should be
included in everyone's emacs environment -- and to have such a
functionality in extra e.g. notmuch-devel.el would require considerable
effort to get good...
That said, I have this in my ~/.emacs.d/notmuch-config.el (where mbox is verb):
;; Patch picking code in mbox-open-notmuch-messages() adapted
;; from id:1325844199-1812-1-git-send-email-dme at dme.org (2012-01-06)
;; function notmuch-dev-review-patch(). GPLv3+
(defun mbox-open-notmuch-messages ()
"When this function is executed in notmuch-show buffer all the \"open\"
messages will be written to the file ~/tmp-mbox (overwriting it)."
(interactive)
(let ((search-terms-list (notmuch-show-get-message-ids-for-open-messages))
(buffer (get-buffer-create "* Contents of ~/tmp-mbox *")))
(set-buffer buffer)
(setq buffer-read-only nil)
(buffer-disable-undo)
(pop-to-buffer buffer)
(goto-char (point-max))
(if (> (buffer-size) 0)
(insert "\n\n"))
(insert (format-time-string
"%c: Writing the following messages to ~/tmp-mbox:\n ")
(mapconcat 'identity search-terms-list "\n ") "\n")
(with-temp-file "~/tmp-mbox"
(call-process notmuch-command nil t nil "show" "--format=mbox"
(mapconcat 'identity search-terms-list " OR ")))
(insert "\nMessages in ~/tmp-mbox:\n")
(call-process "mail" nil t nil
"-H" "-f" (expand-file-name "~/tmp-mbox"))))
After using that I usually execute git am ~/tmp-mbox
Tomi
More information about the notmuch
mailing list