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

Aaron Ecay aaronecay at gmail.com
Sun Apr 11 16:27:30 PDT 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>
---
 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



More information about the notmuch mailing list