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 B2B4E431FC7
\r
6 for <notmuch@notmuchmail.org>; Fri, 18 Jan 2013 08:04:23 -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 PajPoLpN0zHv for <notmuch@notmuchmail.org>;
\r
17 Fri, 18 Jan 2013 08:04:20 -0800 (PST)
\r
18 Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com
\r
19 [209.85.212.173]) (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 08E10431FBD
\r
22 for <notmuch@notmuchmail.org>; Fri, 18 Jan 2013 08:04:16 -0800 (PST)
\r
23 Received: by mail-wi0-f173.google.com with SMTP id hn17so5372406wib.6
\r
24 for <notmuch@notmuchmail.org>; Fri, 18 Jan 2013 08:04:15 -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:mime-version:content-type:content-transfer-encoding;
\r
28 bh=BSHBNDKgtZlDoHTPhclYOsZGKPit+swxFajCc5Q/S8U=;
\r
29 b=ThTn+woO874YCyCENuYHqo5P0Bl0WbDCj/Ebsp8ikPu4Y/aQvcnoWUGrTmJ+kd4d1c
\r
30 /T/7lBbogJ0RGJpDu+mxt+BQUUID3NMi/Hk+fOzX9M+KB6HVcwchub94yXo7YsXJ7zW5
\r
31 tDpMjnRTAQzMOjbFyS8DSgYCv3ylEbFABQeW/cQqq8KnS1PxtTf6r8mT37AbAiRRKStP
\r
32 vZf7rtzjDsfiEXwf/ol8/Tf6ZAhYmw1VnsUAUkA0DANHQzRr3IdfiQg2uP7iM8RSUW/i
\r
33 6Qd2ly3fHqLs2Y4cslGfs0SRxj4UtBKxRxCZ3iCmqQlodk+y+zjFyPmUPn0oJ526/cYa
\r
35 X-Received: by 10.194.174.234 with SMTP id bv10mr15135530wjc.47.1358525055856;
\r
36 Fri, 18 Jan 2013 08:04:15 -0800 (PST)
\r
37 Received: from luz3.lille.inria.fr ([193.51.236.44])
\r
38 by mx.google.com with ESMTPS id i2sm4073866wiw.3.2013.01.18.08.04.14
\r
39 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128);
\r
40 Fri, 18 Jan 2013 08:04:15 -0800 (PST)
\r
41 From: Damien Cassou <damien.cassou@gmail.com>
\r
42 To: notmuch mailing list <notmuch@notmuchmail.org>
\r
43 Subject: [PATCH 3/4] emacs: possibility to customize the rendering of tags
\r
44 Date: Fri, 18 Jan 2013 17:03:57 +0100
\r
45 Message-Id: <1358525039-13569-4-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
50 Content-Type: text/plain; charset=UTF-8
\r
51 Content-Transfer-Encoding: 8bit
\r
52 X-BeenThere: notmuch@notmuchmail.org
\r
53 X-Mailman-Version: 2.1.13
\r
55 List-Id: "Use and development of the notmuch mail system."
\r
56 <notmuch.notmuchmail.org>
\r
57 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
58 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
59 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
60 List-Post: <mailto:notmuch@notmuchmail.org>
\r
61 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
62 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
63 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
64 X-List-Received-Date: Fri, 18 Jan 2013 16:04:24 -0000
\r
66 This patch extracts the rendering of tags in notmuch-show to a
\r
67 dedicated notmuch-tagger file.
\r
69 This new file introduces a `notmuch-tagger-formats' variable that
\r
70 associates each tag to a particular format. For example,
\r
73 (:propertize "unread" face
\r
74 (:foreground "red")))
\r
76 (:propertize "flagged" display
\r
77 (image :type svg :file "~/notmuch/emacs/resources/star.svg" :ascent center :mask heuristic))))
\r
79 associates a red font to the "unread" tag and a star picture to
\r
82 In the future, I would like to use the Customization interface of
\r
83 Emacs to edit this variable and also to provide high-lever
\r
84 functions to manipulate it such
\r
85 that (notmuch-tagger-propertize "unread" :foreground "red")
\r
86 and (notmuch-tagger-picture "flagged" "star.svg").
\r
88 `mode-line-format' templates are used to represent the format for
\r
89 each tag. This is a concize format that can also be used in
\r
90 `header-line-format' if later desired.
\r
92 Signed-off-by: Damien Cassou <damien.cassou@gmail.com>
\r
94 emacs/notmuch-show.el | 7 ++---
\r
95 emacs/notmuch-tagger.el | 75 +++++++++++++++++++++++++++++++++++++++++++++++
\r
96 emacs/notmuch.el | 5 ++--
\r
97 3 files changed, 80 insertions(+), 7 deletions(-)
\r
98 create mode 100644 emacs/notmuch-tagger.el
\r
100 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
101 index 1864dd1..7bf9f3c 100644
\r
102 --- a/emacs/notmuch-show.el
\r
103 +++ b/emacs/notmuch-show.el
\r
105 (require 'notmuch-mua)
\r
106 (require 'notmuch-crypto)
\r
107 (require 'notmuch-print)
\r
108 +(require 'notmuch-tagger)
\r
110 (declare-function notmuch-call-notmuch-process "notmuch" (&rest args))
\r
111 (declare-function notmuch-fontify-headers "notmuch" nil)
\r
112 @@ -362,8 +363,7 @@ operation on the contents of the current buffer."
\r
113 (if (re-search-forward "(\\([^()]*\\))$" (line-end-position) t)
\r
114 (let ((inhibit-read-only t))
\r
115 (replace-match (concat "("
\r
116 - (propertize (mapconcat 'identity tags " ")
\r
117 - 'face 'notmuch-tag-face)
\r
118 + (notmuch-tagger-present-tags tags)
\r
121 (defun notmuch-clean-address (address)
\r
122 @@ -441,8 +441,7 @@ message at DEPTH in the current thread."
\r
126 - (propertize (mapconcat 'identity tags " ")
\r
127 - 'face 'notmuch-tag-face)
\r
128 + (notmuch-tagger-present-tags tags)
\r
130 (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face)))
\r
132 diff --git a/emacs/notmuch-tagger.el b/emacs/notmuch-tagger.el
\r
133 new file mode 100644
\r
134 index 0000000..90730f6
\r
136 +++ b/emacs/notmuch-tagger.el
\r
138 +;; notmuch-tagger.el --- Library to improve the way tags are displayed
\r
140 +;; Copyright © Damien Cassou
\r
142 +;; This file is part of Notmuch.
\r
144 +;; Notmuch is free software: you can redistribute it and/or modify it
\r
145 +;; under the terms of the GNU General Public License as published by
\r
146 +;; the Free Software Foundation, either version 3 of the License, or
\r
147 +;; (at your option) any later version.
\r
149 +;; Notmuch is distributed in the hope that it will be useful, but
\r
150 +;; WITHOUT ANY WARRANTY; without even the implied warranty of
\r
151 +;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
\r
152 +;; General Public License for more details.
\r
154 +;; You should have received a copy of the GNU General Public License
\r
155 +;; along with Notmuch. If not, see <http://www.gnu.org/licenses/>.
\r
157 +;; Authors: Damien Cassou <damien.cassou@gmail.com>
\r
167 +(defvar notmuch-tagger-formats
\r
169 + (:propertize "unread" face
\r
170 + (:foreground "red")))
\r
172 + (:propertize "flagged" display
\r
173 + (image :type svg :file
\r
174 + ,(expand-file-name
\r
175 + "resources/star.svg"
\r
176 + (file-name-directory
\r
178 + (locate-library "notmuch-tagger")
\r
179 + (buffer-file-name))))
\r
180 + :ascent center :mask heuristic))))
\r
181 + "Contains pairs of (KEY FORMAT) to format a tag matching KEY.
\r
183 +KEY must be a string with a tag name. In the future, KEY could
\r
184 +also be a regexp or list of keys to be matched against tags.
\r
186 +The default value set the unread tag to be red and the flagged
\r
187 +tag to have a star picture attached. Those are just examples so
\r
188 +you get an idea of what you can do.")
\r
190 +(defun notmuch-tagger-tag-format (tag)
\r
191 + "Format TAG as a `mode-line-format' template.
\r
193 +The format to apply to TAG is searched in
\r
194 +`notmuch-tagger-formats'. If not found, the default
\r
195 +`notmuch-tag-face' is used."
\r
196 + (let ((match (assoc tag notmuch-tagger-formats)))
\r
199 + `(:propertize ,tag face notmuch-tag-face))))
\r
201 +(defun notmuch-tagger-tags-format (tags)
\r
202 + "Format TAGS as a `mode-line-format' template."
\r
203 + (notmuch-intersperse
\r
204 + (remove nil (mapcar #'notmuch-tagger-tag-format tags))
\r
207 +(defun notmuch-tagger-present-tags (tags)
\r
208 + "Return a string that represent TAGS with their format."
\r
209 + (format-mode-line (notmuch-tagger-tags-format tags)))
\r
211 +(provide 'notmuch-tagger)
\r
212 +;;; notmuch-tagger.el ends here
\r
213 diff --git a/emacs/notmuch.el b/emacs/notmuch.el
\r
214 index c98a4fe..c607905 100644
\r
215 --- a/emacs/notmuch.el
\r
216 +++ b/emacs/notmuch.el
\r
217 @@ -797,9 +797,8 @@ non-authors is found, assume that all of the authors match."
\r
218 (notmuch-search-insert-authors format-string (plist-get result :authors)))
\r
220 ((string-equal field "tags")
\r
221 - (let ((tags-str (mapconcat 'identity (plist-get result :tags) " ")))
\r
222 - (insert (propertize (format format-string tags-str)
\r
223 - 'face 'notmuch-tag-face))))))
\r
224 + (let ((tags (plist-get result :tags)))
\r
225 + (insert (format format-string (notmuch-tagger-present-tags tags)))))))
\r
227 (defun notmuch-search-show-result (result &optional pos)
\r
228 "Insert RESULT at POS or the end of the buffer if POS is null."
\r