summaryrefslogtreecommitdiffhomepage
path: root/email.org
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-04-19 04:33:43 +0100
committerjao <jao@gnu.org>2021-04-19 04:33:43 +0100
commitab6b37d4265a266a02d5dc91f7f4c8b413b7714f (patch)
tree19cc1c31d582002796af31a5e4abe6276ea3f33b /email.org
parenta35f2a7ccabb764beeb841196c7d2a13ce093f81 (diff)
downloadelibs-ab6b37d4265a266a02d5dc91f7f4c8b413b7714f.tar.gz
elibs-ab6b37d4265a266a02d5dc91f7f4c8b413b7714f.tar.bz2
follow link and open enclosure commands for notmuch
Diffstat (limited to 'email.org')
-rw-r--r--email.org35
1 files changed, 34 insertions, 1 deletions
diff --git a/email.org b/email.org
index 757073c..1a03bc9 100644
--- a/email.org
+++ b/email.org
@@ -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)