aboutsummaryrefslogtreecommitdiffhomepage
path: root/emacs/notmuch.el
diff options
context:
space:
mode:
authorGravatar Austin Clements <amdragon@MIT.EDU>2012-07-21 13:37:06 -0400
committerGravatar David Bremner <bremner@debian.org>2012-07-24 09:04:38 -0300
commit60ebc84945731e37d6cbec19ce51c08c408b49e8 (patch)
tree91bfcdc57c1323ca3100370786f99390e5840646 /emacs/notmuch.el
parentae30f33093ebca63f8a18fff7054ac147898af94 (diff)
emacs: Use text properties instead of overlays for tag coloring
Previously, tag-based search result highlighting was done by creating an overlay over each search result. However, overlays have annoying front- and rear-advancement semantics that make it difficult to manipulate text at their boundaries, which the next patch will do. They also have performance problems (creating an overlay is linear in the number of overlays between point and the new overlay, making highlighting a search buffer quadratic in the number of results). Text properties have neither problem. However, text properties make it more difficult to apply multiple faces since, unlike with overlays, a given character can only have a single 'face text property. Hence, we introduce a utility function that combines faces into any existing 'face text properties. Using this utility function, it's straightforward to apply all of the appropriate tag faces in notmuch-search-color-line.
Diffstat (limited to 'emacs/notmuch.el')
-rw-r--r--emacs/notmuch.el21
1 files changed, 7 insertions, 14 deletions
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index ef189273..82c148df 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -633,20 +633,13 @@ foreground and blue background."
(defun notmuch-search-color-line (start end line-tag-list)
"Colorize lines in `notmuch-show' based on tags."
- ;; Create the overlay only if the message has tags which match one
- ;; of those specified in `notmuch-search-line-faces'.
- (let (overlay)
- (mapc (lambda (elem)
- (let ((tag (car elem))
- (attributes (cdr elem)))
- (when (member tag line-tag-list)
- (when (not overlay)
- (setq overlay (make-overlay start end)))
- ;; Merge the specified properties with any already
- ;; applied from an earlier match.
- (overlay-put overlay 'face
- (append (overlay-get overlay 'face) attributes)))))
- notmuch-search-line-faces)))
+ (mapc (lambda (elem)
+ (let ((tag (car elem))
+ (attributes (cdr elem)))
+ (when (member tag line-tag-list)
+ (notmuch-combine-face-text-property start end attributes))))
+ ;; Reverse the list so earlier entries take precedence
+ (reverse notmuch-search-line-faces)))
(defun notmuch-search-author-propertize (authors)
"Split `authors' into matching and non-matching authors and