[PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for notmuch searches
authorDaniel Schoepe <daniel@schoepe.org>
Fri, 28 Oct 2011 14:48:58 +0000 (16:48 +0200)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:39:49 +0000 (09:39 -0800)
90/f0df5a4f5c5b24211558a9e4bf4ddb9fcab4e1 [new file with mode: 0644]

diff --git a/90/f0df5a4f5c5b24211558a9e4bf4ddb9fcab4e1 b/90/f0df5a4f5c5b24211558a9e4bf4ddb9fcab4e1
new file mode 100644 (file)
index 0000000..0b5fd27
--- /dev/null
@@ -0,0 +1,122 @@
+Return-Path: <daniel@schoepe.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 D8A28429E21\r
+       for <notmuch@notmuchmail.org>; Fri, 28 Oct 2011 07:49:59 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.8\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.8 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       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 cU++a6a1bOQG for <notmuch@notmuchmail.org>;\r
+       Fri, 28 Oct 2011 07:49:59 -0700 (PDT)\r
+Received: from mail-fx0-f53.google.com (mail-fx0-f53.google.com\r
+       [209.85.161.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 253D0431FB6\r
+       for <notmuch@notmuchmail.org>; Fri, 28 Oct 2011 07:49:59 -0700 (PDT)\r
+Received: by faai28 with SMTP id i28so4080599faa.26\r
+       for <notmuch@notmuchmail.org>; Fri, 28 Oct 2011 07:49:58 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=schoepe.org; s=google;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=3lWA5wATsBizSqOVY6Z5+b3hXjVUIZhtgzGuWjF1pnw=;\r
+       b=NdmZ+gfLOmp7y5CDFoxsjAl3v4d6N/nqryGIC5WMH5R1qwaags39mHcVvQ6Fa0j4kQ\r
+       DdYwZS/dmUSgVFEVLnsQDz8QetA/ShRwsOLxDtnQvFyRP3+5Ew6GeMCUMTA1Wgcc/Yjq\r
+       Qo6lpc5XbD6DuLx2YjKJq0rx8M7uhVfpf6SPk=\r
+Received: by 10.223.17.23 with SMTP id q23mr6616687faa.11.1319813398003;\r
+       Fri, 28 Oct 2011 07:49:58 -0700 (PDT)\r
+Received: from localhost (dslb-178-004-064-120.pools.arcor-ip.net.\r
+       [178.4.64.120])\r
+       by mx.google.com with ESMTPS id a21sm17727336fao.18.2011.10.28.07.49.55\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Fri, 28 Oct 2011 07:49:56 -0700 (PDT)\r
+From: Daniel Schoepe <daniel@schoepe.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH v3] emacs: Turn id:"<message-id>" elements into buttons for\r
+       notmuch searches\r
+Date: Fri, 28 Oct 2011 16:48:58 +0200\r
+Message-Id: <1319813338-26790-2-git-send-email-daniel@schoepe.org>\r
+X-Mailer: git-send-email 1.7.7\r
+In-Reply-To: <1319813338-26790-1-git-send-email-daniel@schoepe.org>\r
+References: <1309896760-378-1-git-send-email-daniel.schoepe@googlemail.com>\r
+       <1319813338-26790-1-git-send-email-daniel@schoepe.org>\r
+Cc: Daniel Schoepe <daniel.schoepe@googlemail.com>\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: Fri, 28 Oct 2011 14:50:00 -0000\r
+\r
+From: Daniel Schoepe <daniel.schoepe@googlemail.com>\r
+\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
+ 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 8db5435..440e089 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
+@@ -789,6 +790,24 @@ current buffer, if possible."\r
+ (defvar notmuch-show-buffer-name nil)\r
+ (make-variable-buffer-local 'notmuch-show-buffer-name)\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:\\(\"?\\)[^[:space:]\"]+\\1" end t)\r
++      ;; remove the overlay created by goto-address-mode\r
++      (remove-overlays (match-beginning 0) (match-end 0) 'goto-address t)\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
+@@ -839,9 +858,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
++      (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.7\r
+\r