summaryrefslogtreecommitdiffhomepage
path: root/lib/net/jao-notmuch.el
diff options
context:
space:
mode:
authorjao <jao@gnu.org>2021-07-26 02:25:44 +0100
committerjao <jao@gnu.org>2021-07-26 02:25:44 +0100
commite662013059ee6a0801499b962f6681a1bde998dc (patch)
treeabb17fe12898ea39f71afa22e3edbbb668387094 /lib/net/jao-notmuch.el
parentdbb475ebfb7ef4a9b21e7174eeb9242db362c503 (diff)
downloadelibs-e662013059ee6a0801499b962f6681a1bde998dc.tar.gz
elibs-e662013059ee6a0801499b962f6681a1bde998dc.tar.bz2
notmuch: url navigation with w3m rendering
Diffstat (limited to 'lib/net/jao-notmuch.el')
-rw-r--r--lib/net/jao-notmuch.el35
1 files changed, 34 insertions, 1 deletions
diff --git a/lib/net/jao-notmuch.el b/lib/net/jao-notmuch.el
index 1de94dc..52e0fe8 100644
--- a/lib/net/jao-notmuch.el
+++ b/lib/net/jao-notmuch.el
@@ -102,11 +102,44 @@
(pop-to-buffer jao-notmuch--tree-buffer nil no-record)
(user-error "No tree view for this buffer")))
+(defun jao-notmuch-show-next-button ()
+ (interactive)
+ (when (get-text-property (point) 'w3m-href-anchor)
+ (goto-char (next-single-property-change (point) 'w3m-href-anchor)))
+ (if-let (pos (next-single-property-change (point) 'w3m-href-anchor))
+ (goto-char pos)
+ (forward-button 1)))
+
+(defun jao-notmuch-show-previous-button ()
+ (interactive)
+ (if-let (pos (previous-single-property-change (point) 'w3m-href-anchor))
+ (goto-char (previous-single-property-change pos 'w3m-href-anchor))
+ (backward-button 1)))
+
+(defun jao-notmuch-show-ret ()
+ (interactive)
+ (if-let (url (or (get-text-property (point) 'w3m-href-anchor)
+ (thing-at-point-url-at-point)))
+ (browse-url url)
+ (notmuch-show-toggle-message)))
+
+(defun jao-w3m-get-page-urls (res)
+ (save-excursion
+ (goto-char (point-min))
+ (let ((pos (point)))
+ (while (setq pos (next-single-property-change pos 'w3m-href-anchor))
+ (when-let ((url (get-text-property pos 'w3m-href-anchor)))
+ (add-to-list 'res url t)))
+ res)))
+
(defun jao-notmuch-browse-urls ()
(interactive)
(when (or (derived-mode-p 'notmuch-show-mode)
(jao-notmuch-goto-message-buffer))
- (notmuch-show-browse-urls)))
+ (let ((urls (jao-w3m-get-page-urls (notmuch-show--gather-urls))))
+ (if urls
+ (browse-url (completing-read "Browse URL: " urls))
+ (message "No URLs in this message")))))
(defun jao-notmuch--toggle-mime ()
(save-excursion