Washing GitHub emails to include inline patch?
Kyle Meyer
kyle at kyleam.com
Thu Sep 21 18:49:12 PDT 2017
William Casarin writes:
> Most of the patches I review these days comes in as GitHub emails that
> look like this:
>
>
> You can view, comment on, or merge this pull request online at:
[...]
> -- Patch Links --
>
> https://github.com/monstercat/iris/pull/52.patch
> https://github.com/monstercat/iris/pull/52.diff
[...]
> I wonder if it would be be possible to wash this email by downloading
> the patch and present it inline like git-send-email. This would allow me
> to review patches without having to click around the GitHub interface.
> Has anyone done this?
I have a command in my Emacs configuration that I think gets close to
what you want.
--8<---------------cut here---------------start------------->8---
(defun km/open-github-patch (buffer)
"Find GitHub patch link in BUFFER and show it in a new buffer."
(let ((url
(with-current-buffer buffer
(save-excursion
(goto-char (point-min))
(if (re-search-forward "https://github.com/.*\\.patch" nil t)
(match-string-no-properties 0)
(user-error "No patch found"))))))
(with-current-buffer (get-buffer-create
(generate-new-buffer-name "*mail-github-patch*"))
(url-insert-file-contents url)
(diff-mode)
(view-mode 1)
(pop-to-buffer (current-buffer)))))
(defun km/notmuch-show-open-github-patch ()
"Open patch from GitHub email."
(interactive)
(with-current-notmuch-show-message
(km/open-github-patch (current-buffer))))
--8<---------------cut here---------------end--------------->8---
The km/open-github-patch helper function exists because I made a slow
transition from gnus to notmuch and have a gnus variant that also calls
km/open-github-patch. If km/notmuch-show-open-github-patch is the only
caller, there's not much point in having a separate helper function.
--
Kyle
More information about the notmuch
mailing list