unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH -v4] notmuch.el: Add face support to search and show mode
@ 2009-11-25  4:58 Aneesh Kumar K.V
  2009-11-25  5:24 ` Alexander Botero-Lowry
  2009-11-27  8:42 ` [PATCH -v5] notmuch.el: Add face support to search mode Aneesh Kumar K.V
  0 siblings, 2 replies; 11+ messages in thread
From: Aneesh Kumar K.V @ 2009-11-25  4:58 UTC (permalink / raw)
  To: notmuch

This add two faces, notmuch-show-subject-face and
notmuch-tag-face. The first face is used to show the subject
line in the notmuch-show-mode and the second one to show tags
in the notmuch-search-mode.

We can selectively highlight each tag by setting notmuch-tag-face-alist as below

(defface notmuch-tag-unread-face
 '((((class color) (background light)) (:foreground "goldenrod" :bold t))
    (((class color) (background dark)) (:foreground "goldenrod" :bold t)))
  "Notmuch search mode face used to highligh tags.")

(defface notmuch-tag-inbox-face
 '((((class color) (background light)) (:foreground "red" :bold t))
    (((class color) (background dark)) (:foreground "red" :bold t)))
  "Notmuch search mode face used to highligh tags.")

(setq notmuch-tag-face-alist '(("unread" . 'notmuch-tag-unread-face)
				 ("inbox" . 'notmuch-tag-inbox-face)))
(require 'notmuch)

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 notmuch.el |   38 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 551048a..5737f77 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -663,6 +663,17 @@ which this thread was originally shown."
       (notmuch-show-markup-message)))
   (notmuch-show-hide-markers))
 
+(defface notmuch-show-subject-face
+ '((((class color)) (:foreground "red")))
+  "Notmuch show mode face used to highligh subject line."
+  :group 'notmuch)
+
+(defvar notmuch-show-font-lock-keywords
+  (list ;; header in font-lock-type-face
+   (list "\\(Subject:.*$\\)"
+	 '(1  'notmuch-show-subject-face)))
+  "Additonal expression to hightlight in notmuch-show-mode")
+
 ;;;###autoload
 (defun notmuch-show-mode ()
   "Major mode for viewing a thread with notmuch.
@@ -695,7 +706,9 @@ view, (remove the \"inbox\" tag from each), with
   (use-local-map notmuch-show-mode-map)
   (setq major-mode 'notmuch-show-mode
 	mode-name "notmuch-show")
-  (setq buffer-read-only t))
+  (setq buffer-read-only t)
+  (set (make-local-variable 'font-lock-defaults)
+         '(notmuch-show-font-lock-keywords t)))
 
 ;;;###autoload
 
@@ -835,6 +848,16 @@ thread from that buffer can be show when done with this one)."
   (goto-char (point-max))
   (forward-line -1))
 
+(defface notmuch-tag-face
+ '((((class color)) (:foreground "red")))
+  "Notmuch search mode face used to highligh tags."
+  :group 'notmuch)
+
+(defvar notmuch-tag-face-alist nil
+  "List containing the tag list that need to be highlighed")
+
+(defvar notmuch-search-font-lock-keywords  nil)
+
 ;;;###autoload
 (defun notmuch-search-mode ()
   "Major mode for searching mail with notmuch.
@@ -865,7 +888,18 @@ global search.
   (setq truncate-lines t)
   (setq major-mode 'notmuch-search-mode
 	mode-name "notmuch-search")
-  (setq buffer-read-only t))
+  (setq buffer-read-only t)
+  (if (not notmuch-tag-face-alist)
+      (add-to-list 'notmuch-search-font-lock-keywords (list
+		"\\(([^)]*)$\\)" '(1  'notmuch-tag-face)))
+    (progn
+  (setq notmuch-search-tags (mapcar 'car notmuch-tag-face-alist))
+  (loop for notmuch-search-tag  in notmuch-search-tags
+    do (add-to-list 'notmuch-search-font-lock-keywords (list
+				(concat "\\(" notmuch-search-tag "\\)")
+		    `(1  ,(cdr (assoc notmuch-search-tag notmuch-tag-face-alist))))))))
+  (set (make-local-variable 'font-lock-defaults)
+         '(notmuch-search-font-lock-keywords t)))
 
 (defun notmuch-search-find-thread-id ()
   "Return the thread for the current thread"
-- 
1.6.5.2.74.g610f9

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH -v4] notmuch.el: Add face support to search and show mode
  2009-11-25  4:58 [PATCH -v4] notmuch.el: Add face support to search and show mode Aneesh Kumar K.V
@ 2009-11-25  5:24 ` Alexander Botero-Lowry
  2009-11-25 14:33   ` Jeffrey Ollie
  2009-11-25 15:47   ` Aneesh Kumar K. V
  2009-11-27  8:42 ` [PATCH -v5] notmuch.el: Add face support to search mode Aneesh Kumar K.V
  1 sibling, 2 replies; 11+ messages in thread
From: Alexander Botero-Lowry @ 2009-11-25  5:24 UTC (permalink / raw)
  To: Aneesh Kumar K.V, notmuch

On Wed, 25 Nov 2009 10:28:00 +0530, "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:
> This add two faces, notmuch-show-subject-face and
> notmuch-tag-face. The first face is used to show the subject
> line in the notmuch-show-mode and the second one to show tags
> in the notmuch-search-mode.
> 
First, I definetly think fontification is the way to go instead of
the adhoc/crappy way that cworth and I have been doing this in the
past.

[snip]

> +(defvar notmuch-show-font-lock-keywords
> +  (list ;; header in font-lock-type-face
> +   (list "\\(Subject:.*$\\)"
> +	 '(1  'notmuch-show-subject-face)))
> +  "Additonal expression to hightlight in notmuch-show-mode")
> +
So what happens if I have Subject: xxxx in my message? We already ran
into a problem where a patch sent the list that included notmuch control
character caused it to go into an infinite loop, I'd prefer our
fontification code be a bit more resilient. At the very least this
should use the font-lock syntax tables stuff to only do header
fontification when inside the header block. This would probably require
that fontification occur before the message is post-processed by 
notmuch-show to remove the section markers etc.

Also +1 for more subduded colors than red. :) Possibly consider copying
the message-mode colors, so that there is a bit of consistency between
sending and viewing mail? Might even be able to steal the message-mode
faces by importing their symbols.

[snip]

>  (defun notmuch-search-mode ()
>    "Major mode for searching mail with notmuch.
> @@ -865,7 +888,18 @@ global search.
>    (setq truncate-lines t)
>    (setq major-mode 'notmuch-search-mode
>  	mode-name "notmuch-search")
> -  (setq buffer-read-only t))
> +  (setq buffer-read-only t)
> +  (if (not notmuch-tag-face-alist)
> +      (add-to-list 'notmuch-search-font-lock-keywords (list
> +		"\\(([^)]*)$\\)" '(1  'notmuch-tag-face)))
This way of detecting the tags seems ok, but I think it would be nicer
if it could be done even more deterministically. :) One idea that be
neat is to have a --format=sexp for notmuch search, which exports sexps
(probably alists, but could be some other format) for the search results
that can just be eval'd and processed in a cleaner way (and would also
make for nicer APIs in emacs for querying notmuch itself). Actually I
really like the idea of a sexp output mode for show too, instead of the
markers.... *plots*

> +    (progn
> +  (setq notmuch-search-tags (mapcar 'car notmuch-tag-face-alist))
> +  (loop for notmuch-search-tag  in notmuch-search-tags
> +    do (add-to-list 'notmuch-search-font-lock-keywords (list
> +				(concat "\\(" notmuch-search-tag "\\)")
> +		    `(1  ,(cdr (assoc notmuch-search-tag notmuch-tag-face-alist))))))))
> +  (set (make-local-variable 'font-lock-defaults)
> +         '(notmuch-search-font-lock-keywords t)))
>  
I don't really see the point of fontifying all tags the same way if no
tag-faces have been set, especially if none of the rest of the search
results are fontified.

Alex

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH -v4] notmuch.el: Add face support to search and show mode
  2009-11-25  5:24 ` Alexander Botero-Lowry
@ 2009-11-25 14:33   ` Jeffrey Ollie
  2009-11-25 15:32     ` Bart Trojanowski
  2009-11-25 15:47   ` Aneesh Kumar K. V
  1 sibling, 1 reply; 11+ messages in thread
From: Jeffrey Ollie @ 2009-11-25 14:33 UTC (permalink / raw)
  To: Alexander Botero-Lowry; +Cc: notmuch

On Tue, Nov 24, 2009 at 11:24 PM, Alexander Botero-Lowry
<alex.boterolowry@gmail.com> wrote:
>
> This way of detecting the tags seems ok, but I think it would be nicer
> if it could be done even more deterministically. :) One idea that be
> neat is to have a --format=sexp for notmuch search, which exports sexps
> (probably alists, but could be some other format) for the search results
> that can just be eval'd and processed in a cleaner way (and would also
> make for nicer APIs in emacs for querying notmuch itself). Actually I
> really like the idea of a sexp output mode for show too, instead of the
> markers.... *plots*

Along the same lines, I was thinking that it would be nice to be able
to get output formatted in JSON as well for possible use in a web
front-end.  Actually, it looks like Emacs has support for JSON as
well[1].  Not sure what release it was introduced in, but I see that
it's in 23.1.

http://edward.oconnor.cx/2006/03/json.el

-- 
Jeff Ollie

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH -v4] notmuch.el: Add face support to search and show mode
  2009-11-25 14:33   ` Jeffrey Ollie
@ 2009-11-25 15:32     ` Bart Trojanowski
  0 siblings, 0 replies; 11+ messages in thread
From: Bart Trojanowski @ 2009-11-25 15:32 UTC (permalink / raw)
  To: Jeffrey Ollie; +Cc: notmuch

* Jeffrey Ollie <jeff@ocjtech.us> [091125 09:33]:
> On Tue, Nov 24, 2009 at 11:24 PM, Alexander Botero-Lowry
> <alex.boterolowry@gmail.com> wrote:
> >
> > This way of detecting the tags seems ok, but I think it would be nicer
> > if it could be done even more deterministically. :) One idea that be
> > neat is to have a --format=sexp for notmuch search, which exports sexps
> > (probably alists, but could be some other format) for the search results
> > that can just be eval'd and processed in a cleaner way (and would also
> > make for nicer APIs in emacs for querying notmuch itself). Actually I
> > really like the idea of a sexp output mode for show too, instead of the
> > markers.... *plots*
> 
> Along the same lines, I was thinking that it would be nice to be able
> to get output formatted in JSON as well for possible use in a web
> front-end.  Actually, it looks like Emacs has support for JSON as
> well[1].  Not sure what release it was introduced in, but I see that
> it's in 23.1.
> 
> http://edward.oconnor.cx/2006/03/json.el

Would it be possible to make templates for output?

notmuch show --format=json would have notmuch follow rules from
.notmuch/json.template (or somesuch)

-Bart

-- 
				WebSig: http://www.jukie.net/~bart/sig/

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH -v4] notmuch.el: Add face support to search and show mode
  2009-11-25  5:24 ` Alexander Botero-Lowry
  2009-11-25 14:33   ` Jeffrey Ollie
@ 2009-11-25 15:47   ` Aneesh Kumar K. V
  1 sibling, 0 replies; 11+ messages in thread
From: Aneesh Kumar K. V @ 2009-11-25 15:47 UTC (permalink / raw)
  To: Alexander Botero-Lowry, notmuch

On Tue, 24 Nov 2009 21:24:07 -0800, Alexander Botero-Lowry <alex.boterolowry@gmail.com> wrote:
> On Wed, 25 Nov 2009 10:28:00 +0530, "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:
> > This add two faces, notmuch-show-subject-face and
> > notmuch-tag-face. The first face is used to show the subject
> > line in the notmuch-show-mode and the second one to show tags
> > in the notmuch-search-mode.
> > 
> First, I definetly think fontification is the way to go instead of
> the adhoc/crappy way that cworth and I have been doing this in the
> past.
> 
> [snip]
> 
> > +(defvar notmuch-show-font-lock-keywords
> > +  (list ;; header in font-lock-type-face
> > +   (list "\\(Subject:.*$\\)"
> > +	 '(1  'notmuch-show-subject-face)))
> > +  "Additonal expression to hightlight in notmuch-show-mode")
> > +
> So what happens if I have Subject: xxxx in my message?

It will highlight them too. I initially tried to highlight it only
in the header fields. But then my elisp is not good to find out
how to do it for the full message. That is we need to search the
header area of each message and highlight specific fields. And all
the message fall in the same buffer. 


> We already ran
> into a problem where a patch sent the list that included notmuch control
> character caused it to go into an infinite loop, I'd prefer our
> fontification code be a bit more resilient. At the very least this
> should use the font-lock syntax tables stuff to only do header
> fontification when inside the header block. This would probably require
> that fontification occur before the message is post-processed by 
> notmuch-show to remove the section markers etc.

Highlighting specific part of the email should not get any trouble
like infinite loop. Unless somebody figure out how to make elisp 
highlight specific area, it would be nice to have the patch applied.
I really found it to help me when reading mails.


> 
> Also +1 for more subduded colors than red. :) Possibly consider copying
> the message-mode colors, so that there is a bit of consistency between
> sending and viewing mail? Might even be able to steal the message-mode
> faces by importing their symbols.
> 

I use yellow with black background. It is difficult to find a color that
everybody likes. Infact once of the reason the patch was not applied
till now was yellow may the subject line not readable. So i went for
read which kind of looked fine with white background.



> [snip]
> 
> >  (defun notmuch-search-mode ()
> >    "Major mode for searching mail with notmuch.
> > @@ -865,7 +888,18 @@ global search.
> >    (setq truncate-lines t)
> >    (setq major-mode 'notmuch-search-mode
> >  	mode-name "notmuch-search")
> > -  (setq buffer-read-only t))
> > +  (setq buffer-read-only t)
> > +  (if (not notmuch-tag-face-alist)
> > +      (add-to-list 'notmuch-search-font-lock-keywords (list
> > +		"\\(([^)]*)$\\)" '(1  'notmuch-tag-face)))
> This way of detecting the tags seems ok, but I think it would be nicer
> if it could be done even more deterministically. :) One idea that be
> neat is to have a --format=sexp for notmuch search, which exports sexps
> (probably alists, but could be some other format) for the search results
> that can just be eval'd and processed in a cleaner way (and would also
> make for nicer APIs in emacs for querying notmuch itself). Actually I
> really like the idea of a sexp output mode for show too, instead of the
> markers.... *plots*
> 
> > +    (progn
> > +  (setq notmuch-search-tags (mapcar 'car notmuch-tag-face-alist))
> > +  (loop for notmuch-search-tag  in notmuch-search-tags
> > +    do (add-to-list 'notmuch-search-font-lock-keywords (list
> > +				(concat "\\(" notmuch-search-tag "\\)")
> > +		    `(1  ,(cdr (assoc notmuch-search-tag notmuch-tag-face-alist))))))))
> > +  (set (make-local-variable 'font-lock-defaults)
> > +         '(notmuch-search-font-lock-keywords t)))
> >  
> I don't really see the point of fontifying all tags the same way if no
> tag-faces have been set, especially if none of the rest of the search
> results are fontified.

This was done as per Carl's request. The idea was to make tags stand out
from rest of the subject. 

-aneesh

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH -v5] notmuch.el: Add face support to search mode
  2009-11-25  4:58 [PATCH -v4] notmuch.el: Add face support to search and show mode Aneesh Kumar K.V
  2009-11-25  5:24 ` Alexander Botero-Lowry
@ 2009-11-27  8:42 ` Aneesh Kumar K.V
  2009-11-27  8:42   ` [PATCH -v5] notmuch.el: Use message-mode font-face to highlight mail headers Aneesh Kumar K.V
  2009-11-28  6:07   ` [PATCH -v6] notmuch.el: Add face support to search mode Aneesh Kumar K.V
  1 sibling, 2 replies; 11+ messages in thread
From: Aneesh Kumar K.V @ 2009-11-27  8:42 UTC (permalink / raw)
  To: notmuch

This patch use notmuch-tag-face showing tags in the notmuch-search-mode.

We can selectively highlight each tag by setting notmuch-tag-face-alist as below

(defface notmuch-tag-unread-face
 '((((class color)) (:foreground "goldenrod")))
  "Notmuch search mode face used to highligh tags.")

(defface notmuch-tag-inbox-face
 '((((class color)) (:foreground "red")))
  "Notmuch search mode face used to highligh tags.")

(setq notmuch-tag-face-alist '(("unread" . 'notmuch-tag-unread-face)
			       ("inbox" . 'notmuch-tag-inbox-face)))
(require 'notmuch)

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 notmuch.el |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 551048a..4dc5a06 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -835,6 +835,16 @@ thread from that buffer can be show when done with this one)."
   (goto-char (point-max))
   (forward-line -1))
 
+(defface notmuch-tag-face
+ '((((class color)) (:foreground "red")))
+  "Notmuch search mode face used to highligh tags."
+  :group 'notmuch)
+
+(defvar notmuch-tag-face-alist nil
+  "List containing the tag list that need to be highlighed")
+
+(defvar notmuch-search-font-lock-keywords  nil)
+
 ;;;###autoload
 (defun notmuch-search-mode ()
   "Major mode for searching mail with notmuch.
@@ -865,7 +875,18 @@ global search.
   (setq truncate-lines t)
   (setq major-mode 'notmuch-search-mode
 	mode-name "notmuch-search")
-  (setq buffer-read-only t))
+  (setq buffer-read-only t)
+  (if (not notmuch-tag-face-alist)
+      (add-to-list 'notmuch-search-font-lock-keywords (list
+		"\\(([^)]*)$\\)" '(1  'notmuch-tag-face)))
+    (progn
+  (setq notmuch-search-tags (mapcar 'car notmuch-tag-face-alist))
+  (loop for notmuch-search-tag  in notmuch-search-tags
+    do (add-to-list 'notmuch-search-font-lock-keywords (list
+				(concat "\\(" notmuch-search-tag "\\)")
+		    `(1  ,(cdr (assoc notmuch-search-tag notmuch-tag-face-alist))))))))
+  (set (make-local-variable 'font-lock-defaults)
+         '(notmuch-search-font-lock-keywords t)))
 
 (defun notmuch-search-find-thread-id ()
   "Return the thread for the current thread"
-- 
1.6.5.2.74.g610f9

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH -v5] notmuch.el: Use message-mode font-face to highlight mail headers
  2009-11-27  8:42 ` [PATCH -v5] notmuch.el: Add face support to search mode Aneesh Kumar K.V
@ 2009-11-27  8:42   ` Aneesh Kumar K.V
  2009-11-27 10:14     ` [PATCH -v6] " Aneesh Kumar K.V
  2009-11-28  6:07   ` [PATCH -v6] notmuch.el: Add face support to search mode Aneesh Kumar K.V
  1 sibling, 1 reply; 11+ messages in thread
From: Aneesh Kumar K.V @ 2009-11-27  8:42 UTC (permalink / raw)
  To: notmuch

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 notmuch.el |   35 +++++++++++++++++++++++++++++++++--
 1 files changed, 33 insertions(+), 2 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 89ccef6..851c60c 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -595,6 +595,38 @@ which this thread was originally shown."
       (set-marker beg nil)
       (set-marker end nil)
       )))
+(defun notmuch-fontify-headers ()
+  (progn
+    (if (looking-at "[Tt]o:")
+	(progn
+	  (overlay-put (make-overlay (point) (re-search-forward ":"))
+                       'face 'message-header-name)
+          (overlay-put (make-overlay (point) (re-search-forward ".*$"))
+                       'face 'message-header-to)))
+    (beginning-of-line)
+    (if (looking-at "[B]?[Cc][Cc]:")
+	(progn
+	  (overlay-put (make-overlay (point) (re-search-forward ":"))
+                       'face 'message-header-name)
+          (overlay-put (make-overlay (point) (re-search-forward ".*$"))
+                       'face 'message-header-cc)))
+    (beginning-of-line)
+    (if (looking-at "[Ss]ubject:")
+	(progn
+	  (overlay-put (make-overlay (point) (re-search-forward ":"))
+                       'face 'message-header-name)
+          (overlay-put (make-overlay (point) (re-search-forward ".*$"))
+                       'face 'message-header-subject)))
+    (beginning-of-line)
+    (if (looking-at "[Ff]rom:")
+	(progn
+	  (overlay-put (make-overlay (point) (re-search-forward ":"))
+                       'face 'message-header-name)
+          (overlay-put (make-overlay (point) (re-search-forward ".*$"))
+                       'face 'message-header-other)))
+    (beginning-of-line)
+
+))
 
 (defun notmuch-show-markup-header (depth)
   (re-search-forward notmuch-show-header-begin-regexp)
@@ -615,8 +647,7 @@ which this thread was originally shown."
         (forward-line)
         (while (looking-at "[A-Za-z][-A-Za-z0-9]*:")
           (beginning-of-line)
-          (overlay-put (make-overlay (point) (re-search-forward ":"))
-                       'face 'bold)
+	  (notmuch-fontify-headers)
           (forward-line)
           )
 	(indent-rigidly beg end depth)
-- 
1.6.5.2.74.g610f9

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH -v6] notmuch.el: Use message-mode font-face to highlight mail headers
  2009-11-27  8:42   ` [PATCH -v5] notmuch.el: Use message-mode font-face to highlight mail headers Aneesh Kumar K.V
@ 2009-11-27 10:14     ` Aneesh Kumar K.V
  2009-11-28  5:02       ` Carl Worth
  0 siblings, 1 reply; 11+ messages in thread
From: Aneesh Kumar K.V @ 2009-11-27 10:14 UTC (permalink / raw)
  To: notmuch

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 notmuch.el |   29 +++++++++++++++++++++++++++--
 1 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index d2ebb40..b089732 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -604,6 +604,32 @@ which this thread was originally shown."
       (set-marker beg nil)
       (set-marker end nil)
       )))
+(defun notmuch-fontify-headers ()
+  (progn
+    (if (looking-at "[Tt]o:")
+	(progn
+	  (overlay-put (make-overlay (point) (re-search-forward ":"))
+                       'face 'message-header-name)
+          (overlay-put (make-overlay (point) (re-search-forward ".*$"))
+                       'face 'message-header-to))
+    (if (looking-at "[B]?[Cc][Cc]:")
+	(progn
+	  (overlay-put (make-overlay (point) (re-search-forward ":"))
+                       'face 'message-header-name)
+          (overlay-put (make-overlay (point) (re-search-forward ".*$"))
+                       'face 'message-header-cc))
+    (if (looking-at "[Ss]ubject:")
+	(progn
+	  (overlay-put (make-overlay (point) (re-search-forward ":"))
+                       'face 'message-header-name)
+          (overlay-put (make-overlay (point) (re-search-forward ".*$"))
+                       'face 'message-header-subject))
+    (if (looking-at "[Ff]rom:")
+	(progn
+	  (overlay-put (make-overlay (point) (re-search-forward ":"))
+                       'face 'message-header-name)
+          (overlay-put (make-overlay (point) (re-search-forward ".*$"))
+                       'face 'message-header-other))))))))
 
 (defun notmuch-show-markup-header (depth)
   (re-search-forward notmuch-show-header-begin-regexp)
@@ -624,8 +650,7 @@ which this thread was originally shown."
         (forward-line)
         (while (looking-at "[A-Za-z][-A-Za-z0-9]*:")
           (beginning-of-line)
-          (overlay-put (make-overlay (point) (re-search-forward ":"))
-                       'face 'bold)
+	  (notmuch-fontify-headers)
           (forward-line)
           )
 	(indent-rigidly beg end depth)
-- 
1.6.5.2.74.g610f9

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH -v6] notmuch.el: Use message-mode font-face to highlight mail headers
  2009-11-27 10:14     ` [PATCH -v6] " Aneesh Kumar K.V
@ 2009-11-28  5:02       ` Carl Worth
  0 siblings, 0 replies; 11+ messages in thread
From: Carl Worth @ 2009-11-28  5:02 UTC (permalink / raw)
  To: Aneesh Kumar K.V, notmuch

[-- Attachment #1: Type: text/plain, Size: 922 bytes --]

On Fri, 27 Nov 2009 15:44:13 +0530, "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:
> Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>

Thanks for this patch, Aneesh. Deferring to existing message-mode faces
gets us out of the business of having to invent colors, and also means
user will only have to tweak the customization in one place to change
both composition and presentation of mail messages.

So I've pushed this out now.

This change does make a couple of other needed changes for our
presentation seem more urgent:

  1. We need to drop the reverse-video for the message summary line,
     (this was a standin for real face configuration which we have now).

  2. We need to figure out how to lose the underlining of the full-line
     buttons for the message-summary line and the subject line.

Anyway, thanks for the patch, and your patient submission of 6 versions
of it!

-Carl

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH -v6] notmuch.el: Add face support to search mode
  2009-11-27  8:42 ` [PATCH -v5] notmuch.el: Add face support to search mode Aneesh Kumar K.V
  2009-11-27  8:42   ` [PATCH -v5] notmuch.el: Use message-mode font-face to highlight mail headers Aneesh Kumar K.V
@ 2009-11-28  6:07   ` Aneesh Kumar K.V
  2009-11-28  6:56     ` Carl Worth
  1 sibling, 1 reply; 11+ messages in thread
From: Aneesh Kumar K.V @ 2009-11-28  6:07 UTC (permalink / raw)
  To: cworth; +Cc: notmuch

This patch use notmuch-tag-face showing tags in the notmuch-search-mode.

We can selectively highlight each tag by setting notmuch-tag-face-alist as below

(defface notmuch-tag-unread-face
 '((((class color)) (:foreground "goldenrod")))
  "Notmuch search mode face used to highligh tags.")

(defface notmuch-tag-inbox-face
 '((((class color)) (:foreground "red")))
  "Notmuch search mode face used to highligh tags.")

(setq notmuch-tag-face-alist '(("unread" . 'notmuch-tag-unread-face)
			       ("inbox" . 'notmuch-tag-inbox-face)))
(require 'notmuch)

Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 notmuch.el |   30 +++++++++++++++++++++++++++++-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index e9786c0..5cbfedf 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -846,6 +846,23 @@ thread from that buffer can be show when done with this one)."
   (goto-char (point-max))
   (forward-line -1))
 
+(defface notmuch-tag-face
+  '((((class color)
+      (background dark))
+     (:foreground "OliveDrab1"))
+    (((class color)
+      (background light))
+     (:foreground "navy blue" :bold t))
+    (t
+     (:bold t)))
+  "Notmuch search mode face used to highligh tags."
+  :group 'notmuch)
+
+(defvar notmuch-tag-face-alist nil
+  "List containing the tag list that need to be highlighed")
+
+(defvar notmuch-search-font-lock-keywords  nil)
+
 ;;;###autoload
 (defun notmuch-search-mode ()
   "Major mode for searching mail with notmuch.
@@ -876,7 +893,18 @@ global search.
   (setq truncate-lines t)
   (setq major-mode 'notmuch-search-mode
 	mode-name "notmuch-search")
-  (setq buffer-read-only t))
+  (setq buffer-read-only t)
+  (if (not notmuch-tag-face-alist)
+      (add-to-list 'notmuch-search-font-lock-keywords (list
+		"(\\([^)]*\\))$" '(1  'notmuch-tag-face)))
+    (progn
+  (setq notmuch-search-tags (mapcar 'car notmuch-tag-face-alist))
+  (loop for notmuch-search-tag  in notmuch-search-tags
+    do (add-to-list 'notmuch-search-font-lock-keywords (list
+				(concat "([^)]*\\(" notmuch-search-tag "\\)[^)]*)$")
+		    `(1  ,(cdr (assoc notmuch-search-tag notmuch-tag-face-alist))))))))
+  (set (make-local-variable 'font-lock-defaults)
+         '(notmuch-search-font-lock-keywords t)))
 
 (defun notmuch-search-find-thread-id ()
   "Return the thread for the current thread"
-- 
1.6.5.2.74.g610f9

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH -v6] notmuch.el: Add face support to search mode
  2009-11-28  6:07   ` [PATCH -v6] notmuch.el: Add face support to search mode Aneesh Kumar K.V
@ 2009-11-28  6:56     ` Carl Worth
  0 siblings, 0 replies; 11+ messages in thread
From: Carl Worth @ 2009-11-28  6:56 UTC (permalink / raw)
  To: Aneesh Kumar K.V; +Cc: notmuch

[-- Attachment #1: Type: text/plain, Size: 1176 bytes --]

On Sat, 28 Nov 2009 11:37:05 +0530, "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com> wrote:
> This patch use notmuch-tag-face showing tags in the
> notmuch-search-mode.

Thanks, Aneesh! Your patience has prevailed again and I've pushed out
this patch.

> We can selectively highlight each tag by setting notmuch-tag-face-alist as below
> 
> (defface notmuch-tag-unread-face
>  '((((class color)) (:foreground "goldenrod")))
>   "Notmuch search mode face used to highligh tags.")
> 
> (defface notmuch-tag-inbox-face
>  '((((class color)) (:foreground "red")))
>   "Notmuch search mode face used to highligh tags.")
> 
> (setq notmuch-tag-face-alist '(("unread" . 'notmuch-tag-unread-face)
> 			       ("inbox" . 'notmuch-tag-inbox-face)))

I'm a bit concerned that this documentation is going to just disappear
in the commit log and not be where people might actually look for
it. You've got the beginnings of the documentation here:

> +(defvar notmuch-tag-face-alist nil
> +  "List containing the tag list that need to be highlighed")

Which could be expanded to include basically the example above.

Anyway, thanks for the patch.

-Carl

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2009-11-28  6:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-25  4:58 [PATCH -v4] notmuch.el: Add face support to search and show mode Aneesh Kumar K.V
2009-11-25  5:24 ` Alexander Botero-Lowry
2009-11-25 14:33   ` Jeffrey Ollie
2009-11-25 15:32     ` Bart Trojanowski
2009-11-25 15:47   ` Aneesh Kumar K. V
2009-11-27  8:42 ` [PATCH -v5] notmuch.el: Add face support to search mode Aneesh Kumar K.V
2009-11-27  8:42   ` [PATCH -v5] notmuch.el: Use message-mode font-face to highlight mail headers Aneesh Kumar K.V
2009-11-27 10:14     ` [PATCH -v6] " Aneesh Kumar K.V
2009-11-28  5:02       ` Carl Worth
2009-11-28  6:07   ` [PATCH -v6] notmuch.el: Add face support to search mode Aneesh Kumar K.V
2009-11-28  6:56     ` Carl Worth

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).