unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] make http links into buttons
@ 2013-08-23  6:51 Mark Walters
  2014-01-19 12:23 ` David Bremner
  0 siblings, 1 reply; 3+ messages in thread
From: Mark Walters @ 2013-08-23  6:51 UTC (permalink / raw)
  To: notmuch

This patch replaces the use of goto-address-fontify-region with our
own code doing roughly the same thing. The advantage is that we
control how the resulting buttons work. In particular RET on link
activates the button (in my case opening it in an external browser)
and TAB stops at these links.


It finds the urls using the goto-address variable for the regexp so it
should make exactly the same links.

Caveats and queries:

1) the buttons used now are text buttons rather than overlay "things":
this seems to mean some things like fonts get overridden by
notmuch-wash (observable in cited regions for example).

2) Email links are also activatable by RET but there are quite a lot
of them (eg all addresses in headers) so I make these buttons
skippable. Possibly they should not be changed as pressing RET in a
show body (to collapse the message) is relatively common so
accidentally composing a mail may be irritating.

3) the test for id buttonization in emacs-show fails because some
links become buttons. I don't think it is worth updating this
until/unless we have some consensus on how this should all work.

What do people think?

Best wishes

Mark

 
---
 emacs/notmuch-show.el |   27 ++++++++++++++++++++++++---
 1 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 82b70ba..8aa56e0 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -1080,8 +1080,31 @@ See RFC 2392.")
 
 This also turns id:\"<message id>\"-parts and mid: links into
 buttons for a corresponding notmuch search."
-  (goto-address-fontify-region start end)
   (save-excursion
+    ;; Do urls
+    (goto-char start)
+    (while (re-search-forward goto-address-url-regexp end t)
+      (make-text-button (match-beginning 0) (match-end 0)
+			:type 'notmuch-button-type
+			'action #'goto-address-at-point
+			'follow-link t
+			'help-echo "Mouse-1, RET: open this link in browser"
+			'face goto-address-url-face
+			'priority 10
+			'mouse-face goto-address-url-mouse-face))
+    ;; do email addresses
+    (goto-char start)
+    (while (re-search-forward goto-address-mail-regexp end t)
+      (make-text-button (match-beginning 0) (match-end 0)
+			:type 'notmuch-button-type
+			'action #'goto-address-at-point
+			'follow-link t
+			'help-echo "Mouse-1, RET: mail this address"
+			'face goto-address-mail-face
+			'priority 10
+			'skip t ;; don't make tab stop at all email addresses in headers etc
+			'mouse-face goto-address-mail-mouse-face))
+    ;; Do id: and mid: links
     (let (links)
       (goto-char start)
       (while (re-search-forward notmuch-id-regexp end t)
@@ -1096,8 +1119,6 @@ buttons for a corresponding notmuch search."
 	  (push (list (match-beginning 0) (match-end 0)
 		      (notmuch-id-to-query mid)) links)))
       (dolist (link links)
-	;; Remove the overlay created by goto-address-mode
-	(remove-overlays (first link) (second link) 'goto-address t)
 	(make-text-button (first link) (second link)
 			  :type 'notmuch-button-type
 			  'action `(lambda (arg)
-- 
1.7.9.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-03-16 14:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-23  6:51 [PATCH] make http links into buttons Mark Walters
2014-01-19 12:23 ` David Bremner
2014-03-16 14:16   ` Mark Walters

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).