* Applying patches directly from emails?
@ 2016-07-22 21:02 Nicolas Petton
2016-07-23 15:27 ` Daniel Kahn Gillmor
0 siblings, 1 reply; 6+ messages in thread
From: Nicolas Petton @ 2016-07-22 21:02 UTC (permalink / raw)
To: notmuch
[-- Attachment #1: Type: text/plain, Size: 308 bytes --]
hi,
I'd like to be able to apply patches sent from emails, either as
attachments or inlined.
Notmuch can show inline patches as diffs, which is very handy, but I
didn't find a builtin way to apply these inline patches (or attached
ones) directly from the email, maybe I overlooked something?
Cheers,
Nico
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 512 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Applying patches directly from emails?
2016-07-22 21:02 Applying patches directly from emails? Nicolas Petton
@ 2016-07-23 15:27 ` Daniel Kahn Gillmor
2016-07-24 14:03 ` Nicolas Petton
2016-08-13 10:32 ` Jani Nikula
0 siblings, 2 replies; 6+ messages in thread
From: Daniel Kahn Gillmor @ 2016-07-23 15:27 UTC (permalink / raw)
To: Nicolas Petton, notmuch
Hi Nicolas--
On Fri 2016-07-22 17:02:03 -0400, Nicolas Petton wrote:
> I'd like to be able to apply patches sent from emails, either as
> attachments or inlined.
>
> Notmuch can show inline patches as diffs, which is very handy, but I
> didn't find a builtin way to apply these inline patches (or attached
> ones) directly from the email, maybe I overlooked something?
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.
For example, if it's a git-format-generated e-mail, i'll hit the pipe
character ("|") and then in the minibuffer i'll do:
cd ~/src/notmuch/notmuch && git am
does that make sense? If that doesn't work for you, can you be more
specific about what you're trying to do?
--dkg
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Applying patches directly from emails?
2016-07-23 15:27 ` Daniel Kahn Gillmor
@ 2016-07-24 14:03 ` Nicolas Petton
2016-08-13 10:38 ` Jani Nikula
2016-08-13 10:32 ` Jani Nikula
1 sibling, 1 reply; 6+ messages in thread
From: Nicolas Petton @ 2016-07-24 14:03 UTC (permalink / raw)
To: Daniel Kahn Gillmor, notmuch
[-- Attachment #1: Type: text/plain, Size: 513 bytes --]
Daniel Kahn Gillmor <dkg@fifthhorseman.net> writes:
> Hi Nicolas--
Hi Daniel,
> 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.
Cheers,
Nico
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 512 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Applying patches directly from emails?
2016-07-23 15:27 ` Daniel Kahn Gillmor
2016-07-24 14:03 ` Nicolas Petton
@ 2016-08-13 10:32 ` Jani Nikula
1 sibling, 0 replies; 6+ messages in thread
From: Jani Nikula @ 2016-08-13 10:32 UTC (permalink / raw)
To: Daniel Kahn Gillmor, Nicolas Petton, notmuch
On Sat, 23 Jul 2016, Daniel Kahn Gillmor <dkg@fifthhorseman.net> wrote:
> Hi Nicolas--
>
> On Fri 2016-07-22 17:02:03 -0400, Nicolas Petton wrote:
>
>> I'd like to be able to apply patches sent from emails, either as
>> attachments or inlined.
>>
>> Notmuch can show inline patches as diffs, which is very handy, but I
>> didn't find a builtin way to apply these inline patches (or attached
>> ones) directly from the email, maybe I overlooked something?
>
> 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.
Additionally, you can expand all the messages you want applied, collapse
others, and use "C-u |" to pipe all open messages.
> For example, if it's a git-format-generated e-mail, i'll hit the pipe
> character ("|") and then in the minibuffer i'll do:
>
> cd ~/src/notmuch/notmuch && git am
I usually end up doing M-x cd RET first, with the convenience of
directory history and completion, then piping to git am. The end result
is the same.
BR,
Jani.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Applying patches directly from emails?
2016-07-24 14:03 ` Nicolas Petton
@ 2016-08-13 10:38 ` Jani Nikula
2016-08-14 16:07 ` Tomi Ollila
0 siblings, 1 reply; 6+ messages in thread
From: Jani Nikula @ 2016-08-13 10:38 UTC (permalink / raw)
To: Nicolas Petton, Daniel Kahn Gillmor, notmuch
On Sun, 24 Jul 2016, Nicolas Petton <nicolas@petton.fr> wrote:
> Daniel Kahn Gillmor <dkg@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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: Applying patches directly from emails?
2016-08-13 10:38 ` Jani Nikula
@ 2016-08-14 16:07 ` Tomi Ollila
0 siblings, 0 replies; 6+ messages in thread
From: Tomi Ollila @ 2016-08-14 16:07 UTC (permalink / raw)
To: Jani Nikula, Nicolas Petton, Daniel Kahn Gillmor, notmuch
On Sat, Aug 13 2016, Jani Nikula <jani@nikula.org> wrote:
> On Sun, 24 Jul 2016, Nicolas Petton <nicolas@petton.fr> wrote:
>> Daniel Kahn Gillmor <dkg@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@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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2016-08-14 17:12 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-07-22 21:02 Applying patches directly from emails? Nicolas Petton
2016-07-23 15:27 ` Daniel Kahn Gillmor
2016-07-24 14:03 ` Nicolas Petton
2016-08-13 10:38 ` Jani Nikula
2016-08-14 16:07 ` Tomi Ollila
2016-08-13 10:32 ` Jani Nikula
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
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).