Re: [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches
authorPieter Praet <pieter@praet.org>
Thu, 7 Jul 2011 08:07:00 +0000 (10:07 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:39:00 +0000 (09:39 -0800)
2c/6cabc6207bb406056d9c395848b67a4271dea6 [new file with mode: 0644]

diff --git a/2c/6cabc6207bb406056d9c395848b67a4271dea6 b/2c/6cabc6207bb406056d9c395848b67a4271dea6
new file mode 100644 (file)
index 0000000..ad6da39
--- /dev/null
@@ -0,0 +1,157 @@
+Return-Path: <pieter@praet.org>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 1377B431FD0\r
+       for <notmuch@notmuchmail.org>; Thu,  7 Jul 2011 01:07:06 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.7\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5\r
+       tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id uLdYuC+EiAYn for <notmuch@notmuchmail.org>;\r
+       Thu,  7 Jul 2011 01:07:05 -0700 (PDT)\r
+Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com\r
+       [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 2696E431FB6\r
+       for <notmuch@notmuchmail.org>; Thu,  7 Jul 2011 01:07:05 -0700 (PDT)\r
+Received: by wyh22 with SMTP id 22so507904wyh.26\r
+       for <notmuch@notmuchmail.org>; Thu, 07 Jul 2011 01:07:03 -0700 (PDT)\r
+Received: by 10.227.207.207 with SMTP id fz15mr426974wbb.76.1310026023751;\r
+       Thu, 07 Jul 2011 01:07:03 -0700 (PDT)\r
+Received: from localhost ([109.131.160.107])\r
+       by mx.google.com with ESMTPS id b13sm6673393wbh.58.2011.07.07.01.07.02\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Thu, 07 Jul 2011 01:07:02 -0700 (PDT)\r
+From: Pieter Praet <pieter@praet.org>\r
+To: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>,\r
+       Daniel Schoepe <daniel.schoepe@googlemail.com>, notmuch@notmuchmail.org\r
+Subject: Re: [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons\r
+       for notmuch searches\r
+In-Reply-To: <87r5624l3g.fsf@gmail.com>\r
+References: <1309896760-378-1-git-send-email-daniel.schoepe@googlemail.com>\r
+       <1309961881-28333-1-git-send-email-daniel.schoepe@googlemail.com>\r
+       <1309961881-28333-2-git-send-email-daniel.schoepe@googlemail.com>\r
+       <87r5624l3g.fsf@gmail.com>\r
+User-Agent: Notmuch/0.5-331-g04cf689 (http://notmuchmail.org) Emacs/23.1.50.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Thu, 07 Jul 2011 10:07:00 +0200\r
+Message-ID: <87sjqifra3.fsf@praet.org>\r
+MIME-Version: 1.0\r
+Content-Type: text/plain; charset=us-ascii\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Thu, 07 Jul 2011 08:07:06 -0000\r
+\r
+On Thu, 07 Jul 2011 11:16:03 +0400, Dmitry Kurochkin <dmitry.kurochkin@gmail.com> wrote:\r
+> Hi Daniel.\r
+> \r
+> On Wed,  6 Jul 2011 16:18:01 +0200, Daniel Schoepe <daniel.schoepe@googlemail.com> wrote:\r
+> > This fixes the minor annoyance that message ids were parsed as mail\r
+> > addresses by goto-address-mode in notmuch-show buffers.\r
+> \r
+> I did not try it yet but it looks like a nice feature.  Though I have\r
+> some questions on the code below.\r
+> \r
+> > ---\r
+> >  emacs/notmuch-show.el |   24 +++++++++++++++++++++---\r
+> >  1 files changed, 21 insertions(+), 3 deletions(-)\r
+> > \r
+> > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+> > index f96743b..f924d17 100644\r
+> > --- a/emacs/notmuch-show.el\r
+> > +++ b/emacs/notmuch-show.el\r
+> > @@ -27,6 +27,7 @@\r
+> >  (require 'mm-decode)\r
+> >  (require 'mailcap)\r
+> >  (require 'icalendar)\r
+> > +(require 'goto-addr)\r
+> >  \r
+> >  (require 'notmuch-lib)\r
+> >  (require 'notmuch-query)\r
+> > @@ -778,6 +779,24 @@ current buffer, if possible."\r
+> >  (defvar notmuch-show-parent-buffer nil)\r
+> >  (make-variable-buffer-local 'notmuch-show-parent-buffer)\r
+> >  \r
+> > +(defun notmuch-show-buttonise-links (start end)\r
+> > +  "Buttonise URLs and mail addresses between START and END.\r
+> > +\r
+> > +This also turns id:\"<message id>\"-parts into buttons for\r
+> > +a corresponding notmuch search."\r
+> > +  (goto-address-fontify-region start end)\r
+> > +  (save-excursion\r
+> > +    (goto-char start)\r
+> > +    (while (re-search-forward "id:\"[^ ]+\"" end t)\r
+> > +      ;; remove the overlay created by goto-address-mode\r
+> > +      (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t)\r
+> \r
+> Why do we need to remove `goto-address-mode' overlays if it is not\r
+> enabled ((goto-address-mode t) is below is removed)?\r
+\r
+Because those overlays got added by `goto-address-fontify-region'.\r
+\r
+In fact, all `goto-address-mode' does, essentially, is call\r
+  (jit-lock-register #'goto-address-fontify-region)\r
+\r
+> > +      (make-text-button (match-beginning 0) (match-end 0)\r
+> > +                  'action `(lambda (arg)\r
+> > +                             (notmuch-search ,(match-string-no-properties 0)))\r
+> > +                  'follow-link t\r
+> > +                  'help-echo "Mouse-1, RET: search for this message"\r
+> > +                  'face goto-address-mail-face))))\r
+> > +\r
+> >  ;;;###autoload\r
+> >  (defun notmuch-show (thread-id &optional parent-buffer query-context buffer-name crypto-switch)\r
+> >    "Run \"notmuch show\" with the given thread ID and display results.\r
+> > @@ -822,9 +841,8 @@ function is used. "\r
+> >      (notmuch-show-insert-forest\r
+> >       (notmuch-query-get-threads basic-args))))\r
+> >  \r
+> > -      ;; Enable buttonisation of URLs and email addresses in the\r
+> > -      ;; buffer.\r
+> > -      (goto-address-mode t)\r
+> \r
+> `goto-address-mode' creates buttons not only for email addresses but\r
+> also for URLs.  Do we loose it now?\r
+\r
+Nope, everything remains functional.\r
+\r
+> Regards,\r
+>   Dmitry\r
+> \r
+> > +      (jit-lock-register #'notmuch-show-buttonise-links)\r
+> > +\r
+> >        ;; Act on visual lines rather than logical lines.\r
+> >        (visual-line-mode t)\r
+> >  \r
+> > -- \r
+> > 1.7.5.4\r
+> > \r
+> > _______________________________________________\r
+> > notmuch mailing list\r
+> > notmuch@notmuchmail.org\r
+> > http://notmuchmail.org/mailman/listinfo/notmuch\r
+> _______________________________________________\r
+> notmuch mailing list\r
+> notmuch@notmuchmail.org\r
+> http://notmuchmail.org/mailman/listinfo/notmuch\r
+\r
+\r
+Peace\r
+\r
+-- \r
+Pieter\r