[PATCH] emacs: Re-work the implementation of highlighting in notmuch-search-mode.
authorDavid Edmondson <dme@dme.org>
Mon, 7 Jun 2010 14:35:10 +0000 (15:35 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:37:07 +0000 (09:37 -0800)
ed/a8a79b2285c29a9e1678e2bcdd799c37e92e6e [new file with mode: 0644]

diff --git a/ed/a8a79b2285c29a9e1678e2bcdd799c37e92e6e b/ed/a8a79b2285c29a9e1678e2bcdd799c37e92e6e
new file mode 100644 (file)
index 0000000..cc855c5
--- /dev/null
@@ -0,0 +1,116 @@
+Return-Path: <dme@dme.org>\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 0BDA24196F0\r
+       for <notmuch@notmuchmail.org>; Mon,  7 Jun 2010 07:35:24 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -1.9\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5\r
+       tests=[BAYES_00=-1.9] 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 HfsdZFNOMXnl for <notmuch@notmuchmail.org>;\r
+       Mon,  7 Jun 2010 07:35:13 -0700 (PDT)\r
+Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com\r
+       [74.125.82.181])\r
+       by olra.theworths.org (Postfix) with ESMTP id 9D5E6431FC1\r
+       for <notmuch@notmuchmail.org>; Mon,  7 Jun 2010 07:35:13 -0700 (PDT)\r
+Received: by wyb35 with SMTP id 35so2855988wyb.26\r
+       for <notmuch@notmuchmail.org>; Mon, 07 Jun 2010 07:35:12 -0700 (PDT)\r
+Received: by 10.227.145.141 with SMTP id d13mr5570334wbv.40.1275921311840;\r
+       Mon, 07 Jun 2010 07:35:11 -0700 (PDT)\r
+Received: from ut.hh.sledj.net (gmp-ea-fw-1b.sun.com [192.18.8.1])\r
+       by mx.google.com with ESMTPS id n31sm38249009wba.9.2010.06.07.07.35.09\r
+       (version=TLSv1/SSLv3 cipher=RC4-MD5);\r
+       Mon, 07 Jun 2010 07:35:10 -0700 (PDT)\r
+Received: by ut.hh.sledj.net (Postfix, from userid 1000)\r
+       id F1167594015; Mon,  7 Jun 2010 15:35:12 +0100 (BST)\r
+From: David Edmondson <dme@dme.org>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: Re-work the implementation of highlighting in\r
+       notmuch-search-mode.\r
+Date: Mon,  7 Jun 2010 15:35:10 +0100\r
+Message-Id: <1275921310-307-1-git-send-email-dme@dme.org>\r
+X-Mailer: git-send-email 1.7.1\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: Mon, 07 Jun 2010 14:35:24 -0000\r
+\r
+Re-write `notmuch-search-color-line', with the following improvements:\r
+ - create overlays only if they will be needed,\r
+ - merge the properties specified for a tag on top of any matching a\r
+   previous tag.\r
+---\r
+ emacs/notmuch.el |   37 +++++++++++++++++++++----------------\r
+ 1 files changed, 21 insertions(+), 16 deletions(-)\r
+\r
+diff --git a/emacs/notmuch.el b/emacs/notmuch.el\r
+index 10babe4..ac1da34 100644\r
+--- a/emacs/notmuch.el\r
++++ b/emacs/notmuch.el\r
+@@ -585,28 +585,33 @@ This function advances the next thread when finished."\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
\r
+- (setq notmuch-search-line-faces '((\"delete\" . '(:foreground \"red\"))\r
++ (setq notmuch-search-line-faces '((\"delete\" . '(:foreground \"red\"\r
++                                                 :background \"blue\"))\r
+                                    (\"unread\" . '(:foreground \"green\"))))\r
\r
+-Order matters: for lines with multiple tags, the the first\r
+-matching will be applied."\r
++The attributes defined for matching tags are merged, with later\r
++attributes overriding earlier. A message having both \"delete\"\r
++and \"unread\" tags with the above settings would have a green\r
++foreground and blue background."\r
+   :type '(alist :key-type (string) :value-type (list))\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
+-          (cond ((member tag line-tag-list)\r
+-                 (overlay-put overlay 'face face)\r
+-                 (setq tags-faces nil))\r
+-                (t\r
+-                 (setq tags-faces (cdr tags-faces)))))))))\r
++  "Colorize lines in `notmuch-show' based on tags."\r
++  ;; Create the overlay only if the message has tags which match one\r
++  ;; of those specified in `notmuch-search-line-faces'.\r
++  (let (overlay)\r
++    (mapc '(lambda (elem)\r
++           (let ((tag (car elem))\r
++                 (attributes (cdr elem)))\r
++             (when (member tag line-tag-list)\r
++               (when (not overlay)\r
++                 (setq overlay (make-overlay start end)))\r
++               ;; Merge the specified properties with any already\r
++               ;; applied from an earlier match.\r
++               (overlay-put overlay 'face\r
++                            (append (overlay-get overlay 'face) attributes)))))\r
++        notmuch-search-line-faces)))\r
\r
+ (defun notmuch-search-isearch-authors-show (overlay)\r
+   (remove-from-invisibility-spec (cons (overlay-get overlay 'invisible) t)))\r
+-- \r
+1.7.1\r
+\r