[PATCH 2/4] emacs: Make tags in notmuch-show header-line clickable
authorDamien Cassou <damien.cassou@gmail.com>
Thu, 13 Dec 2012 13:09:25 +0000 (14:09 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:52:07 +0000 (09:52 -0800)
47/dad8e0eda66109741e1bf3175fcb4ebbfe4d55 [new file with mode: 0644]

diff --git a/47/dad8e0eda66109741e1bf3175fcb4ebbfe4d55 b/47/dad8e0eda66109741e1bf3175fcb4ebbfe4d55
new file mode 100644 (file)
index 0000000..f78458d
--- /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 963D1431E64\r
+       for <notmuch@notmuchmail.org>; Thu, 13 Dec 2012 05:09:40 -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 Od1Vwz69EG3u for <notmuch@notmuchmail.org>;\r
+       Thu, 13 Dec 2012 05:09:39 -0800 (PST)\r
+Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com\r
+       [209.85.212.175]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 0130C431FBD\r
+       for <notmuch@notmuchmail.org>; Thu, 13 Dec 2012 05:09:38 -0800 (PST)\r
+Received: by mail-wi0-f175.google.com with SMTP id hm11so3877843wib.2\r
+       for <notmuch@notmuchmail.org>; Thu, 13 Dec 2012 05:09:38 -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=Ocu+8nqOhwoUC3cgjlLEyTHfun48TTTdU4i6WDMg1jfX4oaxAQrMsHS2fRub1TNZkQ\r
+       MbRB6uTVCesSFd5jwwNHYzIjvUvMfo9Oz1tIkloMEGQ/7PNHuMxwKs/eyP9Zce9EXn1E\r
+       eRHo0nwBQYDiq+S8S93GmfMRfAtFYcZ7vOzmwROTLWYGndh4GCxNrQANL8xv+IG6QT9k\r
+       HRdZYC/zdk7AMLP29uZuNn/to+UiR3Z0h/5xwgX76EiVNTkJiIOjQW2u9aLJH+OW7Qnu\r
+       lerr2Rbi8WHutPzjEwevJP2GEVWPY6CjOQl7letuSZyPljSyOGE4+rleKZS++NpOcA2p\r
+       Kdcw==\r
+Received: by 10.180.24.4 with SMTP id q4mr28896001wif.19.1355404178610;\r
+       Thu, 13 Dec 2012 05:09:38 -0800 (PST)\r
+Received: from luz3.lille.inria.fr ([193.51.236.232])\r
+       by mx.google.com with ESMTPS id bz12sm2504214wib.5.2012.12.13.05.09.37\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Thu, 13 Dec 2012 05:09:37 -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: Thu, 13 Dec 2012 14:09:25 +0100\r
+Message-Id: <1355404167-31750-3-git-send-email-damien.cassou@gmail.com>\r
+X-Mailer: git-send-email 1.7.10.4\r
+In-Reply-To: <1355404167-31750-1-git-send-email-damien.cassou@gmail.com>\r
+References: <1355404167-31750-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: Thu, 13 Dec 2012 13:09:41 -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