unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Michal Sojka <sojkam1@fel.cvut.cz>
To: notmuch@notmuchmail.org
Subject: [PATCH] emacs: Do not color non-matching authors by tag
Date: Fri, 22 Oct 2010 07:42:02 +0200	[thread overview]
Message-ID: <1287726122-5643-1-git-send-email-sojkam1@fel.cvut.cz> (raw)

Customizing notmuch-search-line-faces to color lines in search result
according to tags has the effect that the color overrides other faces
set for the line. This is usually what the user wants with the
exception that it also colors non-matching authors and it is then not
possible to visually distinguish between matching and non-matching
authors.

This patch changes the way how are the faces specified in
notmuch-search-line-faces applied to the search results. In
particular, instead of adding an overlay for the whole line, the
existing faces of the line are replaced with what is given in
notmuch-search-line-faces. The only exception is that
notmuch-search-non-matching-authors face is never replaced.

Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>

---
 emacs/notmuch.el |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 42619b2..d0fb834 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -593,17 +593,31 @@ matching will be applied."
   :type '(alist :key-type (string) :value-type (list))
   :group 'notmuch)
 
+(defun notmuch-search-set-line-face (start end face)
+  "Change face propery to value FACE expect for non-matching authors."
+  (save-excursion
+    (save-restriction
+      (narrow-to-region start end)
+      (goto-char (point-min))
+      (let ((fstart (point))
+	    fend)
+	(while (< fstart (point-max))
+	  (setq fend (or (next-single-property-change fstart 'face)
+			 (point-max)))
+	  (when (not (eq (get-text-property fstart 'face) 'notmuch-search-non-matching-authors))
+	    (put-text-property fstart fend 'face face))
+	  (setq fstart fend))))))
+
 (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)))
+      (let ((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)
+		   (notmuch-search-set-line-face start end face)
 		   (setq tags-faces nil))
 		  (t
 		   (setq tags-faces (cdr tags-faces)))))))))
-- 
tg: (f117d80..) t/do-not-colorize-non-matching-authors-by-tag (depends on: master)

             reply	other threads:[~2010-10-22  5:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-22  5:42 Michal Sojka [this message]
2010-11-04 13:55 ` [PATCH] emacs: Do not color non-matching authors by tag David Edmondson
2010-11-04 14:12   ` Michal Sojka
2010-11-04 14:45     ` David Edmondson
2010-11-05  8:10       ` Michal Sojka
2010-11-05  8:17         ` Michal Sojka
2010-11-05  8:55           ` David Edmondson
2010-11-05 11:42           ` Jameson Rollins

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1287726122-5643-1-git-send-email-sojkam1@fel.cvut.cz \
    --to=sojkam1@fel.cvut.cz \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).