On Thu, 07 Jul 2011 11:16:03 +0400, Dmitry Kurochkin <dmitry.kurochkin at 
gmail.com> wrote:
> Hi Daniel.
> 
> On Wed,  6 Jul 2011 16:18:01 +0200, Daniel Schoepe <daniel.schoepe at 
> 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 at notmuchmail.org
> > http://notmuchmail.org/mailman/listinfo/notmuch
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


Peace

-- 
Pieter

Reply via email to