This patch moves the overlay/colouring from notmuch.el to notmuch-lib.el. This is in preparation for its use by notmuch-show in the next patch. This is just a rebased version of the emacs/notmuch.el and emacs/notmuch-lib.el parts of David Edmondson's patch (see id:"1325006003-27152-1-git-send-email-dme@dme.org") --- emacs/notmuch-lib.el | 18 ++++++++++++++++++ emacs/notmuch.el | 15 +-------------- 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el index 6907a5f..c8a9351 100644 --- a/emacs/notmuch-lib.el +++ b/emacs/notmuch-lib.el @@ -148,6 +148,24 @@ the user hasn't set this variable with the old or new value." "Return a query that matches the message with id ID." (concat "id:\"" (replace-regexp-in-string "\"" "\"\"" id t t) "\"")) +(defun notmuch-color-line (start end line-tag-list spec) + "Colorize a line based on tags." + ;; Create the overlay only if the message has tags which match one + ;; of those specified in `spec'. + (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)) + (overlay-put overlay 'priority 5)) + ;; Merge the specified properties with any already + ;; applied from an earlier match. + (overlay-put overlay 'face + (append (overlay-get overlay 'face) attributes))))) + spec))) + ;; (defun notmuch-common-do-stash (text) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index c6236db..d5f40e2 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -612,20 +612,7 @@ 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))) + (notmuch-color-line start end line-tag-list notmuch-search-line-faces)) (defun notmuch-search-author-propertize (authors) "Split `authors' into matching and non-matching authors and -- 1.7.9.1