summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2018-12-09 14:42:45 -0500
committerKyle Meyer <kyle@kyleam.com>2018-12-09 14:44:05 -0500
commit83513ca24c1140c7983e6981e900e4e6607b50e2 (patch)
tree4db59c8908876ba600aaf88f9630e9b3469197de
parent51121efd757fedd1e8e4a88d73bbb50acf73859b (diff)
downloademacs.d-83513ca24c1140c7983e6981e900e4e6607b50e2.tar.gz
mail: Generalize "visit URL" command
-rw-r--r--lisp/km-mail.el31
1 files changed, 22 insertions, 9 deletions
diff --git a/lisp/km-mail.el b/lisp/km-mail.el
index 5701c8b..8e5e7c9 100644
--- a/lisp/km-mail.el
+++ b/lisp/km-mail.el
@@ -211,23 +211,36 @@ Tracking System, set '--in-reply-to' to the initial report and
(notmuch-show-stash-git-helper (list root-id) "--in-reply-to="))
" ")))))
+(defun km/notmuch-gitlab-url ()
+ (and (re-search-forward
+ (concat "Reply to this email directly or view it on GitLab: "
+ "\\(https://gitlab\.com/[^\n]+\\)$")
+ nil t)
+ (match-string-no-properties 1)))
+
+(defun km/notmuch-github-url ()
+ (and (re-search-forward
+ (concat "Reply to this email directly or view it on GitHub:\n"
+ "\\(https://github\.com/[^\n]+\\)$")
+ nil t)
+ (match-string-no-properties 1)))
+
+(defvar km/notmuch-url-extractors '(km/notmuch-gitlab-url km/notmuch-github-url))
;;;###autoload
-(defun km/notmuch-visit-github-url (&optional copy)
- "Visit the GitHub link associated with this message.
-If COPY is non-nil, copy the URL instead of visiting it."
+(defun km/notmuch-visit-url (&optional copy)
+ "Visit the URL link associated with this message.
+The URL is set to the the first non-nil value returned
+`km/notmuch-url-extractors'. If COPY is non-nil, copy the URL
+instead of visiting it."
(interactive "P")
(funcall
(if copy
(lambda (url) (kill-new (message url)))
#'browse-url)
(km/notmuch-with-raw-message (notmuch-show-get-message-id)
- (if (re-search-forward
- (concat "Reply to this email directly or view it on GitHub:\n"
- "\\(https://github\.com/[^\n]+\\)$")
- nil t)
- (match-string-no-properties 1)
- (user-error "No GitHub URL found")))))
+ (or (run-hook-with-args-until-success 'km/notmuch-url-extractors)
+ (user-error "No URL found")))))
;;; Mail sync