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 6AFBA4196EE for ; Sat, 6 Feb 2010 17:21:54 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.392 X-Spam-Level: X-Spam-Status: No, score=-1.392 tagged_above=-999 required=5 tests=[AWL=-1.207, BAYES_40=-0.185] 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 TQ5jNAt0UZSe for ; Sat, 6 Feb 2010 17:21:53 -0800 (PST) Received: from mail-vw0-f53.google.com (mail-vw0-f53.google.com [209.85.212.53]) by olra.theworths.org (Postfix) with ESMTP id 3275E4196ED for ; Sat, 6 Feb 2010 17:21:53 -0800 (PST) Received: by vws10 with SMTP id 10so1100130vws.26 for ; Sat, 06 Feb 2010 17:21:52 -0800 (PST) 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=A//2D9TzV7RCwnkoBYj7FrF1TsEDURe+I9bDDwZB8+8=; b=A6crvSsyTQnarbB9S4vPWThqz5aYBowLQr7bcXnh7bR8kbPIXAjNzYobWpib6zDHzp 70Cna0IBvLD7XPR2LIY9xdG3AYRvLF344rz6wB1flM4sIv+JPvLQ6Gsf4Swpa4UzWEJn r7L18PY1oPaTrSeHAPXjD+rOEPanxzlSxkGUM= 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=MiBxPzeT5vVm7TMA3KW8FE0BxZH3bssW71MABMrKvZlRqqkPH7MY/WdFKcZTiqnm7V IoBR3v24RtvaBscer9IZvrAVTXYhrMgHzMmekS4vcOdEWYpDXco7JnBGPHB8942YOA2J 7yUicNt3s4nJI0KbGwta+yx4QjZ2SKXOf37Qc= Received: by 10.220.125.10 with SMTP id w10mr8546273vcr.102.1265505712543; Sat, 06 Feb 2010 17:21:52 -0800 (PST) Received: from localhost.localdomain (vpm093.wireless-resnet.upenn.edu [165.123.236.113]) by mx.google.com with ESMTPS id 39sm27869619vws.14.2010.02.06.17.21.51 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 06 Feb 2010 17:21:51 -0800 (PST) From: Aaron Ecay To: notmuch@notmuchmail.org Date: Sat, 6 Feb 2010 20:21:43 -0500 Message-Id: <1265505703-96736-1-git-send-email-aaronecay@gmail.com> X-Mailer: git-send-email 1.6.6 In-Reply-To: <87r5p01pqb.fsf@servo.finestructure.net> References: <87r5p01pqb.fsf@servo.finestructure.net> Subject: [notmuch] [PATCH] Further improvements to tag-based coloring in search. 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, 07 Feb 2010 01:21:54 -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 --- notmuch.el | 29 ++++++++++++++--------------- 1 files changed, 14 insertions(+), 15 deletions(-) diff --git a/notmuch.el b/notmuch.el index 46159af..fff2192 100644 --- a/notmuch.el +++ b/notmuch.el @@ -1257,8 +1257,7 @@ This function advances the next thread when finished." '(("delete" . (:foreground "DarkGrey"))) "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\")))) @@ -1269,19 +1268,19 @@ matching will be applied." :group 'notmuch) (defun notmuch-search-color-line (start end line-tag-list) - "Colorize lines in notmuch-search 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))) - (cond ((member tag line-tag-list) - (overlay-put overlay 'face face) - (setq tags-faces nil)) - (t - (setq tags-faces (cdr tags-faces))))))))) + "Colorize lines in notmuch-search 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 (make-overlay start end) 'face face) + (setq tags-faces nil)) + (t + (setq tags-faces (cdr tags-faces))))))))) (defun notmuch-search-process-filter (proc string) "Process and filter the output of \"notmuch search\"" -- 1.6.6