[PATCH 3/4] emacs: Make tags that appear in `notmuch-show' clickable
authorDamien Cassou <damien.cassou@gmail.com>
Sun, 18 Nov 2012 19:18:41 +0000 (20:18 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:50:43 +0000 (09:50 -0800)
c3/ff3c9f7d7b97859fd64c55c73919c9d3b1e073 [new file with mode: 0644]

diff --git a/c3/ff3c9f7d7b97859fd64c55c73919c9d3b1e073 b/c3/ff3c9f7d7b97859fd64c55c73919c9d3b1e073
new file mode 100644 (file)
index 0000000..042e595
--- /dev/null
@@ -0,0 +1,155 @@
+Return-Path: <damien.cassou@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 6E9E3431FBD\r
+       for <notmuch@notmuchmail.org>; Sun, 18 Nov 2012 11:19:20 -0800 (PST)\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 NTRMLS0beBec for <notmuch@notmuchmail.org>;\r
+       Sun, 18 Nov 2012 11:19:18 -0800 (PST)\r
+Received: from mail-wg0-f41.google.com (mail-wg0-f41.google.com\r
+ [74.125.82.41])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 9B5D0431FD9   for <notmuch@notmuchmail.org>; Sun, 18 Nov 2012 11:19:18 -0800\r
+ (PST)\r
+Received: by mail-wg0-f41.google.com with SMTP id ds1so859565wgb.2\r
+       for <notmuch@notmuchmail.org>; Sun, 18 Nov 2012 11:19:17 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=uqTLr+lChGZ4OFtNm21p+SL8DSP28mvvERQVw8E32HU=;\r
+       b=WMp3V1fCEsAk9orVq8X3uvtQExwBemvAxv0BH8feaHjU27PK5//RiwwfpAS9zs5xzD\r
+       2C6gQkqCI2l6OEoXZve3IVYxMqKcJhxZOzNcSiZNjx/aMuyEriRVWKuHiAv8MN0IGcVA\r
+       N9tzeqJU5A5S105C38ijpRC319eUOq3CcRK4FhwbOMcMFeJh/J6IMD9utICkNOzQkjlW\r
+       Jux1AJmQxEtKVxgIAPv+PbEDPBs1iVFr9iQQyFUSal3SkxAVSetjVa5EBADAQKieYoqm\r
+       T/gsnAFgtx8E0KkHhebTrPlo5EJsvfU9tskhRANI8O5crF9lNRGI6U5Fe7u5nQ2Gen4C\r
+       ZPsQ==\r
+Received: by 10.216.196.202 with SMTP id r52mr2513540wen.81.1353266357332;\r
+       Sun, 18 Nov 2012 11:19:17 -0800 (PST)\r
+Received: from localhost.localdomain (ble59-4-82-228-190-150.fbx.proxad.net.\r
+       [82.228.190.150])\r
+       by mx.google.com with ESMTPS id i2sm10290063wiw.3.2012.11.18.11.19.16\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sun, 18 Nov 2012 11:19:16 -0800 (PST)\r
+From: Damien Cassou <damien.cassou@gmail.com>\r
+To: notmuch mailing list <notmuch@notmuchmail.org>\r
+Subject: [PATCH 3/4] emacs: Make tags that appear in `notmuch-show' clickable\r
+Date: Sun, 18 Nov 2012 20:18:41 +0100\r
+Message-Id: <1353266322-20318-4-git-send-email-damien.cassou@gmail.com>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1353266322-20318-1-git-send-email-damien.cassou@gmail.com>\r
+References: <1353266322-20318-1-git-send-email-damien.cassou@gmail.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: Sun, 18 Nov 2012 19:19:20 -0000\r
+\r
+Signed-off-by: Damien Cassou <damien.cassou@gmail.com>\r
+---\r
+ emacs/notmuch-show.el   |    9 +++++----\r
+ emacs/notmuch-tagger.el |   33 +++++++++++++++++++++++++++++++++\r
+ 2 files changed, 38 insertions(+), 4 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index 988e27c..379c8cd 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -431,10 +431,11 @@ message at DEPTH in the current thread."\r
+           (notmuch-show-clean-address (plist-get headers :From))\r
+           " ("\r
+           date\r
+-          ") ("\r
+-          (propertize (mapconcat 'identity tags " ")\r
+-                      'face 'notmuch-tag-face)\r
+-          ")\n")\r
++          ") "\r
++          (propertize\r
++           (format-mode-line (notmuch-tagger-present-tags tags))\r
++           'face 'notmuch-tag-face)\r
++          "\n")\r
+     (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))\r
+ \r
+ (defun notmuch-show-insert-header (header header-value)\r
+diff --git a/emacs/notmuch-tagger.el b/emacs/notmuch-tagger.el\r
+index 19a6c7e..379a905 100644\r
+--- a/emacs/notmuch-tagger.el\r
++++ b/emacs/notmuch-tagger.el\r
+@@ -53,12 +53,21 @@ test if the library is present before calling this function."\r
+   (let ((tag (header-button-get button 'notmuch-tagger-tag)))\r
+     (notmuch-tagger-goto-target tag)))\r
+ \r
++(defun notmuch-tagger-body-button-action (button)\r
++  "Open `notmuch-search' for the tag referenced by BUTTON."\r
++  (let ((tag (button-get button 'notmuch-tagger-tag)))\r
++    (notmuch-tagger-goto-target tag)))\r
++\r
+ (eval-after-load "header-button"\r
+   '(define-button-type 'notmuch-tagger-header-button-type\r
+      'supertype 'header\r
+      'action    #'notmuch-tagger-header-button-action\r
+      'follow-link t))\r
+ \r
++(define-button-type 'notmuch-tagger-body-button-type\r
++  'action    #'notmuch-tagger-body-button-action\r
++  'follow-link t)\r
++\r
+ (defun notmuch-tagger-really-make-header-link (tag)\r
+    "Return a property list that presents a link to TAG.\r
+ \r
+@@ -82,6 +91,19 @@ if not."\r
+       (notmuch-tagger-really-make-header-link tag)\r
+     tag))\r
+ \r
++(defun notmuch-tagger-make-body-link (tag)\r
++  "Return a property list that presents a link to TAG.\r
++The returned property list will work everywhere except in the\r
++header-line. For a link that works on the header-line, prefer\r
++`notmuch-tagger-make-header-link'."\r
++  (let ((button (copy-sequence tag)))\r
++    (make-text-button\r
++     button nil\r
++     'type 'notmuch-tagger-body-button-type\r
++     'notmuch-tagger-tag tag\r
++     'help-echo (format "%s: Search other messages like this" tag))\r
++    button))\r
++\r
+ (defun notmuch-tagger-present-tags-header-line (tags)\r
+   "Return a property list to present TAGS in emacs header-line."\r
+   (list\r
+@@ -91,6 +113,17 @@ if not."\r
+             " ")\r
+    ")"))\r
+ \r
++(defun notmuch-tagger-present-tags (tags)\r
++  "Return a property list to present TAGS in emacs.\r
++If tags the result of this function is to be used within the\r
++header-line, prefer `notmuch-tagger-present-tags-header-line'\r
++instead of this function."\r
++  (list\r
++   "("\r
++   (notmuch-tagger-separate-elems\r
++    (mapcar #'notmuch-tagger-make-body-link tags)\r
++            " ")\r
++   ")"))\r
+ \r
+ (provide 'notmuch-tagger)\r
+ ;;; notmuch-tagger.el ends here\r
+-- \r
+1.7.10.4\r
+\r