unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] notmuch.el: colorize lines in notmuch-search based on thread tags.
@ 2010-02-04 12:07 Jameson Rollins
  2010-02-05  0:38 ` [PATCHv2] " Jameson Graef Rollins
  2010-02-07 15:44 ` [PATCH] " Aneesh Kumar K. V
  0 siblings, 2 replies; 9+ messages in thread
From: Jameson Rollins @ 2010-02-04 12:07 UTC (permalink / raw)
  To: Notmuch Mail

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

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 |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index a21c6a6..4f8840a 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -1203,6 +1203,35 @@ This function advances the next thread when finished."
 			    (insert (format " (process returned %d)" exit-status)))
 			(insert "\n"))))))))))
 
+(defcustom notmuch-search-line-faces nil
+  "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 :key-type (string) :value-type (list))
+  :group 'notmuch)
+
+(defun notmuch-search-color-line (start end line-tag-list)
+  "Colorize lines in notmuch-show 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 +1249,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


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

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

* [PATCHv2] notmuch.el: colorize lines in notmuch-search based on thread tags.
  2010-02-04 12:07 [PATCH] notmuch.el: colorize lines in notmuch-search based on thread tags Jameson Rollins
@ 2010-02-05  0:38 ` Jameson Graef Rollins
  2010-02-05 15:05   ` Jameson Graef Rollins
                     ` (2 more replies)
  2010-02-07 15:44 ` [PATCH] " Aneesh Kumar K. V
  1 sibling, 3 replies; 9+ messages in thread
From: Jameson Graef Rollins @ 2010-02-05  0:38 UTC (permalink / raw)
  To: Notmuch Mail

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

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

* Re: [PATCHv2] notmuch.el: colorize lines in notmuch-search based on thread tags.
  2010-02-05  0:38 ` [PATCHv2] " Jameson Graef Rollins
@ 2010-02-05 15:05   ` Jameson Graef Rollins
  2010-02-07  1:21   ` [PATCH] Further improvements to tag-based coloring in search Aaron Ecay
  2010-04-07 18:19   ` [PATCHv2] notmuch.el: colorize lines in notmuch-search based on thread tags Carl Worth
  2 siblings, 0 replies; 9+ messages in thread
From: Jameson Graef Rollins @ 2010-02-05 15:05 UTC (permalink / raw)
  To: Notmuch Mail

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

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.

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

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

* [PATCH] Further improvements to tag-based coloring in search.
  2010-02-05  0:38 ` [PATCHv2] " Jameson Graef Rollins
  2010-02-05 15:05   ` Jameson Graef Rollins
@ 2010-02-07  1:21   ` Aaron Ecay
  2010-04-07 18:20     ` Carl Worth
  2010-04-07 18:19   ` [PATCHv2] notmuch.el: colorize lines in notmuch-search based on thread tags Carl Worth
  2 siblings, 1 reply; 9+ messages in thread
From: Aaron Ecay @ 2010-02-07  1:21 UTC (permalink / raw)
  To: notmuch

Makes the following improvements:
- fix up doc strings
- suppress the creation of unnecessary let-bindings
- create overlays lazily (to avoid creating many overlays for threads
  that do not get colored)

Signed-off-by: Aaron Ecay <aaronecay@gmail.com>
---
 notmuch.el |   29 ++++++++++++++---------------
 1 files changed, 14 insertions(+), 15 deletions(-)

diff --git a/notmuch.el b/notmuch.el
index 46159af..fff2192 100644
--- a/notmuch.el
+++ b/notmuch.el
@@ -1257,8 +1257,7 @@ This function advances the next thread when finished."
   '(("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):
+Here is an example of how to color search results based on tags:
 
 (setq notmuch-search-line-faces '((\"delete\" . (:foreground \"red\"))
 				  (\"unread\" . (:foreground \"green\"))))
@@ -1269,19 +1268,19 @@ matching will be applied."
   :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)))))))))
+  "Colorize lines in notmuch-search based on tags.
+
+Uses the tag/face mappings found in `notmuch-search-line-faces'."
+  (when notmuch-search-line-faces
+    (let ((tags-faces notmuch-search-line-faces))
+      (while tags-faces
+        (let ((tag (caar tags-faces))
+              (face (cdar tags-faces)))
+          (cond ((member tag line-tag-list)
+                 (overlay-put (make-overlay start end) '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\""
-- 
1.6.6

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

* Re: [PATCH] notmuch.el: colorize lines in notmuch-search based on thread tags.
  2010-02-04 12:07 [PATCH] notmuch.el: colorize lines in notmuch-search based on thread tags Jameson Rollins
  2010-02-05  0:38 ` [PATCHv2] " Jameson Graef Rollins
@ 2010-02-07 15:44 ` Aneesh Kumar K. V
  2010-02-07 22:17   ` Aaron Ecay
  1 sibling, 1 reply; 9+ messages in thread
From: Aneesh Kumar K. V @ 2010-02-07 15:44 UTC (permalink / raw)
  To: Jameson Rollins, Notmuch Mail

On Thu, 04 Feb 2010 07:07:26 -0500, Jameson Rollins <jrollins@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").


Doesn't 92c4dcc641e9dfb5f65026ebae5cedc8eb1d9e21 help you achive
something similar ?

-aneesh

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

* Re: [PATCH] notmuch.el: colorize lines in notmuch-search based on thread tags.
  2010-02-07 15:44 ` [PATCH] " Aneesh Kumar K. V
@ 2010-02-07 22:17   ` Aaron Ecay
  0 siblings, 0 replies; 9+ messages in thread
From: Aaron Ecay @ 2010-02-07 22:17 UTC (permalink / raw)
  To: Notmuch Mail

--- 2010ko Otsailak 7an, "Aneesh Kumar K. V"-ek idatzi zuen:
> Doesn't 92c4dcc641e9dfb5f65026ebae5cedc8eb1d9e21 help you achive something
> similar ?

That commit allows colors to be applied to the tag name only, whereas this
patch applies the color to the whole line.  Which method(s) notmuch should
support is debatable, of course.  Mutt does whole-line coloring, FWIW.

I should also point out that tag-based coloring is problematic in the current
emacs interface, wherein long subjects can push the tags off the right side of
the window.  That is arguably a bug, but until it is fixed the utility of
tag-only coloring is limited.

Aaron

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

* Re: [PATCHv2] notmuch.el: colorize lines in notmuch-search based on thread tags.
  2010-02-05  0:38 ` [PATCHv2] " Jameson Graef Rollins
  2010-02-05 15:05   ` Jameson Graef Rollins
  2010-02-07  1:21   ` [PATCH] Further improvements to tag-based coloring in search Aaron Ecay
@ 2010-04-07 18:19   ` Carl Worth
  2 siblings, 0 replies; 9+ messages in thread
From: Carl Worth @ 2010-04-07 18:19 UTC (permalink / raw)
  To: Jameson Graef Rollins, Notmuch Mail

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

On Thu, 04 Feb 2010 19:38:20 -0500, Jameson Graef Rollins <jrollins@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

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

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

* Re: [PATCH] Further improvements to tag-based coloring in search.
  2010-02-07  1:21   ` [PATCH] Further improvements to tag-based coloring in search Aaron Ecay
@ 2010-04-07 18:20     ` Carl Worth
  2010-04-11 23:27       ` Aaron Ecay
  0 siblings, 1 reply; 9+ messages in thread
From: Carl Worth @ 2010-04-07 18:20 UTC (permalink / raw)
  To: Aaron Ecay, notmuch

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

On Sat,  6 Feb 2010 20:21:43 -0500, Aaron Ecay <aaronecay@gmail.com> wrote:
> Makes the following improvements:
> - fix up doc strings
> - suppress the creation of unnecessary let-bindings
> - create overlays lazily (to avoid creating many overlays for threads
>   that do not get colored)

Hi Aaron,

I saw this fixed-up version from you only after I'd pushed the previous
one. If you could resend a new change on top of what's now in master,
then that would be appreciated.

Thanks,

-Carl

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

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

* [PATCH] Further improvements to tag-based coloring in search.
  2010-04-07 18:20     ` Carl Worth
@ 2010-04-11 23:27       ` Aaron Ecay
  0 siblings, 0 replies; 9+ messages in thread
From: Aaron Ecay @ 2010-04-11 23:27 UTC (permalink / raw)
  To: notmuch

Makes the following improvements:
- fix up doc strings
- suppress the creation of unnecessary let-bindings
- create overlays lazily (to avoid creating many overlays for threads
  that do not get colored)

Signed-off-by: Aaron Ecay <aaronecay@gmail.com>
---
 emacs/notmuch.el |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 517c53a..03d89c1 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -605,8 +605,7 @@ This function advances the next thread when finished."
 (defcustom notmuch-search-line-faces nil
   "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):
+Here is an example of how to color search results based on tags:
 
 (setq notmuch-search-line-faces '((\"delete\" . '(:foreground \"red\"))
                                  (\"unread\" . '(:foreground \"green\"))))
@@ -617,16 +616,16 @@ matching will be applied."
   :group 'notmuch)
 
 (defun notmuch-search-color-line (start end line-tag-list)
-  "Colorize lines in notmuch-show 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)))
+  "Colorize lines in notmuch-show based on tags.
+
+Uses the tag/face mappings found in `notmuch-search-line-faces'."
+  (when notmuch-search-line-faces
+    (let ((tags-faces notmuch-search-line-faces))
+      (while tags-faces
+        (let ((tag (caar tags-faces))
+              (face (cdar tags-faces)))
 	    (cond ((member tag line-tag-list)
-		   (overlay-put overlay 'face face)
+		   (overlay-put (make-overlay start end) 'face face)
 		   (setq tags-faces nil))
 		  (t
 		   (setq tags-faces (cdr tags-faces)))))))))
-- 
1.7.0.4

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

end of thread, other threads:[~2010-04-11 23:27 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-04 12:07 [PATCH] notmuch.el: colorize lines in notmuch-search based on thread tags Jameson Rollins
2010-02-05  0:38 ` [PATCHv2] " Jameson Graef Rollins
2010-02-05 15:05   ` Jameson Graef Rollins
2010-02-07  1:21   ` [PATCH] Further improvements to tag-based coloring in search Aaron Ecay
2010-04-07 18:20     ` Carl Worth
2010-04-11 23:27       ` Aaron Ecay
2010-04-07 18:19   ` [PATCHv2] notmuch.el: colorize lines in notmuch-search based on thread tags Carl Worth
2010-02-07 15:44 ` [PATCH] " Aneesh Kumar K. V
2010-02-07 22:17   ` Aaron Ecay

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).