[notmuch] [PATCH 1/2] notmuch.el: convert sparse keymap to a list in notmuch-substitu...
[notmuch-archives.git] / 29 / aff82769261175a5b908b7a1dadee56254c714
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 1A469431FBF\r
6         for <notmuch@notmuchmail.org>; Tue, 24 Nov 2009 20:58:11 -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 hOHz6nH1n6cu for <notmuch@notmuchmail.org>;\r
11         Tue, 24 Nov 2009 20:58:10 -0800 (PST)\r
12 Received: from e23smtp08.au.ibm.com (e23smtp08.au.ibm.com [202.81.31.141])\r
13         by olra.theworths.org (Postfix) with ESMTP id A486A431FAE\r
14         for <notmuch@notmuchmail.org>; Tue, 24 Nov 2009 20:58:09 -0800 (PST)\r
15 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [202.81.31.245])\r
16         by e23smtp08.au.ibm.com (8.14.3/8.13.1) with ESMTP id nAPFw6Sr027971\r
17         for <notmuch@notmuchmail.org>; Thu, 26 Nov 2009 02:58:06 +1100\r
18 Received: from d23av02.au.ibm.com (d23av02.au.ibm.com [9.190.235.138])\r
19         by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id\r
20         nAP4w5Ci1777826\r
21         for <notmuch@notmuchmail.org>; Wed, 25 Nov 2009 15:58:05 +1100\r
22 Received: from d23av02.au.ibm.com (loopback [127.0.0.1])\r
23         by d23av02.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id\r
24         nAP4w5wO010412\r
25         for <notmuch@notmuchmail.org>; Wed, 25 Nov 2009 15:58:05 +1100\r
26 Received: from localhost.localdomain ([9.124.31.111])\r
27         by d23av02.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id\r
28         nAP4w25A010362; Wed, 25 Nov 2009 15:58:03 +1100\r
29 From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>\r
30 To: notmuch@notmuchmail.org\r
31 Date: Wed, 25 Nov 2009 10:28:00 +0530\r
32 Message-Id:\r
33  <1259125080-18708-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 Subject: [notmuch] [PATCH -v4] notmuch.el: Add face support to search and\r
36         show mode\r
37 X-BeenThere: notmuch@notmuchmail.org\r
38 X-Mailman-Version: 2.1.12\r
39 Precedence: list\r
40 List-Id: "Use and development of the notmuch mail system."\r
41         <notmuch.notmuchmail.org>\r
42 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
43         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
44 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
45 List-Post: <mailto:notmuch@notmuchmail.org>\r
46 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
47 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
48         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
49 X-List-Received-Date: Wed, 25 Nov 2009 04:58:11 -0000\r
50 \r
51 This add two faces, notmuch-show-subject-face and\r
52 notmuch-tag-face. The first face is used to show the subject\r
53 line in the notmuch-show-mode and the second one to show tags\r
54 in the notmuch-search-mode.\r
55 \r
56 We can selectively highlight each tag by setting notmuch-tag-face-alist as below\r
57 \r
58 (defface notmuch-tag-unread-face\r
59  '((((class color) (background light)) (:foreground "goldenrod" :bold t))\r
60     (((class color) (background dark)) (:foreground "goldenrod" :bold t)))\r
61   "Notmuch search mode face used to highligh tags.")\r
62 \r
63 (defface notmuch-tag-inbox-face\r
64  '((((class color) (background light)) (:foreground "red" :bold t))\r
65     (((class color) (background dark)) (:foreground "red" :bold t)))\r
66   "Notmuch search mode face used to highligh tags.")\r
67 \r
68 (setq notmuch-tag-face-alist '(("unread" . 'notmuch-tag-unread-face)\r
69                                  ("inbox" . 'notmuch-tag-inbox-face)))\r
70 (require 'notmuch)\r
71 \r
72 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>\r
73 ---\r
74  notmuch.el |   38 ++++++++++++++++++++++++++++++++++++--\r
75  1 files changed, 36 insertions(+), 2 deletions(-)\r
76 \r
77 diff --git a/notmuch.el b/notmuch.el\r
78 index 551048a..5737f77 100644\r
79 --- a/notmuch.el\r
80 +++ b/notmuch.el\r
81 @@ -663,6 +663,17 @@ which this thread was originally shown."\r
82        (notmuch-show-markup-message)))\r
83    (notmuch-show-hide-markers))\r
84  \r
85 +(defface notmuch-show-subject-face\r
86 + '((((class color)) (:foreground "red")))\r
87 +  "Notmuch show mode face used to highligh subject line."\r
88 +  :group 'notmuch)\r
89 +\r
90 +(defvar notmuch-show-font-lock-keywords\r
91 +  (list ;; header in font-lock-type-face\r
92 +   (list "\\(Subject:.*$\\)"\r
93 +        '(1  'notmuch-show-subject-face)))\r
94 +  "Additonal expression to hightlight in notmuch-show-mode")\r
95 +\r
96  ;;;###autoload\r
97  (defun notmuch-show-mode ()\r
98    "Major mode for viewing a thread with notmuch.\r
99 @@ -695,7 +706,9 @@ view, (remove the \"inbox\" tag from each), with\r
100    (use-local-map notmuch-show-mode-map)\r
101    (setq major-mode 'notmuch-show-mode\r
102         mode-name "notmuch-show")\r
103 -  (setq buffer-read-only t))\r
104 +  (setq buffer-read-only t)\r
105 +  (set (make-local-variable 'font-lock-defaults)\r
106 +         '(notmuch-show-font-lock-keywords t)))\r
107  \r
108  ;;;###autoload\r
109  \r
110 @@ -835,6 +848,16 @@ thread from that buffer can be show when done with this one)."\r
111    (goto-char (point-max))\r
112    (forward-line -1))\r
113  \r
114 +(defface notmuch-tag-face\r
115 + '((((class color)) (:foreground "red")))\r
116 +  "Notmuch search mode face used to highligh tags."\r
117 +  :group 'notmuch)\r
118 +\r
119 +(defvar notmuch-tag-face-alist nil\r
120 +  "List containing the tag list that need to be highlighed")\r
121 +\r
122 +(defvar notmuch-search-font-lock-keywords  nil)\r
123 +\r
124  ;;;###autoload\r
125  (defun notmuch-search-mode ()\r
126    "Major mode for searching mail with notmuch.\r
127 @@ -865,7 +888,18 @@ global search.\r
128    (setq truncate-lines t)\r
129    (setq major-mode 'notmuch-search-mode\r
130         mode-name "notmuch-search")\r
131 -  (setq buffer-read-only t))\r
132 +  (setq buffer-read-only t)\r
133 +  (if (not notmuch-tag-face-alist)\r
134 +      (add-to-list 'notmuch-search-font-lock-keywords (list\r
135 +               "\\(([^)]*)$\\)" '(1  'notmuch-tag-face)))\r
136 +    (progn\r
137 +  (setq notmuch-search-tags (mapcar 'car notmuch-tag-face-alist))\r
138 +  (loop for notmuch-search-tag  in notmuch-search-tags\r
139 +    do (add-to-list 'notmuch-search-font-lock-keywords (list\r
140 +                               (concat "\\(" notmuch-search-tag "\\)")\r
141 +                   `(1  ,(cdr (assoc notmuch-search-tag notmuch-tag-face-alist))))))))\r
142 +  (set (make-local-variable 'font-lock-defaults)\r
143 +         '(notmuch-search-font-lock-keywords t)))\r
144  \r
145  (defun notmuch-search-find-thread-id ()\r
146    "Return the thread for the current thread"\r
147 -- \r
148 1.6.5.2.74.g610f9\r
149 \r