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

* Re: [PATCH] make http links into buttons
  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
  0 siblings, 1 reply; 3+ messages in thread
From: David Bremner @ 2014-01-19 12:23 UTC (permalink / raw)
  To: Mark Walters, notmuch

[-- Attachment #1: Type: text/plain, Size: 470 bytes --]

Mark Walters <markwalters1009@gmail.com> writes:

> 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.

The attached message behaves a bit strangely under tabbing; it seems to
get stuck in the first signature block.


[-- Attachment #2: review.eml:2,S --]
[-- Type: application/octet-stream, Size: 5392 bytes --]

Return-path: <mathematical_statistical_sciences@nsa.gc.gov>
Envelope-to: snowden@localhost
Delivery-date: Fri, 13 Dec 2013 11:30:06 -0400
Received: from localhost ([127.0.0.1] helo=tesseract.cs.fbi.gov)
	by tesseract.cs.fbi.gov with esmtp (Exim 4.80)
	(envelope-from <mathematical_statistical_sciences@nsa.gov>)
	id 1VrUgj-0006pg-Gg
	for snowden@localhost; Fri, 13 Dec 2013 11:30:05 -0400
MIME-Version: 1.0
Received: from fbimail.ad.fbi.gov [131.202.6.79]
	by tesseract.cs.fbi.gov with IMAP (fetchmail-6.3.21)
	for <snowden@localhost> (single-drop); Fri, 13 Dec 2013 11:30:01 -0400 (AST)
Received: from wintermute.ad.fbi.gov (131.202.1.54) by wopr.ad.fbi.gov
 (131.202.6.81) with Microsoft SMTP Server (TLS) id 14.3.174.1; Fri, 13 Dec
 2013 11:29:11 -0400
Received: from fiero.its.fbi.gov (131.202.1.10) by wintermute.ad.fbi.gov
 (131.202.1.54) with Microsoft SMTP Server (TLS) id 14.3.158.1; Fri, 13 Dec
 2013 11:29:11 -0400
Received: from pmx4.nbpei-ecn.gov (pmx4.nbpei-ecn.gov [198.164.163.222])	by
 fiero.its.fbi.gov (8.13.8/8.13.8) with ESMTP id rBDFTBF7005728	for
 <snowden@fbi.gov>; Fri, 13 Dec 2013 11:29:11 -0400
Received: from pmx4.nbpei-ecn.gov (localhost [127.0.0.1])	by localhost
 (Postfix) with SMTP id ECBAEB00E75	for <snowden@fbi.gov>; Fri, 13 Dec 2013
 11:29:10 -0400 (AST)
Received: from ipmail2.nserc.gov (ipmail2.nserc.gov [198.96.3.111])	by
 pmx4.nbpei-ecn.gov (Postfix) with ESMTP id AC5C9B007BB	for <snowden@fbi.gov>;
 Fri, 13 Dec 2013 11:29:10 -0400 (AST)
Message-ID: <666@ipmail2.nsa.gov>
X-IronPort-AV: E=Sophos;i="4.95,479,1384318800"; 
   d="scan'208";a="12157491"
Received: from unknown (HELO OTTCNSPW2.secure.gov) ([192.168.2.97])  by
 ipmail2.nserc.gov with SMTP; 13 Dec 2013 10:29:07 -0500
Date: Fri, 13 Dec 2013 10:29:07 -0500
From: <mathematical_statistical_sciences@nsa.gov>
To: <snowden@fbi.gov>
Content-Transfer-Encoding: 8bit
Content-Type: text/html; charset="utf-8"
Subject: blah blah
X-Mailer: Microsoft SharePoint Foundation 2010
X-PMX-Version: 6.0.3.2322014, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2013.12.13.151815
X-PerlMx-Spam: Gauge=XIIIIIII, Probability=17%, Report='
 CTYPE_JUST_HTML 0.848, HTML_MIME_NO_HTML_TAG 0.8, HTML_NO_HTTP 0.1, MSGID_ADDED_BY_MTA 0.05, SUPERLONG_LINE 0.05, BODYTEXTH_SIZE_10000_LESS 0, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, NO_REAL_NAME 0, SPF_NONE 0, __ANY_URI 0, __C230066_P5 0, __CT 0, __CTE 0, __CTYPE_HTML 0, __CTYPE_IS_HTML 0, __HAS_FROM 0, __HAS_HTML 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HIGHBITS 0, __MIME_HTML 0, __MIME_HTML_ONLY 0, __MIME_VERSION 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __SUBJ_ALPHA_END2 0, __SUBJ_ALPHA_NEGATE 0, __SUBJ_HIGHBIT 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_PATH 0, __URI_NS , __USER_AGENT_MS_GENERIC 0, __UTF8_SUBJ 0'
X-MS-Exchange-Organization-Antispam-Report: ContentFilterConfigBypassedSender
X-MS-Exchange-Organization-AVStamp-Mailbox: MSFTFF;1;0;0 0 0
X-MS-Exchange-Organization-SCL: -1
X-MS-Exchange-Organization-AuthSource: wintermute.ad.fbi.gov
X-MS-Exchange-Organization-AuthAs: Anonymous
X-Spam-Score: 1.8
X-Spam_bar: +

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">(Le français suit l’anglais)
 
<p> Dear Dr. Snowden: </p>


<p> Your Username is: snowden@fbi.gov </p>

<p> If you have forgotten your Password, select <strong>I Forgot my Password</strong> on the login page. </p>

<p> To access the referee extranet, go to <a href="https://influence.nsa.gov/sekrit.aspx">https://influence.nsa.gov/sekrit.aspx</a>. </p>


<p><strong>Technical Support</strong><br>
Contact the On-line Services Helpdesk at 999-999-0000 or by email at <a href="mailto:webapp@nsa.gov">webapp@nsa.gov</a>. In your message, please include your email address and telephone number. Hours of service are from 8:30 a.m. to 4:30 p.m. (EST), Monday to Friday. </p>

<p>Regards, </p>


<p> <strong> J Edgar Hoover </strong>
Research Grants and Scholarships | Subventions de recherche et bourses<br>
<br>
--<br>
<a href="mailto:mathematical_statistical_sciences@nsa.gov">mathematical_statistical_sciences@nsa.gov</a><br>
<br>
<a href="www.nsa.gov"> www.nsa.gov</a>  | <a href="www.cia.gov"> www.cia.gov</a><br>

</p>

<p>_____________</p>

<p> Madame/Monsieur, </p>


<p> Votre nom d’utilisateur est : snowden@fbi.gov </p>

<p> Si vous avez oublié votre mot de passe, sélectionnez <strong>J'ai oublié mon mot de passe</strong> à la page d’ouverture de session de l’extranet. </p>


<p> Pour accéder à l’extranet, rendez-vous à <a href="https://influence.nsa.gov/sekrit.aspx">https://influence.nsa.gov/sekrit.aspx</a>. </p>

<p> <strong>Soutien technique</strong><br>
 Veuillez communiquer avec le Service de dépannage des services électroniques par téléphone au999-999-0000 ou par courriel à <a href="mailto:webapp@nsa.gov">webapp@nsa.gov</a> et indiquer dans votre message votre adresse de courriel et votre numéro de téléphone. Les heures de service sont de 8 h 30 à 16 h 30 (heure de l’Est) du lundi au vendredi. </p>

<p> Sincères salutations, </p>

<p> <strong>J Edgar Hoover </strong> <br>
Research Grants and Scholarships | Subventions de recherche et bourses<br>
<br>
--<br>
<a href="mailto:mathematical_statistical_sciences@nsa.gov">mathematical_statistical_sciences@nsa.gov</a><br>
<br>
<a href="www.nsa.gov"> www.nsa.gov</a>  | <a href="www.cia.gov"> www.cia.gov</a><br>

</p>

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

* Re: [PATCH] make http links into buttons
  2014-01-19 12:23 ` David Bremner
@ 2014-03-16 14:16   ` Mark Walters
  0 siblings, 0 replies; 3+ messages in thread
From: Mark Walters @ 2014-03-16 14:16 UTC (permalink / raw)
  To: David Bremner, notmuch


Since there was a little discussion about this on irc I post it here (with
bremner's permission) so that it doesn't get lost.

Best wishes

Mark

Day changed Mon Jan 20 2014

14:28 < mjw1009_> bremner: I am not sure quite what behaviour you were seeing on the link-buttons message (nor quite what you would expect)
14:29 < mjw1009_> (that is the message attached to id:87mwisqhx7.fsf@zancas.localnet)
14:29 < bremner> umm. hangon, I need to re-enable that patch.
14:30 < mjw1009_> before you do can you check it behaves as you expect in master?
14:30 < bremner> well, tabbing doesn't visit the URLs at all in master. so I guess yes?
14:30 < mjw1009_> and you would expect it just to stop at the [text/html] part button?
14:31 < bremner> it bounces between the from address and the text/html button
14:31 < mjw1009_> (I was a little surprised when looking at the code that we linkify the html part at all rather than leaving that to shr or something)
14:32 < mjw1009_> Oh great. that behaves differently in emacs 23
14:32 < mjw1009_> (on master)
14:32 < bremner> ah. this could be tricky. Do you have access to emacs24?
14:33 < mjw1009_> yes
14:34 < bremner> ok, with the patch in emacs24, I hit tab 3 times, and then it seems stuck at "mathematical_statistical_sciences@nsa.gov"
14:35 < mjw1009_> Ok now I can reproduce some odd behaviour. It works much more as expected in emacs23
14:36 < mjw1009_> I don't know why it is cycling in the normal case on emacs24. on normal message tab on emacs23 stops at the end of the message and signals an error. 
14:37 < mjw1009_> But anyway I now know where to look so I can do some experiments. Thanks!
14:37 < bremner> cool.

20:04 < mjw1009_> does anyone else see the following on emacs24: goto a message with a text/html part(eg id:CAGhLh6F=m_K9QqmwXmakfeyPbCtMriBAr+6FQ7N8seT=r15KmQ@mail.gmail.com ); if you tab thought the message it all behaves correctly, but if you open the text-html part and tab through then the cursor goes from the text-html button to the top of the buffer

Day changed Tue Jan 21 2014

02:03 < bremner> mjw1009_: yeah, I can duplicate that.

^ permalink raw reply	[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).