summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--lib/net/jao-notmuch.el35
-rw-r--r--notmuch.org6
2 files changed, 39 insertions, 2 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
diff --git a/notmuch.org b/notmuch.org
index 4f9b3ee..a36be1d 100644
--- a/notmuch.org
+++ b/notmuch.org
@@ -187,6 +187,7 @@
:bind (:map notmuch-hello-mode-map
(("a" . jao-notmuch-refresh-agenda)
("n" . widget-forward)
+ ("p" . widget-backward)
("S" . consult-notmuch)
("g" . jao-notmuch-refresh-hello)
("." . jao-notmuch-hello-first)
@@ -237,7 +238,10 @@
("RET" . jao-notmuch-tree-show-or-scroll)
("SPC" . jao-notmuch-tree-scroll-or-next))
:map notmuch-show-mode-map
- (("h" . jao-notmuch-goto-tree-buffer))
+ (("h" . jao-notmuch-goto-tree-buffer)
+ ("TAB" . jao-notmuch-show-next-button)
+ ("S-TAB" . jao-notmuch-show-previous-button)
+ ("RET" . jao-notmuch-show-ret))
:map notmuch-common-keymap
(("B" . jao-notmuch-browse-urls))))
#+end_src