[PATCH 2/4] emacs: Make tags in notmuch-show header-line clickable
authorDamien Cassou <damien.cassou@gmail.com>
Tue, 11 Dec 2012 09:00:35 +0000 (10:00 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:52:02 +0000 (09:52 -0800)
e9/6b658ad27614274e9e421416e928a01639fc99 [new file with mode: 0644]

diff --git a/e9/6b658ad27614274e9e421416e928a01639fc99 b/e9/6b658ad27614274e9e421416e928a01639fc99
new file mode 100644 (file)
index 0000000..d12d0b5
--- /dev/null
@@ -0,0 +1,139 @@
+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 9BA08431FBC\r
+       for <notmuch@notmuchmail.org>; Tue, 11 Dec 2012 01:00:48 -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 87XO999por-f for <notmuch@notmuchmail.org>;\r
+       Tue, 11 Dec 2012 01:00:48 -0800 (PST)\r
+Received: from mail-we0-f181.google.com (mail-we0-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 B6243431FAE\r
+       for <notmuch@notmuchmail.org>; Tue, 11 Dec 2012 01:00:47 -0800 (PST)\r
+Received: by mail-we0-f181.google.com with SMTP id t11so1690896wey.26\r
+       for <notmuch@notmuchmail.org>; Tue, 11 Dec 2012 01:00:46 -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=y/RuoVVMQ+Ef+LcIvjpvURpR3Rg2xFKstQMpTDN6RS0=;\r
+       b=CgKZi/X4+Jl+TuIKwiSFxwnitPzExBc5GBnoNnh7aQjiqSXheQBWUsbCBp6S5Ycuik\r
+       8iIDxVpZyCz6dQq4Bbs5AawiTllqwoKmwLRH0reYs5+vJrEtBIqd+7z8DpWhLo3hQig+\r
+       M+vByqEVjWxZinLyLQ9lp32rJ6cPCn0kNYVy9/0gYPuOKRBeMYBfYDBTtqK8hFGueHDG\r
+       diHjk/qMDlJxPt0/tHgH+b1hsdEcS8Q8lsID4nq9iUCg0gy8z5d8S9XsQqsNdJxYyYQJ\r
+       2VKJszQZiiRPCDzHkaSSllNKsGKvErt0/Moilh5UF5mLpBYMSbDvg+dBg/W5zHdnDVOL\r
+       Ydsw==\r
+Received: by 10.180.102.234 with SMTP id fr10mr15387961wib.17.1355216446502;\r
+       Tue, 11 Dec 2012 01:00:46 -0800 (PST)\r
+Received: from luz3.lille.inria.fr ([193.51.236.232])\r
+       by mx.google.com with ESMTPS id b1sm15376748wix.11.2012.12.11.01.00.45\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Tue, 11 Dec 2012 01:00:45 -0800 (PST)\r
+From: Damien Cassou <damien.cassou@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 2/4] emacs: Make tags in notmuch-show header-line clickable\r
+Date: Tue, 11 Dec 2012 10:00:35 +0100\r
+Message-Id: <1355216437-21109-3-git-send-email-damien.cassou@gmail.com>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1355216437-21109-1-git-send-email-damien.cassou@gmail.com>\r
+References: <1355216437-21109-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: Tue, 11 Dec 2012 09:00:48 -0000\r
+\r
+Signed-off-by: Damien Cassou <damien.cassou@gmail.com>\r
+---\r
+ emacs/notmuch-tagger.el |   54 ++++++++++++++++++++++++++++++++++++++++++++++-\r
+ 1 file changed, 53 insertions(+), 1 deletion(-)\r
+\r
+diff --git a/emacs/notmuch-tagger.el b/emacs/notmuch-tagger.el\r
+index 6fcebff..38b858a 100644\r
+--- a/emacs/notmuch-tagger.el\r
++++ b/emacs/notmuch-tagger.el\r
+@@ -23,12 +23,64 @@\r
+ ;;; Code:\r
+ ;;\r
\r
++(defun notmuch-tagger-header-button-present-p ()\r
++  "Check if `header-button' can be loaded or is already loaded.\r
++\r
++`header-button' is a third-party library which facilitates the\r
++creation of links in emacs header-line. This function tries to\r
++`require' `header-button' and returns nil if and only if this\r
++fails."\r
++  (require 'header-button nil t))\r
++\r
++(defun notmuch-tagger-goto-target (tag)\r
++  "Show a `notmuch-search' buffer for the TAG."\r
++  (notmuch-search (concat "tag:\"" tag "\"")))\r
++\r
++(defun notmuch-tagger-header-button-action (button)\r
++  "Open `notmuch-search' for the tag referenced by BUTTON.\r
++This function depends on the presence of the `header-button'\r
++library. Please call `notmuch-tagger-header-button-present-p' to\r
++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
++(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
++(defun notmuch-tagger-really-make-header-link (tag)\r
++   "Return a property list that presents a link to TAG.\r
++\r
++The returned property list will only work in the header-line.\r
++Additionally, this function depends on the presence of the\r
++`header-button' library. Please call\r
++`notmuch-tagger-header-button-present-p' to test if library is\r
++present before calling this function."\r
++   (header-button-format\r
++    tag\r
++    :type 'notmuch-tagger-header-button-type\r
++    'notmuch-tagger-tag tag\r
++    'help-echo (format "%s: Search other messages like this" tag)))\r
++\r
++(defun notmuch-tagger-make-header-link (tag)\r
++  "Return a property list to present TAG as a link to search.\r
++\r
++This only works if `header-button' is loaded. Simply returns tag\r
++if not."\r
++  (if (notmuch-tagger-header-button-present-p)\r
++      (notmuch-tagger-really-make-header-link tag)\r
++    tag))\r
++\r
+ (defun notmuch-tagger-format-tags-header-line (tags)\r
+   "Format TAGS as a `mode-line-format' template.\r
+ The result is suitable for inclusion in `header-line-format'."\r
+   (list\r
+    "("\r
+-   (notmuch-intersperse tags " ")\r
++   (notmuch-intersperse\r
++    (mapcar #'notmuch-tagger-make-header-link tags)\r
++    " ")\r
+    ")"))\r
\r
+ (provide 'notmuch-tagger)\r
+-- \r
+1.7.10.4\r
+\r