diff options
-rw-r--r-- | email.org | 35 |
1 files changed, 34 insertions, 1 deletions
@@ -271,6 +271,37 @@ (when (or (derived-mode-p 'notmuch-show-mode) (jao-notmuch-goto-message-buffer)) (notmuch-show-browse-urls))) + + (defun jao-notmuch-follow-link (&optional external) + (interactive "P") + (with-current-notmuch-show-message + (goto-char (point-min)) + (if (not (or (search-forward-regexp "\\bVia: " nil t) + (search-forward-regexp "\\bURL: " nil t) + (and (search-forward-regexp "\\bLink$" nil t) + (not (beginning-of-line))))) + (user-error "No standard Via/URL/Link") + (re-search-forward "https?://" nil t) + (if external + (jao-browse-with-external-browser) + (browse-url (jao-url-around-point)))))) + + (defun jao-notmuch-open-enclosure (add) + (interactive "P") + (with-current-notmuch-show-message + (goto-char (point-min)) + (if (not (search-forward "Enclosure:" nil t)) + (user-error "No enclosure in message body") + (re-search-forward "https?://" nil t) + (if-let (url (thing-at-point-url-at-point)) + (progn + (message "%s %s ..." (if add "Adding" "Playing") url) + (if add + (emms-add-url url) + (emms-play-url url) + (sit-for 1) + (jao-emms-echo))) + (error "Found an enclosure, but not a link!"))))) #+end_src *** package #+begin_src emacs-lisp @@ -330,7 +361,9 @@ :bind (:map notmuch-common-keymap (("T" . jao-notmuch-tree-tag) - ("B" . jao-notmuch-browse-urls)) + ("E" . jao-notmuch-open-enclosure) + ("B" . jao-notmuch-browse-urls) + ("M-g" . jao-notmuch-follow-link)) :map notmuch-show-mode-map (("h" . jao-notmuch-goto-index-buffer) ("k" . jao-notmuch-tag-jump) |