summaryrefslogtreecommitdiff
path: root/lisp/km-mail.el
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2017-02-25 23:32:07 -0500
committerKyle Meyer <kyle@kyleam.com>2017-02-25 23:32:07 -0500
commite47d51b571c449c48c622939cfca6a7566e47937 (patch)
treeed31d64a7058d4a8bba57c3cfe0705ef04077d9f /lisp/km-mail.el
parent5d85587f5118ee2f6868fff65e0bed484cecc20b (diff)
downloademacs.d-e47d51b571c449c48c622939cfca6a7566e47937.tar.gz
Pull out logic from gnus-open-github-patch
Diffstat (limited to 'lisp/km-mail.el')
-rw-r--r--lisp/km-mail.el33
1 files changed, 18 insertions, 15 deletions
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.