Re: [PATCH v2] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches
authorDmitry Kurochkin <dmitry.kurochkin@gmail.com>
Thu, 7 Jul 2011 07:16:03 +0000 (11:16 +0400)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:39:00 +0000 (09:39 -0800)
4f/e4e6ed575225573c54ac7810be06a33697e872 [new file with mode: 0644]

diff --git a/4f/e4e6ed575225573c54ac7810be06a33697e872 b/4f/e4e6ed575225573c54ac7810be06a33697e872
new file mode 100644 (file)
index 0000000..55b4414
--- /dev/null
@@ -0,0 +1,145 @@
+Return-Path: <dmitry.kurochkin@gmail.com>\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 B5E97431FD0\r
+       for <notmuch@notmuchmail.org>; Thu,  7 Jul 2011 00:16:13 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, 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 5PBJ+8X-tGqS for <notmuch@notmuchmail.org>;\r
+       Thu,  7 Jul 2011 00:16:12 -0700 (PDT)\r
+Received: from mail-bw0-f53.google.com (mail-bw0-f53.google.com\r
+       [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 5B5E7431FB6\r
+       for <notmuch@notmuchmail.org>; Thu,  7 Jul 2011 00:16:12 -0700 (PDT)\r
+Received: by bwg12 with SMTP id 12so715996bwg.26\r
+       for <notmuch@notmuchmail.org>; Thu, 07 Jul 2011 00:16:11 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=from:to:subject:in-reply-to:references:user-agent:date:message-id\r
+       :mime-version:content-type;\r
+       bh=FmyWoFla9w4G0ks13DxYKt9EN4p7rwUHjK/M7OO5bFk=;\r
+       b=udivSsn7EJ4qgOiGOtUNmz/1LnFkrN/ng51yXKvPG/VbPLN98z+ki6+0am/dt//O/m\r
+       i0NHg9gs1rQ9LegpOAgiO8xvfVXaIud+0ZybQtuSfMrhii9wj/PsZb93+xzVGzCWXKWP\r
+       5Pt3wz5I6XtPKxPgPpgnp8AlrnRUvGvZyXgdY=\r
+Received: by 10.205.65.4 with SMTP id xk4mr431227bkb.21.1310022970880;\r
+       Thu, 07 Jul 2011 00:16:10 -0700 (PDT)\r
+Received: from localhost ([91.144.186.21])\r
+       by mx.google.com with ESMTPS id lb15sm2079454bkb.1.2011.07.07.00.16.08\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Thu, 07 Jul 2011 00:16:08 -0700 (PDT)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: 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: <1309961881-28333-2-git-send-email-daniel.schoepe@googlemail.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
+User-Agent: Notmuch/0.5-321-g41686e2 (http://notmuchmail.org) Emacs/23.3.1\r
+       (x86_64-pc-linux-gnu)\r
+Date: Thu, 07 Jul 2011 11:16:03 +0400\r
+Message-ID: <87r5624l3g.fsf@gmail.com>\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 07:16:13 -0000\r
+\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
+> +      (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
+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