unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches
@ 2011-07-05 20:12 Daniel Schoepe
  2011-07-06 14:18 ` [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for Daniel Schoepe
  2011-10-28 14:48 ` [PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for Daniel Schoepe
  0 siblings, 2 replies; 16+ messages in thread
From: Daniel Schoepe @ 2011-07-05 20:12 UTC (permalink / raw)
  To: notmuch

This fixes the minor annoyance that message ids were parsed as mail
addresses by goto-address-mode in notmuch-show buffers.
---
 emacs/notmuch-show.el |   23 ++++++++++++++++++++---
 1 files changed, 20 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index f96743b..0f7fcfe 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -778,6 +778,24 @@ current buffer, if possible."
 (defvar notmuch-show-parent-buffer nil)
 (make-variable-buffer-local 'notmuch-show-parent-buffer)
 
+(defun notmuch-show-buttonise-links (start end)
+  "Buttonise URLs and mail addresses between START and END.
+
+This also turns id:\"<message id>\"-parts into buttons for
+a corresponding notmuch search."
+  (goto-address-fontify-region start end)
+  (save-excursion
+    (goto-char start)
+    (while (re-search-forward "id:\"[^ ]+\"" end t)
+      ;; remove the overlay created by goto-address-mode
+      (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t)
+      (make-text-button (match-beginning 0) (match-end 0)
+			'action `(lambda (arg)
+				   (notmuch-search ,(match-string-no-properties 0)))
+			'follow-link t
+			'help-echo "Mouse-1, RET: search for this message"
+			'face goto-address-mail-face))))
+
 ;;;###autoload
 (defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch)
   "Run \"notmuch show\" with the given thread ID and display results.
@@ -822,9 +840,8 @@ function is used. "
 	  (notmuch-show-insert-forest
 	   (notmuch-query-get-threads basic-args))))
 
-      ;; Enable buttonisation of URLs and email addresses in the
-      ;; buffer.
-      (goto-address-mode t)
+      (jit-lock-register #'notmuch-show-buttonise-links)
+
       ;; Act on visual lines rather than logical lines.
       (visual-line-mode t)
 
-- 
1.7.5.4

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

* [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for
  2011-07-05 20:12 [PATCH] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches Daniel Schoepe
@ 2011-07-06 14:18 ` Daniel Schoepe
  2011-07-06 14:18   ` [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches Daniel Schoepe
  2011-10-28 14:48 ` [PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for Daniel Schoepe
  1 sibling, 1 reply; 16+ messages in thread
From: Daniel Schoepe @ 2011-07-06 14:18 UTC (permalink / raw)
  To: notmuch

I forgot to (require 'goto-addr), which caused a warning about
goto-address-mail-face.

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

* [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches
  2011-07-06 14:18 ` [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for Daniel Schoepe
@ 2011-07-06 14:18   ` Daniel Schoepe
  2011-07-07  7:04     ` Pieter Praet
                       ` (3 more replies)
  0 siblings, 4 replies; 16+ messages in thread
From: Daniel Schoepe @ 2011-07-06 14:18 UTC (permalink / raw)
  To: notmuch

This fixes the minor annoyance that message ids were parsed as mail
addresses by goto-address-mode in notmuch-show buffers.
---
 emacs/notmuch-show.el |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index f96743b..f924d17 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -27,6 +27,7 @@
 (require 'mm-decode)
 (require 'mailcap)
 (require 'icalendar)
+(require 'goto-addr)
 
 (require 'notmuch-lib)
 (require 'notmuch-query)
@@ -778,6 +779,24 @@ current buffer, if possible."
 (defvar notmuch-show-parent-buffer nil)
 (make-variable-buffer-local 'notmuch-show-parent-buffer)
 
+(defun notmuch-show-buttonise-links (start end)
+  "Buttonise URLs and mail addresses between START and END.
+
+This also turns id:\"<message id>\"-parts into buttons for
+a corresponding notmuch search."
+  (goto-address-fontify-region start end)
+  (save-excursion
+    (goto-char start)
+    (while (re-search-forward "id:\"[^ ]+\"" end t)
+      ;; remove the overlay created by goto-address-mode
+      (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t)
+      (make-text-button (match-beginning 0) (match-end 0)
+			'action `(lambda (arg)
+				   (notmuch-search ,(match-string-no-properties 0)))
+			'follow-link t
+			'help-echo "Mouse-1, RET: search for this message"
+			'face goto-address-mail-face))))
+
 ;;;###autoload
 (defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch)
   "Run \"notmuch show\" with the given thread ID and display results.
@@ -822,9 +841,8 @@ function is used. "
 	  (notmuch-show-insert-forest
 	   (notmuch-query-get-threads basic-args))))
 
-      ;; Enable buttonisation of URLs and email addresses in the
-      ;; buffer.
-      (goto-address-mode t)
+      (jit-lock-register #'notmuch-show-buttonise-links)
+
       ;; Act on visual lines rather than logical lines.
       (visual-line-mode t)
 
-- 
1.7.5.4

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

* Re: [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches
  2011-07-06 14:18   ` [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches Daniel Schoepe
@ 2011-07-07  7:04     ` Pieter Praet
  2011-07-07  7:16     ` Dmitry Kurochkin
                       ` (2 subsequent siblings)
  3 siblings, 0 replies; 16+ messages in thread
From: Pieter Praet @ 2011-07-07  7:04 UTC (permalink / raw)
  To: Daniel Schoepe, notmuch

On Wed,  6 Jul 2011 16:18:01 +0200, Daniel Schoepe <daniel.schoepe@googlemail.com> wrote:
> This fixes the minor annoyance that message ids were parsed as mail
> addresses by goto-address-mode in notmuch-show buffers.
> ---
>  emacs/notmuch-show.el |   24 +++++++++++++++++++++---
>  1 files changed, 21 insertions(+), 3 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index f96743b..f924d17 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -27,6 +27,7 @@
>  (require 'mm-decode)
>  (require 'mailcap)
>  (require 'icalendar)
> +(require 'goto-addr)
>  
>  (require 'notmuch-lib)
>  (require 'notmuch-query)
> @@ -778,6 +779,24 @@ current buffer, if possible."
>  (defvar notmuch-show-parent-buffer nil)
>  (make-variable-buffer-local 'notmuch-show-parent-buffer)
>  
> +(defun notmuch-show-buttonise-links (start end)
> +  "Buttonise URLs and mail addresses between START and END.
> +
> +This also turns id:\"<message id>\"-parts into buttons for
> +a corresponding notmuch search."
> +  (goto-address-fontify-region start end)
> +  (save-excursion
> +    (goto-char start)
> +    (while (re-search-forward "id:\"[^ ]+\"" end t)
> +      ;; remove the overlay created by goto-address-mode
> +      (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t)
> +      (make-text-button (match-beginning 0) (match-end 0)
> +			'action `(lambda (arg)
> +				   (notmuch-search ,(match-string-no-properties 0)))
> +			'follow-link t
> +			'help-echo "Mouse-1, RET: search for this message"
> +			'face goto-address-mail-face))))
> +
>  ;;;###autoload
>  (defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch)
>    "Run \"notmuch show\" with the given thread ID and display results.
> @@ -822,9 +841,8 @@ function is used. "
>  	  (notmuch-show-insert-forest
>  	   (notmuch-query-get-threads basic-args))))
>  
> -      ;; Enable buttonisation of URLs and email addresses in the
> -      ;; buffer.
> -      (goto-address-mode t)
> +      (jit-lock-register #'notmuch-show-buttonise-links)
> +
>        ;; Act on visual lines rather than logical lines.
>        (visual-line-mode t)
>  
> -- 
> 1.7.5.4
> 
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


Signed-off-by: Pieter Praet <pieter@praet.org>

Fantastic usability improvement Daniel!


Peace

-- 
Pieter

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

* Re: [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches
  2011-07-06 14:18   ` [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches Daniel Schoepe
  2011-07-07  7:04     ` Pieter Praet
@ 2011-07-07  7:16     ` Dmitry Kurochkin
  2011-07-07  8:07       ` Pieter Praet
  2011-07-07  8:15       ` Daniel Schoepe
  2011-10-11 14:27     ` Daniel Schoepe
  2011-10-17  9:16     ` Thomas Schwinge
  3 siblings, 2 replies; 16+ messages in thread
From: Dmitry Kurochkin @ 2011-07-07  7:16 UTC (permalink / raw)
  To: Daniel Schoepe, notmuch

Hi Daniel.

On Wed,  6 Jul 2011 16:18:01 +0200, Daniel Schoepe <daniel.schoepe@googlemail.com> wrote:
> This fixes the minor annoyance that message ids were parsed as mail
> addresses by goto-address-mode in notmuch-show buffers.

I did not try it yet but it looks like a nice feature.  Though I have
some questions on the code below.

> ---
>  emacs/notmuch-show.el |   24 +++++++++++++++++++++---
>  1 files changed, 21 insertions(+), 3 deletions(-)
> 
> diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> index f96743b..f924d17 100644
> --- a/emacs/notmuch-show.el
> +++ b/emacs/notmuch-show.el
> @@ -27,6 +27,7 @@
>  (require 'mm-decode)
>  (require 'mailcap)
>  (require 'icalendar)
> +(require 'goto-addr)
>  
>  (require 'notmuch-lib)
>  (require 'notmuch-query)
> @@ -778,6 +779,24 @@ current buffer, if possible."
>  (defvar notmuch-show-parent-buffer nil)
>  (make-variable-buffer-local 'notmuch-show-parent-buffer)
>  
> +(defun notmuch-show-buttonise-links (start end)
> +  "Buttonise URLs and mail addresses between START and END.
> +
> +This also turns id:\"<message id>\"-parts into buttons for
> +a corresponding notmuch search."
> +  (goto-address-fontify-region start end)
> +  (save-excursion
> +    (goto-char start)
> +    (while (re-search-forward "id:\"[^ ]+\"" end t)
> +      ;; remove the overlay created by goto-address-mode
> +      (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t)

Why do we need to remove `goto-address-mode' overlays if it is not
enabled ((goto-address-mode t) is below is removed)?

> +      (make-text-button (match-beginning 0) (match-end 0)
> +			'action `(lambda (arg)
> +				   (notmuch-search ,(match-string-no-properties 0)))
> +			'follow-link t
> +			'help-echo "Mouse-1, RET: search for this message"
> +			'face goto-address-mail-face))))
> +
>  ;;;###autoload
>  (defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch)
>    "Run \"notmuch show\" with the given thread ID and display results.
> @@ -822,9 +841,8 @@ function is used. "
>  	  (notmuch-show-insert-forest
>  	   (notmuch-query-get-threads basic-args))))
>  
> -      ;; Enable buttonisation of URLs and email addresses in the
> -      ;; buffer.
> -      (goto-address-mode t)

`goto-address-mode' creates buttons not only for email addresses but
also for URLs.  Do we loose it now?

Regards,
  Dmitry

> +      (jit-lock-register #'notmuch-show-buttonise-links)
> +
>        ;; Act on visual lines rather than logical lines.
>        (visual-line-mode t)
>  
> -- 
> 1.7.5.4
> 
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

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

* Re: [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches
  2011-07-07  7:16     ` Dmitry Kurochkin
@ 2011-07-07  8:07       ` Pieter Praet
  2011-07-07  8:15       ` Daniel Schoepe
  1 sibling, 0 replies; 16+ messages in thread
From: Pieter Praet @ 2011-07-07  8:07 UTC (permalink / raw)
  To: Dmitry Kurochkin, Daniel Schoepe, notmuch

On Thu, 07 Jul 2011 11:16:03 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> Hi Daniel.
> 
> On Wed,  6 Jul 2011 16:18:01 +0200, Daniel Schoepe <daniel.schoepe@googlemail.com> wrote:
> > This fixes the minor annoyance that message ids were parsed as mail
> > addresses by goto-address-mode in notmuch-show buffers.
> 
> I did not try it yet but it looks like a nice feature.  Though I have
> some questions on the code below.
> 
> > ---
> >  emacs/notmuch-show.el |   24 +++++++++++++++++++++---
> >  1 files changed, 21 insertions(+), 3 deletions(-)
> > 
> > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
> > index f96743b..f924d17 100644
> > --- a/emacs/notmuch-show.el
> > +++ b/emacs/notmuch-show.el
> > @@ -27,6 +27,7 @@
> >  (require 'mm-decode)
> >  (require 'mailcap)
> >  (require 'icalendar)
> > +(require 'goto-addr)
> >  
> >  (require 'notmuch-lib)
> >  (require 'notmuch-query)
> > @@ -778,6 +779,24 @@ current buffer, if possible."
> >  (defvar notmuch-show-parent-buffer nil)
> >  (make-variable-buffer-local 'notmuch-show-parent-buffer)
> >  
> > +(defun notmuch-show-buttonise-links (start end)
> > +  "Buttonise URLs and mail addresses between START and END.
> > +
> > +This also turns id:\"<message id>\"-parts into buttons for
> > +a corresponding notmuch search."
> > +  (goto-address-fontify-region start end)
> > +  (save-excursion
> > +    (goto-char start)
> > +    (while (re-search-forward "id:\"[^ ]+\"" end t)
> > +      ;; remove the overlay created by goto-address-mode
> > +      (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t)
> 
> Why do we need to remove `goto-address-mode' overlays if it is not
> enabled ((goto-address-mode t) is below is removed)?

Because those overlays got added by `goto-address-fontify-region'.

In fact, all `goto-address-mode' does, essentially, is call
  (jit-lock-register #'goto-address-fontify-region)

> > +      (make-text-button (match-beginning 0) (match-end 0)
> > +			'action `(lambda (arg)
> > +				   (notmuch-search ,(match-string-no-properties 0)))
> > +			'follow-link t
> > +			'help-echo "Mouse-1, RET: search for this message"
> > +			'face goto-address-mail-face))))
> > +
> >  ;;;###autoload
> >  (defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch)
> >    "Run \"notmuch show\" with the given thread ID and display results.
> > @@ -822,9 +841,8 @@ function is used. "
> >  	  (notmuch-show-insert-forest
> >  	   (notmuch-query-get-threads basic-args))))
> >  
> > -      ;; Enable buttonisation of URLs and email addresses in the
> > -      ;; buffer.
> > -      (goto-address-mode t)
> 
> `goto-address-mode' creates buttons not only for email addresses but
> also for URLs.  Do we loose it now?

Nope, everything remains functional.

> Regards,
>   Dmitry
> 
> > +      (jit-lock-register #'notmuch-show-buttonise-links)
> > +
> >        ;; Act on visual lines rather than logical lines.
> >        (visual-line-mode t)
> >  
> > -- 
> > 1.7.5.4
> > 
> > _______________________________________________
> > notmuch mailing list
> > notmuch@notmuchmail.org
> > http://notmuchmail.org/mailman/listinfo/notmuch
> _______________________________________________
> notmuch mailing list
> notmuch@notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


Peace

-- 
Pieter

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

* Re: [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches
  2011-07-07  7:16     ` Dmitry Kurochkin
  2011-07-07  8:07       ` Pieter Praet
@ 2011-07-07  8:15       ` Daniel Schoepe
  2011-07-07  8:22         ` Dmitry Kurochkin
  1 sibling, 1 reply; 16+ messages in thread
From: Daniel Schoepe @ 2011-07-07  8:15 UTC (permalink / raw)
  To: Dmitry Kurochkin, notmuch

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

Hi Dmitry,

On Thu, 07 Jul 2011 11:16:03 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> Why do we need to remove `goto-address-mode' overlays if it is not
> enabled ((goto-address-mode t) is below is removed)?
> [..]
> `goto-address-mode' creates buttons not only for email addresses but
> also for URLs.  Do we loose it now?

Everything `goto-address-mode' does is still in effect, I just replaced
(goto-address-mode t) by a call to `goto-address-fontify-region' in
notmuch-show-buttonise-links, to ensure that the id links will be
buttonised (and the overlay removed after it's actually been inserted)
_after_ goto-address does its thing.

I could also have left (goto-address-mode t) in and jit-register-lock'ed
notmuch-show-buttonise-links before that, but then I would be relying on
the fact that fontifiers that are registered first, will be run last. As
far as I can tell this is just an implementation detail and might change
some day.

Cheers,
Daniel

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

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

* Re: [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches
  2011-07-07  8:15       ` Daniel Schoepe
@ 2011-07-07  8:22         ` Dmitry Kurochkin
  0 siblings, 0 replies; 16+ messages in thread
From: Dmitry Kurochkin @ 2011-07-07  8:22 UTC (permalink / raw)
  To: Daniel Schoepe, Pieter Praet, notmuch

On Thu, 07 Jul 2011 10:15:47 +0200, Daniel Schoepe <daniel.schoepe@googlemail.com> wrote:
> Hi Dmitry,
> 
> On Thu, 07 Jul 2011 11:16:03 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:
> > Why do we need to remove `goto-address-mode' overlays if it is not
> > enabled ((goto-address-mode t) is below is removed)?
> > [..]
> > `goto-address-mode' creates buttons not only for email addresses but
> > also for URLs.  Do we loose it now?
> 
> Everything `goto-address-mode' does is still in effect, I just replaced
> (goto-address-mode t) by a call to `goto-address-fontify-region' in
> notmuch-show-buttonise-links, to ensure that the id links will be
> buttonised (and the overlay removed after it's actually been inserted)
> _after_ goto-address does its thing.
> 
> I could also have left (goto-address-mode t) in and jit-register-lock'ed
> notmuch-show-buttonise-links before that, but then I would be relying on
> the fact that fontifiers that are registered first, will be run last. As
> far as I can tell this is just an implementation detail and might change
> some day.
> 

Thank you and Pieter for the answers.  I missed
`goto-address-fontify-region' on the first look.

Regards,
  Dmitry

> Cheers,
> Daniel

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

* Re: [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches
  2011-07-06 14:18   ` [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches Daniel Schoepe
  2011-07-07  7:04     ` Pieter Praet
  2011-07-07  7:16     ` Dmitry Kurochkin
@ 2011-10-11 14:27     ` Daniel Schoepe
  2011-10-17  9:16     ` Thomas Schwinge
  3 siblings, 0 replies; 16+ messages in thread
From: Daniel Schoepe @ 2011-10-11 14:27 UTC (permalink / raw)
  To: notmuch

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

On Wed,  6 Jul 2011 16:18:01 +0200, Daniel Schoepe <daniel.schoepe@googlemail.com> wrote:
> This fixes the minor annoyance that message ids were parsed as mail
> addresses by goto-address-mode in notmuch-show buffers.

Due to the frequent references to other threads on this mailing list, I
found my patch quite useful and haven't encountered any issues with
it. Hence I'm clamoring to get this applied again, so it doesn't get lost
like some other useful patches.

Cheers,
Daniel

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

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

* Re: [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches
  2011-07-06 14:18   ` [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches Daniel Schoepe
                       ` (2 preceding siblings ...)
  2011-10-11 14:27     ` Daniel Schoepe
@ 2011-10-17  9:16     ` Thomas Schwinge
  2011-10-17 12:13       ` Daniel Schoepe
  3 siblings, 1 reply; 16+ messages in thread
From: Thomas Schwinge @ 2011-10-17  9:16 UTC (permalink / raw)
  To: Daniel Schoepe; +Cc: notmuch

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

Hi!

Good idea!


On Wed,  6 Jul 2011 16:18:01 +0200, Daniel Schoepe <daniel.schoepe@googlemail.com> wrote:
> +(defun notmuch-show-buttonise-links (start end)
> +  "Buttonise URLs and mail addresses between START and END.
> +
> +This also turns id:\"<message id>\"-parts into buttons for
> +a corresponding notmuch search."
> +  (goto-address-fontify-region start end)
> +  (save-excursion
> +    (goto-char start)
> +    (while (re-search-forward "id:\"[^ ]+\"" end t)

Is it permissible for message IDs to contain double quotes?  If not (and
I hope so), might id:\"[^\"]+\" be a better regexp?  (Untested.)  As it
appears to me, this would allow proper matching in text like this, too:

    Bla bla, see id:"some@thing".  Bla bla.


Even if not favorable, should a syntax without double quotes be
supported, too?  Here we'd really have to match on whitespace and line
end, as everything else is too ambiguous.


Grüße,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 489 bytes --]

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

* Re: [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches
  2011-10-17  9:16     ` Thomas Schwinge
@ 2011-10-17 12:13       ` Daniel Schoepe
  2011-10-17 13:11         ` Thomas Schwinge
  0 siblings, 1 reply; 16+ messages in thread
From: Daniel Schoepe @ 2011-10-17 12:13 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: notmuch

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

On Mon, 17 Oct 2011 11:16:45 +0200, Thomas Schwinge <thomas@schwinge.name> wrote:
> Is it permissible for message IDs to contain double quotes?  If not (and
> I hope so), might id:\"[^\"]+\" be a better regexp?  (Untested.)  As it
> appears to me, this would allow proper matching in text like this, too:
> 
>     Bla bla, see id:"some@thing".  Bla bla.

My patch already works for this example, and I don't think spaces are
allowed in message IDs, so it shouldn't make a difference.

> Even if not favorable, should a syntax without double quotes be
> supported, too?  Here we'd really have to match on whitespace and line
> end, as everything else is too ambiguous.

I guess the syntaxes we have to support are those produced by notmuch
frontends, at least until other mailing lists start using this kind of
references as well. I don't think the quotes are necessary, since the
IDs don't contain any spaces, so your suggestion would be
preferable (of course, that might lead to more id:..-texts turned into
links even though they aren't intended to be). 
I'll send an edited patch later.

Cheers,
Daniel

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

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

* Re: [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches
  2011-10-17 12:13       ` Daniel Schoepe
@ 2011-10-17 13:11         ` Thomas Schwinge
  2011-10-17 13:43           ` Daniel Schoepe
  0 siblings, 1 reply; 16+ messages in thread
From: Thomas Schwinge @ 2011-10-17 13:11 UTC (permalink / raw)
  To: Daniel Schoepe; +Cc: notmuch

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

Hi!

On Mon, 17 Oct 2011 14:13:05 +0200, Daniel Schoepe <daniel.schoepe@googlemail.com> wrote:
> On Mon, 17 Oct 2011 11:16:45 +0200, Thomas Schwinge <thomas@schwinge.name> wrote:
> > Is it permissible for message IDs to contain double quotes?  If not (and
> > I hope so), might id:\"[^\"]+\" be a better regexp?  (Untested.)  As it
> > appears to me, this would allow proper matching in text like this, too:
> > 
> >     Bla bla, see id:"some@thing".  Bla bla.
> 
> My patch already works for this example, and I don't think spaces are
> allowed in message IDs, so it shouldn't make a difference.

Ah, of course, right...  Yet, won't yours -- id:\"[^ ]+\" -- match too
much in this example:

    Bla, bla, see id:"some@thing"--"some famous quote" is bla.

How about this one?  id:\(\"?\)[^[:space:]"]+\1

Test:

  id:some@thing "something"
  id:"some@thing"--"something"
  id:"some@thing"--something
  id:some@thing "something else"
  id:"some@thing"--"something else"
  id:"some@thing"--something else
  id:some@thing
  id:"some@thing"


Grüße,
 Thomas

[-- Attachment #2: Type: application/pgp-signature, Size: 489 bytes --]

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

* Re: [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches
  2011-10-17 13:11         ` Thomas Schwinge
@ 2011-10-17 13:43           ` Daniel Schoepe
  0 siblings, 0 replies; 16+ messages in thread
From: Daniel Schoepe @ 2011-10-17 13:43 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: notmuch

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

On Mon, 17 Oct 2011 15:11:47 +0200, Thomas Schwinge <thomas@schwinge.name> wrote:
> Ah, of course, right...  Yet, won't yours -- id:\"[^ ]+\" -- match too
> much in this example:
> 
>     Bla, bla, see id:"some@thing"--"some famous quote" is bla.
> 
> How about this one?  id:\(\"?\)[^[:space:]"]+\1

You're right, that isn't recognized correctly. According to RFC 822, the
domain part of a message id (which is just "<" addr-spec ">", where
addr-spec is the syntax for normal mail adresses) may contain double
quotes and any other characters if they are escaped with a \. I think
however, that we don't have to handle all those corner cases in a
feature that is merely for convenience, such as this.

In conclusion I think we should allow non-quoted id:..-links, but not
worry about people having escaped spaces or things like that in their
domain parts. What do you think?

Cheers,
Daniel

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

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

* [PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for 
  2011-07-05 20:12 [PATCH] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches Daniel Schoepe
  2011-07-06 14:18 ` [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for Daniel Schoepe
@ 2011-10-28 14:48 ` Daniel Schoepe
  2011-10-28 14:48   ` [PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches Daniel Schoepe
  2011-10-28 17:21   ` [PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for David Bremner
  1 sibling, 2 replies; 16+ messages in thread
From: Daniel Schoepe @ 2011-10-28 14:48 UTC (permalink / raw)
  To: notmuch

Rebased and replaced regex by the one suggested by Thomas Schwinge.

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

* [PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches
  2011-10-28 14:48 ` [PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for Daniel Schoepe
@ 2011-10-28 14:48   ` Daniel Schoepe
  2011-10-28 17:21   ` [PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for David Bremner
  1 sibling, 0 replies; 16+ messages in thread
From: Daniel Schoepe @ 2011-10-28 14:48 UTC (permalink / raw)
  To: notmuch; +Cc: Daniel Schoepe

From: Daniel Schoepe <daniel.schoepe@googlemail.com>

This fixes the minor annoyance that message ids were parsed as mail
addresses by goto-address-mode in notmuch-show buffers.
---
 emacs/notmuch-show.el |   24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
index 8db5435..440e089 100644
--- a/emacs/notmuch-show.el
+++ b/emacs/notmuch-show.el
@@ -27,6 +27,7 @@
 (require 'mm-decode)
 (require 'mailcap)
 (require 'icalendar)
+(require 'goto-addr)
 
 (require 'notmuch-lib)
 (require 'notmuch-query)
@@ -789,6 +790,24 @@ current buffer, if possible."
 (defvar notmuch-show-buffer-name nil)
 (make-variable-buffer-local 'notmuch-show-buffer-name)
 
+(defun notmuch-show-buttonise-links (start end)
+  "Buttonise URLs and mail addresses between START and END.
+
+This also turns id:\"<message id>\"-parts into buttons for
+a corresponding notmuch search."
+  (goto-address-fontify-region start end)
+  (save-excursion
+    (goto-char start)
+    (while (re-search-forward "id:\\(\"?\\)[^[:space:]\"]+\\1" end t)
+      ;; remove the overlay created by goto-address-mode
+      (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t)
+      (make-text-button (match-beginning 0) (match-end 0)
+			'action `(lambda (arg)
+				   (notmuch-search ,(match-string-no-properties 0)))
+			'follow-link t
+			'help-echo "Mouse-1, RET: search for this message"
+			'face goto-address-mail-face))))
+
 ;;;###autoload
 (defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch)
   "Run \"notmuch show\" with the given thread ID and display results.
@@ -839,9 +858,8 @@ function is used. "
 	  (notmuch-show-insert-forest
 	   (notmuch-query-get-threads basic-args))))
 
-      ;; Enable buttonisation of URLs and email addresses in the
-      ;; buffer.
-      (goto-address-mode t)
+      (jit-lock-register #'notmuch-show-buttonise-links)
+
       ;; Act on visual lines rather than logical lines.
       (visual-line-mode t)
 
-- 
1.7.7

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

* Re: [PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for
  2011-10-28 14:48 ` [PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for Daniel Schoepe
  2011-10-28 14:48   ` [PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches Daniel Schoepe
@ 2011-10-28 17:21   ` David Bremner
  1 sibling, 0 replies; 16+ messages in thread
From: David Bremner @ 2011-10-28 17:21 UTC (permalink / raw)
  To: Daniel Schoepe, notmuch

On Fri, 28 Oct 2011 16:48:57 +0200, Daniel Schoepe <daniel@schoepe.org> wrote:
> Rebased and replaced regex by the one suggested by Thomas Schwinge.
> 

Pushed.

d

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

end of thread, other threads:[~2011-10-28 17:21 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-05 20:12 [PATCH] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches Daniel Schoepe
2011-07-06 14:18 ` [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for Daniel Schoepe
2011-07-06 14:18   ` [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches Daniel Schoepe
2011-07-07  7:04     ` Pieter Praet
2011-07-07  7:16     ` Dmitry Kurochkin
2011-07-07  8:07       ` Pieter Praet
2011-07-07  8:15       ` Daniel Schoepe
2011-07-07  8:22         ` Dmitry Kurochkin
2011-10-11 14:27     ` Daniel Schoepe
2011-10-17  9:16     ` Thomas Schwinge
2011-10-17 12:13       ` Daniel Schoepe
2011-10-17 13:11         ` Thomas Schwinge
2011-10-17 13:43           ` Daniel Schoepe
2011-10-28 14:48 ` [PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for Daniel Schoepe
2011-10-28 14:48   ` [PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches Daniel Schoepe
2011-10-28 17:21   ` [PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for David Bremner

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