From: Mark Walters <markwalters1009@gmail.com>
To: notmuch@notmuchmail.org
Subject: [PATCH] make http links into buttons
Date: Fri, 23 Aug 2013 07:51:35 +0100 [thread overview]
Message-ID: <1377240695-825-1-git-send-email-markwalters1009@gmail.com> (raw)
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
next reply other threads:[~2013-08-23 6:51 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-23 6:51 Mark Walters [this message]
2014-01-19 12:23 ` [PATCH] make http links into buttons David Bremner
2014-03-16 14:16 ` Mark Walters
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1377240695-825-1-git-send-email-markwalters1009@gmail.com \
--to=markwalters1009@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).