Re: [PATCH] emacs: wash: make word-wrap bound message width
[notmuch-archives.git] / dd / db69e9cde6e8dcf188589cc1d807e82bf4cf1b
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 2F5D6431FBC\r
6         for <notmuch@notmuchmail.org>; Sun, 22 Nov 2009 21:21:31 -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 b363J-i9C7WQ for <notmuch@notmuchmail.org>;\r
11         Sun, 22 Nov 2009 21:21:30 -0800 (PST)\r
12 Received: from e23smtp09.au.ibm.com (e23smtp09.au.ibm.com [202.81.31.142])\r
13         by olra.theworths.org (Postfix) with ESMTP id C0311431FAE\r
14         for <notmuch@notmuchmail.org>; Sun, 22 Nov 2009 21:21:29 -0800 (PST)\r
15 Received: from d23relay03.au.ibm.com (d23relay03.au.ibm.com [202.81.31.245])\r
16         by e23smtp09.au.ibm.com (8.14.3/8.13.1) with ESMTP id nANGLSZL004459\r
17         for <notmuch@notmuchmail.org>; Tue, 24 Nov 2009 03:21:28 +1100\r
18 Received: from d23av01.au.ibm.com (d23av01.au.ibm.com [9.190.234.96])\r
19         by d23relay03.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id\r
20         nAN5LRxk1429548\r
21         for <notmuch@notmuchmail.org>; Mon, 23 Nov 2009 16:21:27 +1100\r
22 Received: from d23av01.au.ibm.com (loopback [127.0.0.1])\r
23         by d23av01.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVout) with ESMTP id\r
24         nAN5LRBK000320\r
25         for <notmuch@notmuchmail.org>; Mon, 23 Nov 2009 16:21:27 +1100\r
26 Received: from localhost.localdomain (N20wks267599wss.in.ibm.com\r
27         [9.124.31.111] (may be forged))\r
28         by d23av01.au.ibm.com (8.14.3/8.13.1/NCO v10.0 AVin) with ESMTP id\r
29         nAN5LPrP032642; Mon, 23 Nov 2009 16:21:25 +1100\r
30 From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>\r
31 To: notmuch@notmuchmail.org\r
32 Date: Mon, 23 Nov 2009 10:51:20 +0530\r
33 Message-Id:\r
34  <1258953680-11605-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>\r
35 X-Mailer: git-send-email 1.6.5.2.74.g610f9\r
36 Subject: [notmuch] [PATCH -v3] notmuch.el: Add face support to search and\r
37         show mode\r
38 X-BeenThere: notmuch@notmuchmail.org\r
39 X-Mailman-Version: 2.1.12\r
40 Precedence: list\r
41 List-Id: "Use and development of the notmuch mail system."\r
42         <notmuch.notmuchmail.org>\r
43 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
44         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
45 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
46 List-Post: <mailto:notmuch@notmuchmail.org>\r
47 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
48 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
49         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
50 X-List-Received-Date: Mon, 23 Nov 2009 05:21:31 -0000\r
51 \r
52 This add two faces, notmuch-show-subject-face and\r
53 notmuch-tag-face. The first face is used to show the subject\r
54 line in the notmuch-show-mode and the second one to show tags\r
55 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) (background light)) (:foreground "goldenrod" :bold t))\r
61     (((class color) (background dark)) (:foreground "goldenrod" :bold t)))\r
62   "Notmuch search mode face used to highligh tags.")\r
63 \r
64 (defface notmuch-tag-inbox-face\r
65  '((((class color) (background light)) (:foreground "red" :bold t))\r
66     (((class color) (background dark)) (:foreground "red" :bold t)))\r
67   "Notmuch search mode face used to highligh tags.")\r
68 \r
69 (setq notmuch-tag-face-alist '(("unread" . 'notmuch-tag-unread-face)\r
70                                  ("inbox" . 'notmuch-tag-inbox-face)))\r
71 (require 'notmuch)\r
72 \r
73 Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>\r
74 ---\r
75  notmuch.el |   40 ++++++++++++++++++++++++++++++++++++++--\r
76  1 files changed, 38 insertions(+), 2 deletions(-)\r
77 \r
78 diff --git a/notmuch.el b/notmuch.el\r
79 index 1f24461..2aa6d5a 100644\r
80 --- a/notmuch.el\r
81 +++ b/notmuch.el\r
82 @@ -686,6 +686,18 @@ which this thread was originally shown."\r
83    (force-window-update)\r
84    (redisplay t))\r
85  \r
86 +(defface notmuch-show-subject-face\r
87 + '((((class color) (background light)) (:foreground "yellow" :bold t))\r
88 +    (((class color) (background dark)) (:foreground "yellow" :bold t)))\r
89 +  "Notmuch show mode face used to highligh subject line."\r
90 +  :group 'notmuch)\r
91 +\r
92 +(defvar notmuch-show-font-lock-keywords\r
93 +  (list ;; header in font-lock-type-face\r
94 +   (list "\\(Subject:.*$\\)"\r
95 +        '(1  'notmuch-show-subject-face)))\r
96 +  "Additonal expression to hightlight in notmuch-show-mode")\r
97 +\r
98  ;;;###autoload\r
99  (defun notmuch-show-mode ()\r
100    "Major mode for viewing a thread with notmuch.\r
101 @@ -726,7 +738,9 @@ view, (remove the \"inbox\" tag from each), with\r
102    (use-local-map notmuch-show-mode-map)\r
103    (setq major-mode 'notmuch-show-mode\r
104         mode-name "notmuch-show")\r
105 -  (setq buffer-read-only t))\r
106 +  (setq buffer-read-only t)\r
107 +  (set (make-local-variable 'font-lock-defaults)\r
108 +         '(notmuch-show-font-lock-keywords t)))\r
109  \r
110  ;;;###autoload\r
111  \r
112 @@ -855,6 +869,17 @@ thread from that buffer can be show when done with this one)."\r
113    (goto-char (point-max))\r
114    (forward-line -1))\r
115  \r
116 +(defface notmuch-tag-face\r
117 + '((((class color) (background light)) (:foreground "goldenrod" :bold t))\r
118 +    (((class color) (background dark)) (:foreground "goldenrod" :bold t)))\r
119 +  "Notmuch search mode face used to highligh tags."\r
120 +  :group 'notmuch)\r
121 +\r
122 +(defvar notmuch-tag-face-alist nil\r
123 +  "List containing the tag list that need to be highlighed")\r
124 +\r
125 +(defvar notmuch-search-font-lock-keywords  nil)\r
126 +\r
127  ;;;###autoload\r
128  (defun notmuch-search-mode ()\r
129    "Major mode for searching mail with notmuch.\r
130 @@ -885,7 +910,18 @@ global search.\r
131    (setq truncate-lines t)\r
132    (setq major-mode 'notmuch-search-mode\r
133         mode-name "notmuch-search")\r
134 -  (setq buffer-read-only t))\r
135 +  (setq buffer-read-only t)\r
136 +  (if (not notmuch-tag-face-alist)\r
137 +      (add-to-list 'notmuch-search-font-lock-keywords (list\r
138 +               "\\(([^)]*)$\\)" '(1  'notmuch-tag-face)))\r
139 +    (progn\r
140 +  (setq notmuch-search-tags (mapcar 'car notmuch-tag-face-alist))\r
141 +  (loop for notmuch-search-tag  in notmuch-search-tags\r
142 +    do (add-to-list 'notmuch-search-font-lock-keywords (list\r
143 +                               (concat "\\(" notmuch-search-tag "\\)")\r
144 +                   `(1  ,(cdr (assoc notmuch-search-tag notmuch-tag-face-alist))))))))\r
145 +  (set (make-local-variable 'font-lock-defaults)\r
146 +         '(notmuch-search-font-lock-keywords t)))\r
147  \r
148  (defun notmuch-search-find-thread-id ()\r
149    (save-excursion\r
150 -- \r
151 1.6.5.2.74.g610f9\r
152 \r