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 852FA4196F2 for ; Sun, 11 Apr 2010 16:27:41 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.599 X-Spam-Level: X-Spam-Status: No, score=-0.599 tagged_above=-999 required=5 tests=[BAYES_05=-0.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001] 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 Iwi14GPEoGIE for ; Sun, 11 Apr 2010 16:27:40 -0700 (PDT) Received: from qw-out-1920.google.com (qw-out-1920.google.com [74.125.92.147]) by olra.theworths.org (Postfix) with ESMTP id BFE0C431FC1 for ; Sun, 11 Apr 2010 16:27:40 -0700 (PDT) Received: by qw-out-1920.google.com with SMTP id 5so1632319qwc.32 for ; Sun, 11 Apr 2010 16:27:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:subject:date :message-id:x-mailer:in-reply-to:references; bh=gaE8zzJO5VJZNKXAb9gebzIcGpwbOzxrUbr2wlbrGT4=; b=K0fWwIB9jevGvQb14oTdDpORUdx0/vQOAbj2rilTBwiJVbNvTOUVHTL5TjzE3UB3RG kAFb6fIj5LOCtHM1QwUrma9j749n5N4pibXyoUXjtLWMYpefiG0z/uEPRKsNHat7QJox kdwXk/SLpgRZb/Xc5AMjwhSViI2bkT2+GUUaI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:subject:date:message-id:x-mailer:in-reply-to:references; b=aacYVHc35OCXre9qFrY6mB9gdMXDn4Q3khrjAZKWfquTHJEuTnhJ/GVd5jd2x/d5jS ZMwb8ZFRgajGiO0DJRdVpRpW0j1Bh3YEA6SjACkQpDHp4moAeanXvZuGEVBsQCsMOglJ g+mHRNgLtlv//Db/W1bz7IB9Pwt555LLTIpXg= Received: by 10.224.53.148 with SMTP id m20mr1144532qag.278.1271028460108; Sun, 11 Apr 2010 16:27:40 -0700 (PDT) Received: from localhost.localdomain (vpm120.wireless-resnet.upenn.edu [165.123.236.140]) by mx.google.com with ESMTPS id 6sm7336237qwk.21.2010.04.11.16.27.38 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sun, 11 Apr 2010 16:27:38 -0700 (PDT) From: Aaron Ecay To: notmuch@notmuchmail.org Subject: [PATCH] Further improvements to tag-based coloring in search. Date: Sun, 11 Apr 2010 19:27:30 -0400 Message-Id: <8491e4717d8c63b3dd046809458d3609ffd588b0.1271028205.git.aaronecay@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <8739z7gm4d.fsf@yoom.home.cworth.org> References: <8739z7gm4d.fsf@yoom.home.cworth.org> 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: Sun, 11 Apr 2010 23:27:41 -0000 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 --- 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