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 1675C431FC0
\r
6 for <notmuch@notmuchmail.org>; Fri, 18 Jan 2013 08:04:25 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\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 v43EK9lMjHjH for <notmuch@notmuchmail.org>;
\r
17 Fri, 18 Jan 2013 08:04:23 -0800 (PST)
\r
18 Received: from mail-wi0-f175.google.com (mail-wi0-f175.google.com
\r
19 [209.85.212.175]) (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 4F1C8431FD6
\r
22 for <notmuch@notmuchmail.org>; Fri, 18 Jan 2013 08:04:18 -0800 (PST)
\r
23 Received: by mail-wi0-f175.google.com with SMTP id hm11so5372254wib.2
\r
24 for <notmuch@notmuchmail.org>; Fri, 18 Jan 2013 08:04:17 -0800 (PST)
\r
25 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;
\r
26 h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to
\r
27 :references; bh=PZJsaNl15a64PqWdNvMy5MhROJsArJxiu2ujkxVfLEY=;
\r
28 b=a+6GmVZyRiAxOx9P9GFardAbQm0pBbSLmPmBsi8g73mNVAK6tc5gGVPcECWPzTEUIR
\r
29 9vHsjrOsXv6/hz2Sw0LqbE5o2ulthb+55TxYMalDd9Gk3fi+wnnfa+loROLlV+bx2Jrj
\r
30 i2gbaCnmGxnH9g4VxEp37oY4+YXknEaqdRNZ7BPfEA9bwTvEEBJmWvUd/i2r3lHUnD8M
\r
31 h4eR490JOKW3K7Ato6fRhc0ym6zM0Q9SnBAylJrhlrYAqhtLNm3iIe6s4zQXWgEGfdCg
\r
32 SweZxe3C04gzOteIUsZLLIloTmxPUuWAUX/SXsPvedi90fL29HrCVUFIu1/Whk430ohu
\r
34 X-Received: by 10.194.172.228 with SMTP id bf4mr15155624wjc.38.1358525057161;
\r
35 Fri, 18 Jan 2013 08:04:17 -0800 (PST)
\r
36 Received: from luz3.lille.inria.fr ([193.51.236.44])
\r
37 by mx.google.com with ESMTPS id i2sm4073866wiw.3.2013.01.18.08.04.15
\r
38 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
\r
39 Fri, 18 Jan 2013 08:04:16 -0800 (PST)
\r
40 From: Damien Cassou <damien.cassou@gmail.com>
\r
41 To: notmuch mailing list <notmuch@notmuchmail.org>
\r
42 Subject: [PATCH 4/4] emacs: provide convenience functions for notmuch-tagger
\r
44 Date: Fri, 18 Jan 2013 17:03:58 +0100
\r
45 Message-Id: <1358525039-13569-5-git-send-email-damien.cassou@gmail.com>
\r
46 X-Mailer: git-send-email 1.7.10.4
\r
47 In-Reply-To: <1358525039-13569-1-git-send-email-damien.cassou@gmail.com>
\r
48 References: <1358525039-13569-1-git-send-email-damien.cassou@gmail.com>
\r
49 X-BeenThere: notmuch@notmuchmail.org
\r
50 X-Mailman-Version: 2.1.13
\r
52 List-Id: "Use and development of the notmuch mail system."
\r
53 <notmuch.notmuchmail.org>
\r
54 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
55 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
56 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
57 List-Post: <mailto:notmuch@notmuchmail.org>
\r
58 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
59 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
60 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
61 X-List-Received-Date: Fri, 18 Jan 2013 16:04:25 -0000
\r
63 This patch adds functions like `notmuch-tagger-rename',
\r
64 `notmuch-tagger-hide', and `notmuch-tagger-image-star' to facilitate
\r
65 the manipulation of `notmuch-tagger-formats'. For example, a typical
\r
66 .init.el file would contain:
\r
68 ;; Capitalize the tag 'important' and set its color
\r
69 (notmuch-tagger-rename "important" "Important" :foreground "red")
\r
71 ;; Use a star icon for the 'starred' tag
\r
72 (notmuch-tagger-image-star "starred")
\r
74 Signed-off-by: Damien Cassou <damien.cassou@gmail.com>
\r
76 emacs/notmuch-tagger.el | 101 +++++++++++++++++++++++++++++++++++++++++++----
\r
77 1 file changed, 94 insertions(+), 7 deletions(-)
\r
79 diff --git a/emacs/notmuch-tagger.el b/emacs/notmuch-tagger.el
\r
80 index 90730f6..f798757 100644
\r
81 --- a/emacs/notmuch-tagger.el
\r
82 +++ b/emacs/notmuch-tagger.el
\r
89 +;; Capitalize the tag 'important' and set its color
\r
90 +;; (notmuch-tagger-rename "important" "Important" :foreground "red")
\r
92 +;; Use a star icon for the 'starred' tag
\r
93 +;; (notmuch-tagger-image-star "starred")
\r
100 +(defun notmuch-tagger-image-path (image)
\r
101 + "Get full path for IMAGE name in the resources/ sub-directory."
\r
102 + (expand-file-name
\r
104 + (expand-file-name "resources"
\r
105 + (file-name-directory
\r
107 + (locate-library "notmuch-tagger")
\r
108 + (buffer-file-name))))))
\r
110 (defvar notmuch-tagger-formats
\r
112 (:propertize "unread" face
\r
113 (:foreground "red")))
\r
115 (:propertize "flagged" display
\r
116 - (image :type svg :file
\r
117 - ,(expand-file-name
\r
118 - "resources/star.svg"
\r
119 - (file-name-directory
\r
121 - (locate-library "notmuch-tagger")
\r
122 - (buffer-file-name))))
\r
124 + :file ,(notmuch-tagger-image-path "star.svg")
\r
125 :ascent center :mask heuristic))))
\r
126 "Contains pairs of (KEY FORMAT) to format a tag matching KEY.
\r
128 @@ -50,6 +63,80 @@ The default value set the unread tag to be red and the flagged
\r
129 tag to have a star picture attached. Those are just examples so
\r
130 you get an idea of what you can do.")
\r
132 +(defun notmuch-tagger-set-format (key format)
\r
133 + "Set that tags matched by KEY must be displayed using FORMAT.
\r
135 +This function updates `notmuch-tagger-formats' according to its
\r
138 +Instead of calling this function, use one of the higher-level
\r
139 +ones like `notmuch-tagger-rename', `notmuch-tagger-propertize',
\r
140 +`notmuch-tagger-hide', and `notmuch-tagger-image'."
\r
141 + (let ((pair (assoc key notmuch-tagger-formats)))
\r
143 + (setf (cdr pair) (list format))
\r
144 + (add-to-list 'notmuch-tagger-formats (list key format)))))
\r
147 +(defun notmuch-tagger-rename (key new-name &rest face)
\r
148 + "Display tags matching KEY as NEW-NAME with a particular FACE.
\r
149 +Use this function like this:
\r
151 +\(notmuch-tagger-rename \"draft\" \"Draft\" :foreground \"red\")
\r
153 +This will present the draft tag with a capital and in red."
\r
154 + (notmuch-tagger-set-format key
\r
155 + `(:propertize ,new-name face ,(or face 'notmuch-tag-face))))
\r
157 +(defun notmuch-tagger-propertize (key &rest face)
\r
158 + "Render tags matching KEY with a particular face.
\r
159 +Use this function like this:
\r
161 +\(notmuch-tagger-propertize \"draft\" :foreground \"red\")
\r
163 +This will present the draft tag in red."
\r
164 + (apply 'notmuch-tagger-rename key key face))
\r
166 +(defun notmuch-tagger-hide (key)
\r
167 + "Hide tags matching KEY."
\r
168 + (notmuch-tagger-set-format key nil))
\r
170 +(defun notmuch-tagger-image (key file type)
\r
171 + "Show tags matching KEY as images taken from FILE with type TYPE.
\r
173 +See Info node `(elisp)Image Formats' for possible values for
\r
174 +TYPE (e.g., 'svg and 'png).
\r
176 +There is a set of predefined pictures that you can use by calling
\r
177 + functions like `notmuch-tagger-image-star' and
\r
178 + `notmuch-tagger-image-tag'."
\r
179 + (notmuch-tagger-set-format
\r
181 + `(:propertize ,key display
\r
182 + (image :type ,type
\r
185 + :mask heuristic))))
\r
187 +(defun notmuch-tagger-provided-image (key image)
\r
188 + "Show tags matching KEY as IMAGE provided by notmuch-tagger."
\r
189 + (notmuch-tagger-image
\r
191 + (notmuch-tagger-image-path image)
\r
192 + (intern (file-name-extension image))))
\r
194 +(defun notmuch-tagger-image-star (key)
\r
195 + "Show tags matching KEY as resources/star.svg."
\r
196 + (notmuch-tagger-provided-image key "star.svg"))
\r
198 +(defun notmuch-tagger-image-star-empty (key)
\r
199 + "Show tags matching KEY as resources/star-empty.svg."
\r
200 + (notmuch-tagger-provided-image key "star-empty.svg"))
\r
202 +(defun notmuch-tagger-image-tag (tag)
\r
203 + "Show tags matching KEY as resources/tag.svg."
\r
204 + (notmuch-tagger-provided-image tag "tag.svg"))
\r
206 (defun notmuch-tagger-tag-format (tag)
\r
207 "Format TAG as a `mode-line-format' template.
\r