From ab6b37d4265a266a02d5dc91f7f4c8b413b7714f Mon Sep 17 00:00:00 2001 From: jao Date: Mon, 19 Apr 2021 04:33:43 +0100 Subject: follow link and open enclosure commands for notmuch --- email.org | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'email.org') 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) -- cgit v1.2.3