Re: [PATCH 9/9] add has: query prefix to search for specific properties
[notmuch-archives.git] / e9 / 6b658ad27614274e9e421416e928a01639fc99
1 Return-Path: <damien.cassou@gmail.com>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 9BA08431FBC\r
6         for <notmuch@notmuchmail.org>; Tue, 11 Dec 2012 01:00:48 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.799\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
12         tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
13         FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
14 Received: from olra.theworths.org ([127.0.0.1])\r
15         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
16         with ESMTP id 87XO999por-f for <notmuch@notmuchmail.org>;\r
17         Tue, 11 Dec 2012 01:00:48 -0800 (PST)\r
18 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com\r
19         [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
20         (No client certificate requested)\r
21         by olra.theworths.org (Postfix) with ESMTPS id B6243431FAE\r
22         for <notmuch@notmuchmail.org>; Tue, 11 Dec 2012 01:00:47 -0800 (PST)\r
23 Received: by mail-we0-f181.google.com with SMTP id t11so1690896wey.26\r
24         for <notmuch@notmuchmail.org>; Tue, 11 Dec 2012 01:00:46 -0800 (PST)\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
26         h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
27         bh=y/RuoVVMQ+Ef+LcIvjpvURpR3Rg2xFKstQMpTDN6RS0=;\r
28         b=CgKZi/X4+Jl+TuIKwiSFxwnitPzExBc5GBnoNnh7aQjiqSXheQBWUsbCBp6S5Ycuik\r
29         8iIDxVpZyCz6dQq4Bbs5AawiTllqwoKmwLRH0reYs5+vJrEtBIqd+7z8DpWhLo3hQig+\r
30         M+vByqEVjWxZinLyLQ9lp32rJ6cPCn0kNYVy9/0gYPuOKRBeMYBfYDBTtqK8hFGueHDG\r
31         diHjk/qMDlJxPt0/tHgH+b1hsdEcS8Q8lsID4nq9iUCg0gy8z5d8S9XsQqsNdJxYyYQJ\r
32         2VKJszQZiiRPCDzHkaSSllNKsGKvErt0/Moilh5UF5mLpBYMSbDvg+dBg/W5zHdnDVOL\r
33         Ydsw==\r
34 Received: by 10.180.102.234 with SMTP id fr10mr15387961wib.17.1355216446502;\r
35         Tue, 11 Dec 2012 01:00:46 -0800 (PST)\r
36 Received: from luz3.lille.inria.fr ([193.51.236.232])\r
37         by mx.google.com with ESMTPS id b1sm15376748wix.11.2012.12.11.01.00.45\r
38         (version=TLSv1/SSLv3 cipher=OTHER);\r
39         Tue, 11 Dec 2012 01:00:45 -0800 (PST)\r
40 From: Damien Cassou <damien.cassou@gmail.com>\r
41 To: notmuch@notmuchmail.org\r
42 Subject: [PATCH 2/4] emacs: Make tags in notmuch-show header-line clickable\r
43 Date: Tue, 11 Dec 2012 10:00:35 +0100\r
44 Message-Id: <1355216437-21109-3-git-send-email-damien.cassou@gmail.com>\r
45 X-Mailer: git-send-email 1.7.10.4\r
46 In-Reply-To: <1355216437-21109-1-git-send-email-damien.cassou@gmail.com>\r
47 References: <1355216437-21109-1-git-send-email-damien.cassou@gmail.com>\r
48 X-BeenThere: notmuch@notmuchmail.org\r
49 X-Mailman-Version: 2.1.13\r
50 Precedence: list\r
51 List-Id: "Use and development of the notmuch mail system."\r
52         <notmuch.notmuchmail.org>\r
53 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
54         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
55 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
56 List-Post: <mailto:notmuch@notmuchmail.org>\r
57 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
58 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
59         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
60 X-List-Received-Date: Tue, 11 Dec 2012 09:00:48 -0000\r
61 \r
62 Signed-off-by: Damien Cassou <damien.cassou@gmail.com>\r
63 ---\r
64  emacs/notmuch-tagger.el |   54 ++++++++++++++++++++++++++++++++++++++++++++++-\r
65  1 file changed, 53 insertions(+), 1 deletion(-)\r
66 \r
67 diff --git a/emacs/notmuch-tagger.el b/emacs/notmuch-tagger.el\r
68 index 6fcebff..38b858a 100644\r
69 --- a/emacs/notmuch-tagger.el\r
70 +++ b/emacs/notmuch-tagger.el\r
71 @@ -23,12 +23,64 @@\r
72  ;;; Code:\r
73  ;;\r
74  \r
75 +(defun notmuch-tagger-header-button-present-p ()\r
76 +  "Check if `header-button' can be loaded or is already loaded.\r
77 +\r
78 +`header-button' is a third-party library which facilitates the\r
79 +creation of links in emacs header-line. This function tries to\r
80 +`require' `header-button' and returns nil if and only if this\r
81 +fails."\r
82 +  (require 'header-button nil t))\r
83 +\r
84 +(defun notmuch-tagger-goto-target (tag)\r
85 +  "Show a `notmuch-search' buffer for the TAG."\r
86 +  (notmuch-search (concat "tag:\"" tag "\"")))\r
87 +\r
88 +(defun notmuch-tagger-header-button-action (button)\r
89 +  "Open `notmuch-search' for the tag referenced by BUTTON.\r
90 +This function depends on the presence of the `header-button'\r
91 +library. Please call `notmuch-tagger-header-button-present-p' to\r
92 +test if the library is present before calling this function."\r
93 +  (let ((tag (header-button-get button 'notmuch-tagger-tag)))\r
94 +    (notmuch-tagger-goto-target tag)))\r
95 +\r
96 +(eval-after-load "header-button"\r
97 +  '(define-button-type 'notmuch-tagger-header-button-type\r
98 +     'supertype 'header\r
99 +     'action    #'notmuch-tagger-header-button-action\r
100 +     'follow-link t))\r
101 +\r
102 +(defun notmuch-tagger-really-make-header-link (tag)\r
103 +   "Return a property list that presents a link to TAG.\r
104 +\r
105 +The returned property list will only work in the header-line.\r
106 +Additionally, this function depends on the presence of the\r
107 +`header-button' library. Please call\r
108 +`notmuch-tagger-header-button-present-p' to test if library is\r
109 +present before calling this function."\r
110 +   (header-button-format\r
111 +    tag\r
112 +    :type 'notmuch-tagger-header-button-type\r
113 +    'notmuch-tagger-tag tag\r
114 +    'help-echo (format "%s: Search other messages like this" tag)))\r
115 +\r
116 +(defun notmuch-tagger-make-header-link (tag)\r
117 +  "Return a property list to present TAG as a link to search.\r
118 +\r
119 +This only works if `header-button' is loaded. Simply returns tag\r
120 +if not."\r
121 +  (if (notmuch-tagger-header-button-present-p)\r
122 +      (notmuch-tagger-really-make-header-link tag)\r
123 +    tag))\r
124 +\r
125  (defun notmuch-tagger-format-tags-header-line (tags)\r
126    "Format TAGS as a `mode-line-format' template.\r
127  The result is suitable for inclusion in `header-line-format'."\r
128    (list\r
129     "("\r
130 -   (notmuch-intersperse tags " ")\r
131 +   (notmuch-intersperse\r
132 +    (mapcar #'notmuch-tagger-make-header-link tags)\r
133 +    " ")\r
134     ")"))\r
135  \r
136  (provide 'notmuch-tagger)\r
137 -- \r
138 1.7.10.4\r
139 \r