From e47d51b571c449c48c622939cfca6a7566e47937 Mon Sep 17 00:00:00 2001 From: Kyle Meyer Date: Sat, 25 Feb 2017 23:32:07 -0500 Subject: Pull out logic from gnus-open-github-patch --- lisp/km-mail.el | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'lisp') diff --git a/lisp/km-mail.el b/lisp/km-mail.el index 8fa0cfb..7bc462f 100644 --- a/lisp/km-mail.el +++ b/lisp/km-mail.el @@ -102,24 +102,27 @@ argument FOLLOW, follow link instead of copying it." (--when-let (message-field-value "Message-ID") (kill-new (message "%s" it))))) +(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/gnus-open-github-patch () - "Open patch from github email. -A new buffer with the patch contents is opened in another window." + "Open patch from GitHub email." (interactive) (km/gnus-summary-set-current-article) - (let ((bufname (generate-new-buffer-name "*gnus-github-patch*")) - url) - (with-current-buffer gnus-original-article-buffer - (save-excursion - (goto-char (point-min)) - (if (re-search-forward "https://github.com/.*\\.patch" nil t) - (setq url (match-string-no-properties 0)) - (user-error "No patch found")))) - (with-current-buffer (get-buffer-create bufname) - (url-insert-file-contents url) - (diff-mode) - (view-mode 1)) - (pop-to-buffer bufname))) + (km/open-github-patch gnus-original-article-buffer)) (defun km/gnus-summary-catchup (&optional no-next) "Mark all articles as read. -- cgit v1.2.3