[notmuch] [PATCHv2] notmuch.el: colorize lines in notmuch-search based on thread tags.

2010-04-07 Thread Carl Worth
On Thu, 04 Feb 2010 19:38:20 -0500, Jameson Graef Rollins  wrote:
> Arbitrary font faces can be specified for given thread tags.  By
> default, no coloring is applied.  To specify coloring, place something
> like this in your .emacs:
> 
> (setq notmuch-search-line-faces '(("delete" . (:foreground "red"))
>   ("unread" . (:foreground "green"
> 
> Order matters: line faces listed first will take precedence (in the
> example above, a thread tagged both "delete" and "unread" will be
> colored red, since the "delete" face is listed before the "unread").

Hi Jameson,

Thanks for this patch. I just pushed it (based on what I found
originally in spaetz' tree). Only after coming back here did I find that
you had sent a second version that colored "delete" tags by default.

I haven't added that part for a couple of reasons:

1. The commit message doesn't match the behavior of the patch, (it says
   "no coloring is applied" by default.

2. I think we'll go with a tag name of "deleted" rather than "delete".

I did fix up some indentation and a slightly scrambled commit
message. But maybe that only existed in spaetz' tree.

Finally, I checked the customization support, ("M-x customize", then
browse Applications->Email->Notmuch), and saw that notmuch-tag-face is
much easier to customize there, (provides a drop-down value menu with
buttons for modifying the face---where I couldn't even figure out how to
use customize for the new notmuch-search-line-faces).

Plus, I think both of these values should likely be merged into a single
face-selection option, (perhaps with a separate Boolean to determine
whether to highlight just the tag name or the whole line).

Thanks again for the improvements, and hopefully you'll see quicker
merging from me in the future.

-Carl
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
URL: 



Re: [notmuch] [PATCHv2] notmuch.el: colorize lines in notmuch-search based on thread tags.

2010-04-07 Thread Carl Worth
On Thu, 04 Feb 2010 19:38:20 -0500, Jameson Graef Rollins 
jroll...@finestructure.net wrote:
 Arbitrary font faces can be specified for given thread tags.  By
 default, no coloring is applied.  To specify coloring, place something
 like this in your .emacs:
 
 (setq notmuch-search-line-faces '((delete . (:foreground red))
   (unread . (:foreground green
 
 Order matters: line faces listed first will take precedence (in the
 example above, a thread tagged both delete and unread will be
 colored red, since the delete face is listed before the unread).

Hi Jameson,

Thanks for this patch. I just pushed it (based on what I found
originally in spaetz' tree). Only after coming back here did I find that
you had sent a second version that colored delete tags by default.

I haven't added that part for a couple of reasons:

1. The commit message doesn't match the behavior of the patch, (it says
   no coloring is applied by default.

2. I think we'll go with a tag name of deleted rather than delete.

I did fix up some indentation and a slightly scrambled commit
message. But maybe that only existed in spaetz' tree.

Finally, I checked the customization support, (M-x customize, then
browse Applications-Email-Notmuch), and saw that notmuch-tag-face is
much easier to customize there, (provides a drop-down value menu with
buttons for modifying the face---where I couldn't even figure out how to
use customize for the new notmuch-search-line-faces).

Plus, I think both of these values should likely be merged into a single
face-selection option, (perhaps with a separate Boolean to determine
whether to highlight just the tag name or the whole line).

Thanks again for the improvements, and hopefully you'll see quicker
merging from me in the future.

-Carl


pgpPdyb5s50VE.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCHv2] notmuch.el: colorize lines in notmuch-search based on thread tags.

2010-02-05 Thread Jameson Graef Rollins
I realize I should have mentioned that this patch is meant to supercede
the previous patch.  There are just a couple of minor improvements,
including turning on highlighting for deleted threads by default.

jamie.
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: 



Re: [notmuch] [PATCHv2] notmuch.el: colorize lines in notmuch-search based on thread tags.

2010-02-05 Thread Jameson Graef Rollins
I realize I should have mentioned that this patch is meant to supercede
the previous patch.  There are just a couple of minor improvements,
including turning on highlighting for deleted threads by default.

jamie.


pgpXjXWTROZ0t.pgp
Description: PGP signature
___
notmuch mailing list
notmuch@notmuchmail.org
http://notmuchmail.org/mailman/listinfo/notmuch


[notmuch] [PATCHv2] notmuch.el: colorize lines in notmuch-search based on thread tags.

2010-02-04 Thread Jameson Graef Rollins
Arbitrary font faces can be specified for given thread tags.  By
default, no coloring is applied.  To specify coloring, place something
like this in your .emacs:

(setq notmuch-search-line-faces '(("delete" . (:foreground "red"))
  ("unread" . (:foreground "green"

Order matters: line faces listed first will take precedence (in the
example above, a thread tagged both "delete" and "unread" will be
colored red, since the "delete" face is listed before the "unread").
---
 notmuch.el |   34 +-
 1 files changed, 33 insertions(+), 1 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index a21c6a6..6c42b37 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -1203,6 +1203,36 @@ This function advances the next thread when finished."
(insert (format " (process returned %d)" 
exit-status)))
(insert "\n"))

+(defcustom notmuch-search-line-faces
+  '(("delete" . (:foreground "DarkGrey")))
+  "Tag/face mapping for line highlighting in notmuch-search.
+
+Here is an example of how to color search results based on tags.
+(the following text would be placed in your ~/.emacs file):
+
+(setq notmuch-search-line-faces '((\"delete\" . (:foreground \"red\"))
+ (\"unread\" . (:foreground \"green\"
+
+Order matters: for lines with multiple tags, the the first
+matching will be applied."
+  :type '(alist :value-type (string face))
+  :group 'notmuch)
+
+(defun notmuch-search-color-line (start end line-tag-list)
+  "Colorize lines in notmuch-search based on tags"
+  (if notmuch-search-line-faces
+  (let ((overlay (make-overlay start end))
+   (tags-faces (copy-alist notmuch-search-line-faces)))
+   (while tags-faces
+ (let* ((tag-face (car tags-faces))
+(tag (car tag-face))
+(face (cdr tag-face)))
+   (cond ((member tag line-tag-list)
+  (overlay-put overlay 'face face)
+  (setq tags-faces nil))
+ (t
+  (setq tags-faces (cdr tags-faces)
+
 (defun notmuch-search-process-filter (proc string)
   "Process and filter the output of \"notmuch search\""
   (let ((buffer (process-buffer proc)))
@@ -1220,12 +1250,14 @@ This function advances the next thread when finished."
   (authors (match-string 4 string))
   (authors-length (length authors))
   (subject (match-string 5 string))
-  (tags (match-string 6 string)))
+  (tags (match-string 6 string))
+  (tag-list (if tags (save-match-data (split-string 
tags)
  (if (> authors-length 40)
  (set 'authors (concat (substring authors 0 (- 40 3)) 
"...")))
  (goto-char (point-max))
  (let ((beg (point-marker)))
(insert (format "%s %-7s %-40s %s (%s)\n" date count 
authors subject tags))
+   (notmuch-search-color-line beg (point-marker) tag-list)
(put-text-property beg (point-marker) 
'notmuch-search-thread-id thread-id)
(put-text-property beg (point-marker) 
'notmuch-search-authors authors)
(put-text-property beg (point-marker) 
'notmuch-search-subject subject))
-- 
1.6.5