[Patch v2 3/3] emacs: allow notmuch-show-line-faces to use flags for colouring
authorMark Walters <markwalters1009@gmail.com>
Sun, 29 Apr 2012 22:48:17 +0000 (23:48 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:46:49 +0000 (09:46 -0800)
97/87b0d1d038fcdd0fd56129ef40cb328263bb55 [new file with mode: 0644]

diff --git a/97/87b0d1d038fcdd0fd56129ef40cb328263bb55 b/97/87b0d1d038fcdd0fd56129ef40cb328263bb55
new file mode 100644 (file)
index 0000000..d718a31
--- /dev/null
@@ -0,0 +1,134 @@
+Return-Path: <markwalters1009@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 7534D429E36\r
+       for <notmuch@notmuchmail.org>; Sun, 29 Apr 2012 15:48:23 -0700 (PDT)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: 0.201\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=0.201 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001,\r
+       RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\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 8kHd+++RHBd9 for <notmuch@notmuchmail.org>;\r
+       Sun, 29 Apr 2012 15:48:21 -0700 (PDT)\r
+Received: from mail-wg0-f45.google.com (mail-wg0-f45.google.com\r
+ [74.125.82.45])       (using TLSv1 with cipher RC4-SHA (128/128 bits))        (No client\r
+ certificate requested)        by olra.theworths.org (Postfix) with ESMTPS id\r
+ 3F268431FDA   for <notmuch@notmuchmail.org>; Sun, 29 Apr 2012 15:48:13 -0700\r
+ (PDT)\r
+Received: by wgbdt14 with SMTP id dt14so1973630wgb.2\r
+       for <notmuch@notmuchmail.org>; Sun, 29 Apr 2012 15:48:10 -0700 (PDT)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references;\r
+       bh=gAsLlCwH02M8uthqw3CVudh6WzBKVA+69J8gGwpsjew=;\r
+       b=i8q+aAHnJ2SlLaTAM5maCD49wcBtJ2K6LMgLg93oejzrr2dZeVNBFFk7wWMQRyYRzW\r
+       GWrCCLKiuHC02VUjIOJO0yUwaxDIF5unLRvdATtToUZaAHqiRwB6VrgupAsC5ZQ5jqVb\r
+       K8mVFCq+R3Blx40mEjdD76X3T4XwhqO6LeKWf+tmKWoZkLyrrMOcwjtYLqyPNDmto270\r
+       yuYqoj4rzFOx7NJT7xm1q9kVaNHKJdnVAMtQwiS44YFFCrrS5d1Fb8SIRfBs+rd2LJB8\r
+       oSJDbLBZvXnmkhh75V+nhMckcrOJ/sMH2ZMIE18cHqITjeUFpSe3JUmreEexpJ+w6c3F\r
+       lFmQ==\r
+Received: by 10.180.101.136 with SMTP id fg8mr24031124wib.4.1335739690631;\r
+       Sun, 29 Apr 2012 15:48:10 -0700 (PDT)\r
+Received: from localhost (94-192-233-223.zone6.bethere.co.uk.\r
+ [94.192.233.223])     by mx.google.com with ESMTPS id\r
+ fz9sm24224283wib.3.2012.04.29.15.48.09        (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sun, 29 Apr 2012 15:48:10 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [Patch v2 3/3] emacs: allow notmuch-show-line-faces to use flags for\r
+       colouring\r
+Date: Sun, 29 Apr 2012 23:48:17 +0100\r
+Message-Id: <1335739697-8501-4-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1335739697-8501-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1335739697-8501-1-git-send-email-markwalters1009@gmail.com>\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, 29 Apr 2012 22:48:23 -0000\r
+\r
+This allows header-lines `notmuch-show-mode' buffers to be coloured\r
+based on the flags (match/excluded) of the message. It supplies the\r
+line colouring function with a list of tags each prefixed with "tag:"\r
+and a list of flags ("match" or "excluded") each prefixed with\r
+"flag:".\r
+\r
+The match flag is obviously not equivalent to a tag; the excluded flag\r
+looks equivalent but is subtly different: a message is not marked\r
+excluded if that tag appeared in the query.\r
+---\r
+ emacs/notmuch-show.el |   21 ++++++++++++++++-----\r
+ 1 files changed, 16 insertions(+), 5 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
+index bb7db6e..f09de26 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -96,14 +96,16 @@ any given message."\r
+ (defcustom notmuch-show-line-faces nil\r
+   "Tag to face mapping for header line highlighting in `notmuch-show-mode'.\r
+ \r
+-Here is an example of how to color search results based on tags.\r
++Here is an example of how to color search results based on tags\r
++and flags (match and excluded).\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 '((\"tag:delete\" . (:foreground \"red\"\r
+                                                 :background \"blue\"))\r
+-                                   (\"unread\" . (:foreground \"green\"))))\r
++                                   (\"tag:unread\" . (:foreground \"green\"))\r
++                                   (\"flag:excluded\" . (:background \"grey\"))))\r
+ \r
+-The attributes defined for matching tags are merged, with later\r
++The attributes defined for matching tags/flags 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
+@@ -871,11 +873,20 @@ current buffer, if possible."\r
+        content-start content-end\r
+        headers-start headers-end\r
+        body-start body-end\r
++       tags-and-flags\r
+        (headers-invis-spec (notmuch-show-make-symbol "header"))\r
+        (message-invis-spec (notmuch-show-make-symbol "message"))\r
+        (bare-subject (notmuch-show-strip-re (plist-get headers :Subject)))\r
+        (tags (plist-get msg :tags)))\r
+ \r
++    (mapc (lambda (tag)\r
++          (setq tags-and-flags (cons (concat "tag:" tag) tags-and-flags)))\r
++        tags)\r
++    (if (plist-get msg :match)\r
++      (setq tags-and-flags (cons "flag:match" tags-and-flags)))\r
++    (if (plist-get msg :excluded)\r
++      (setq tags-and-flags (cons "flag:excluded" tags-and-flags)))\r
++\r
+     ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise\r
+     ;; removing items from `buffer-invisibility-spec' (which is what\r
+     ;; `notmuch-show-headers-visible' and\r
+@@ -904,7 +915,7 @@ current buffer, if possible."\r
+     (setq content-start (point-marker))\r
+ \r
+     ;; Colour the header line according to the tags of the message.\r
+-    (notmuch-color-line message-start content-start tags notmuch-show-line-faces)\r
++    (notmuch-color-line message-start content-start tags-and-flags notmuch-show-line-faces)\r
+ \r
+     (plist-put msg :headers-invis-spec headers-invis-spec)\r
+     (plist-put msg :message-invis-spec message-invis-spec)\r
+-- \r
+1.7.9.1\r
+\r