Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 2A66D40D148 for ; Thu, 21 Oct 2010 22:42:29 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.9 X-Spam-Level: X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9] autolearn=ham Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nTeBM+HKCzdP for ; Thu, 21 Oct 2010 22:42:17 -0700 (PDT) Received: from max.feld.cvut.cz (max.feld.cvut.cz [147.32.192.36]) by olra.theworths.org (Postfix) with ESMTP id ABBAA40D149 for ; Thu, 21 Oct 2010 22:42:17 -0700 (PDT) Received: from localhost (unknown [192.168.200.4]) by max.feld.cvut.cz (Postfix) with ESMTP id 2380E19F33DD; Fri, 22 Oct 2010 07:42:17 +0200 (CEST) X-Virus-Scanned: IMAP AMAVIS Received: from max.feld.cvut.cz ([192.168.200.1]) by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new, port 10044) with ESMTP id WYXeq+ObWbuA; Fri, 22 Oct 2010 07:42:15 +0200 (CEST) Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34]) by max.feld.cvut.cz (Postfix) with ESMTP id C4B0819F3366; Fri, 22 Oct 2010 07:42:15 +0200 (CEST) Received: from steelpick.2x.cz (note-sojka.felk.cvut.cz [147.32.86.30]) (Authenticated sender: sojkam1) by imap.feld.cvut.cz (Postfix) with ESMTPSA id BC2C5FA006; Fri, 22 Oct 2010 07:42:15 +0200 (CEST) Received: from wsh by steelpick.2x.cz with local (Exim 4.72) (envelope-from ) id 1P9AON-0001TX-KD; Fri, 22 Oct 2010 07:42:15 +0200 From: Michal Sojka To: notmuch@notmuchmail.org Subject: [PATCH] emacs: Do not color non-matching authors by tag Date: Fri, 22 Oct 2010 07:42:02 +0200 Message-Id: <1287726122-5643-1-git-send-email-sojkam1@fel.cvut.cz> X-Mailer: git-send-email 1.7.2.3 X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Oct 2010 05:42:29 -0000 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 --- 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)