[notmuch] [PATCH] Further improvements to tag-based coloring in search.

Aaron Ecay aaronecay at gmail.com
Sat Feb 6 17:21:43 PST 2010


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 at 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



More information about the notmuch mailing list