[PATCH] Further improvements to tag-based coloring in search.
authorAaron Ecay <aaronecay@gmail.com>
Sun, 11 Apr 2010 23:27:30 +0000 (19:27 +2000)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:36:35 +0000 (09:36 -0800)
94/042420397be273cceb42c9375a4980a85a7c55 [new file with mode: 0644]

diff --git a/94/042420397be273cceb42c9375a4980a85a7c55 b/94/042420397be273cceb42c9375a4980a85a7c55
new file mode 100644 (file)
index 0000000..4ea6c2e
--- /dev/null
@@ -0,0 +1,119 @@
+Return-Path: <aaronecay@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id 852FA4196F2\r
+       for <notmuch@notmuchmail.org>; Sun, 11 Apr 2010 16:27:41 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.599\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.599 tagged_above=-999 required=5\r
+       tests=[BAYES_05=-0.5, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,\r
+       DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001]\r
+       autolearn=ham\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id Iwi14GPEoGIE for <notmuch@notmuchmail.org>;\r
+       Sun, 11 Apr 2010 16:27:40 -0700 (PDT)\r
+Received: from qw-out-1920.google.com (qw-out-1920.google.com [74.125.92.147])\r
+       by olra.theworths.org (Postfix) with ESMTP id BFE0C431FC1\r
+       for <notmuch@notmuchmail.org>; Sun, 11 Apr 2010 16:27:40 -0700 (PDT)\r
+Received: by qw-out-1920.google.com with SMTP id 5so1632319qwc.32\r
+       for <notmuch@notmuchmail.org>; Sun, 11 Apr 2010 16:27:40 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma;\r
+       h=domainkey-signature:received:received:from:to:subject:date\r
+       :message-id:x-mailer:in-reply-to:references;\r
+       bh=gaE8zzJO5VJZNKXAb9gebzIcGpwbOzxrUbr2wlbrGT4=;\r
+       b=K0fWwIB9jevGvQb14oTdDpORUdx0/vQOAbj2rilTBwiJVbNvTOUVHTL5TjzE3UB3RG\r
+       kAFb6fIj5LOCtHM1QwUrma9j749n5N4pibXyoUXjtLWMYpefiG0z/uEPRKsNHat7QJox\r
+       kdwXk/SLpgRZb/Xc5AMjwhSViI2bkT2+GUUaI=\r
+DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma;\r
+       h=from:to:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       b=aacYVHc35OCXre9qFrY6mB9gdMXDn4Q3khrjAZKWfquTHJEuTnhJ/GVd5jd2x/d5jS\r
+       ZMwb8ZFRgajGiO0DJRdVpRpW0j1Bh3YEA6SjACkQpDHp4moAeanXvZuGEVBsQCsMOglJ\r
+       g+mHRNgLtlv//Db/W1bz7IB9Pwt555LLTIpXg=\r
+Received: by 10.224.53.148 with SMTP id m20mr1144532qag.278.1271028460108;\r
+       Sun, 11 Apr 2010 16:27:40 -0700 (PDT)\r
+Received: from localhost.localdomain (vpm120.wireless-resnet.upenn.edu\r
+       [165.123.236.140])\r
+       by mx.google.com with ESMTPS id 6sm7336237qwk.21.2010.04.11.16.27.38\r
+       (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
+       Sun, 11 Apr 2010 16:27:38 -0700 (PDT)\r
+From: Aaron Ecay <aaronecay@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] Further improvements to tag-based coloring in search.\r
+Date: Sun, 11 Apr 2010 19:27:30 -0400\r
+Message-Id:\r
+ <8491e4717d8c63b3dd046809458d3609ffd588b0.1271028205.git.aaronecay@gmail.com>\r
+X-Mailer: git-send-email 1.7.0.4\r
+In-Reply-To: <8739z7gm4d.fsf@yoom.home.cworth.org>\r
+References: <8739z7gm4d.fsf@yoom.home.cworth.org>\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sun, 11 Apr 2010 23:27:41 -0000\r
+\r
+Makes the following improvements:\r
+- fix up doc strings\r
+- suppress the creation of unnecessary let-bindings\r
+- create overlays lazily (to avoid creating many overlays for threads\r
+  that do not get colored)\r
+\r
+Signed-off-by: Aaron Ecay <aaronecay@gmail.com>\r
+---\r
+ emacs/notmuch.el |   21 ++++++++++-----------\r
+ 1 files changed, 10 insertions(+), 11 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 517c53a..03d89c1 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -605,8 +605,7 @@ This function advances the next thread when finished."\r
+ (defcustom notmuch-search-line-faces nil\r
+   "Tag/face mapping for line highlighting in notmuch-search.\r
\r
+-Here is an example of how to color search results based on tags.\r
+-(the following text would be placed in your ~/.emacs file):\r
++Here is an example of how to color search results based on tags:\r
\r
+ (setq notmuch-search-line-faces '((\"delete\" . '(:foreground \"red\"))\r
+                                  (\"unread\" . '(:foreground \"green\"))))\r
+@@ -617,16 +616,16 @@ matching will be applied."\r
+   :group 'notmuch)\r
\r
+ (defun notmuch-search-color-line (start end line-tag-list)\r
+-  "Colorize lines in notmuch-show based on tags"\r
+-  (if notmuch-search-line-faces\r
+-      (let ((overlay (make-overlay start end))\r
+-          (tags-faces (copy-alist notmuch-search-line-faces)))\r
+-      (while tags-faces\r
+-        (let* ((tag-face (car tags-faces))\r
+-               (tag (car tag-face))\r
+-               (face (cdr tag-face)))\r
++  "Colorize lines in notmuch-show based on tags.\r
++\r
++Uses the tag/face mappings found in `notmuch-search-line-faces'."\r
++  (when notmuch-search-line-faces\r
++    (let ((tags-faces notmuch-search-line-faces))\r
++      (while tags-faces\r
++        (let ((tag (caar tags-faces))\r
++              (face (cdar tags-faces)))\r
+           (cond ((member tag line-tag-list)\r
+-                 (overlay-put overlay 'face face)\r
++                 (overlay-put (make-overlay start end) 'face face)\r
+                  (setq tags-faces nil))\r
+                 (t\r
+                  (setq tags-faces (cdr tags-faces)))))))))\r
+-- \r
+1.7.0.4\r
+\r