[notmuch] [PATCH -v6] notmuch.el: Add face support to search mode
[notmuch-archives.git] / 65 / 1e53f4cfe21815eabdb1452f1ad6c374d3fec9
1 Return-Path: <aneesh.kumar@linux.vnet.ibm.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 3F040431FC0\r
6         for <notmuch@notmuchmail.org>; Fri, 27 Nov 2009 22:07:16 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 Received: from olra.theworths.org ([127.0.0.1])\r
9         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
10         with ESMTP id TUT2j5Trw+Hm for <notmuch@notmuchmail.org>;\r
11         Fri, 27 Nov 2009 22:07:15 -0800 (PST)\r
12 Received: from e23smtp07.au.ibm.com (e23smtp07.au.ibm.com [202.81.31.140])\r
13         by olra.theworths.org (Postfix) with ESMTP id D7812431FAE\r
14         for <notmuch@notmuchmail.org>; Fri, 27 Nov 2009 22:07:14 -0800 (PST)\r
15 Received: from d23relay04.au.ibm.com (d23relay04.au.ibm.com [202.81.31.246])\r
16         by e23smtp07.au.ibm.com (8.14.3/8.13.1) with ESMTP id nAS67DeS018249\r
17         for <notmuch@notmuchmail.org>; Sat, 28 Nov 2009 17:07:13 +1100\r
18 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139])\r
19         by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id\r
20         nAS63haA1634478\r
21         for <notmuch@notmuchmail.org>; Sat, 28 Nov 2009 17:03:43 +1100\r
22 Received: from d23av04.au.ibm.com (loopback [127.0.0.1])\r
23         by d23av04.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id\r
24         nAS67C2v028104\r
25         for <notmuch@notmuchmail.org>; Sat, 28 Nov 2009 17:07:13 +1100\r
26 Received: from localhost.localdomain ([9.77.123.164])\r
27         by d23av04.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id\r
28         nAS67AWi028095; Sat, 28 Nov 2009 17:07:11 +1100\r
29 From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>\r
30 To: cworth@cworth.org\r
31 Date: Sat, 28 Nov 2009 11:37:05 +0530\r
32 Message-Id:\r
33  <1259388425-32510-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>\r
34 X-Mailer: git-send-email 1.6.5.2.74.g610f9\r
35 In-Reply-To:\r
36  <1259311332-14557-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>\r
37 References:\r
38  <1259311332-14557-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>\r
39 Cc: notmuch@notmuchmail.org\r
40 Subject: [notmuch] [PATCH -v6] notmuch.el: Add face support to search mode\r
41 X-BeenThere: notmuch@notmuchmail.org\r
42 X-Mailman-Version: 2.1.12\r
43 Precedence: list\r
44 List-Id: "Use and development of the notmuch mail system."\r
45         <notmuch.notmuchmail.org>\r
46 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
47         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
48 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
49 List-Post: <mailto:notmuch@notmuchmail.org>\r
50 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
51 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
52         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
53 X-List-Received-Date: Sat, 28 Nov 2009 06:07:16 -0000\r
54 \r
55 This patch use notmuch-tag-face showing tags in the notmuch-search-mode.\r
56 \r
57 We can selectively highlight each tag by setting notmuch-tag-face-alist as below\r
58 \r
59 (defface notmuch-tag-unread-face\r
60  '((((class color)) (:foreground "goldenrod")))\r
61   "Notmuch search mode face used to highligh tags.")\r
62 \r
63 (defface notmuch-tag-inbox-face\r
64  '((((class color)) (:foreground "red")))\r
65   "Notmuch search mode face used to highligh tags.")\r
66 \r
67 (setq notmuch-tag-face-alist '(("unread" . 'notmuch-tag-unread-face)\r
68                                ("inbox" . 'notmuch-tag-inbox-face)))\r
69 (require 'notmuch)\r
70 \r
71 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>\r
72 ---\r
73  notmuch.el |   30 +++++++++++++++++++++++++++++-\r
74  1 files changed, 29 insertions(+), 1 deletions(-)\r
75 \r
76 diff --git a/notmuch.el b/notmuch.el\r
77 index e9786c0..5cbfedf 100644\r
78 --- a/notmuch.el\r
79 +++ b/notmuch.el\r
80 @@ -846,6 +846,23 @@ thread from that buffer can be show when done with this one)."\r
81    (goto-char (point-max))\r
82    (forward-line -1))\r
83  \r
84 +(defface notmuch-tag-face\r
85 +  '((((class color)\r
86 +      (background dark))\r
87 +     (:foreground "OliveDrab1"))\r
88 +    (((class color)\r
89 +      (background light))\r
90 +     (:foreground "navy blue" :bold t))\r
91 +    (t\r
92 +     (:bold t)))\r
93 +  "Notmuch search mode face used to highligh tags."\r
94 +  :group 'notmuch)\r
95 +\r
96 +(defvar notmuch-tag-face-alist nil\r
97 +  "List containing the tag list that need to be highlighed")\r
98 +\r
99 +(defvar notmuch-search-font-lock-keywords  nil)\r
100 +\r
101  ;;;###autoload\r
102  (defun notmuch-search-mode ()\r
103    "Major mode for searching mail with notmuch.\r
104 @@ -876,7 +893,18 @@ global search.\r
105    (setq truncate-lines t)\r
106    (setq major-mode 'notmuch-search-mode\r
107         mode-name "notmuch-search")\r
108 -  (setq buffer-read-only t))\r
109 +  (setq buffer-read-only t)\r
110 +  (if (not notmuch-tag-face-alist)\r
111 +      (add-to-list 'notmuch-search-font-lock-keywords (list\r
112 +               "(\\([^)]*\\))$" '(1  'notmuch-tag-face)))\r
113 +    (progn\r
114 +  (setq notmuch-search-tags (mapcar 'car notmuch-tag-face-alist))\r
115 +  (loop for notmuch-search-tag  in notmuch-search-tags\r
116 +    do (add-to-list 'notmuch-search-font-lock-keywords (list\r
117 +                               (concat "([^)]*\\(" notmuch-search-tag "\\)[^)]*)$")\r
118 +                   `(1  ,(cdr (assoc notmuch-search-tag notmuch-tag-face-alist))))))))\r
119 +  (set (make-local-variable 'font-lock-defaults)\r
120 +         '(notmuch-search-font-lock-keywords t)))\r
121  \r
122  (defun notmuch-search-find-thread-id ()\r
123    "Return the thread for the current thread"\r
124 -- \r
125 1.6.5.2.74.g610f9\r
126 \r