summaryrefslogtreecommitdiff
path: root/lisp/km-util.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/km-util.el')
-rw-r--r--lisp/km-util.el16
1 files changed, 16 insertions, 0 deletions
diff --git a/lisp/km-util.el b/lisp/km-util.el
index 40672d7..1678161 100644
--- a/lisp/km-util.el
+++ b/lisp/km-util.el
@@ -45,5 +45,21 @@ point in the buffer."
(progn (goto-char (region-end)) (1+ (point-at-eol))))
(list (point-min) (point-max))))
+(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)))))
+
(provide 'km-util)
;;; km-util.el ends here