[PATCH 3/3] emacs: allow notmuch-show-line-faces to use flags for colouring
authorMark Walters <markwalters1009@gmail.com>
Sat, 14 Apr 2012 19:21:41 +0000 (20:21 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:46:23 +0000 (09:46 -0800)
65/87d4947a17e2a57f5113b07c0c1a4629ecce45 [new file with mode: 0644]

diff --git a/65/87d4947a17e2a57f5113b07c0c1a4629ecce45 b/65/87d4947a17e2a57f5113b07c0c1a4629ecce45
new file mode 100644 (file)
index 0000000..9ab69ae
--- /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 3ACD4431FC2\r
+       for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 12:21:51 -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 pROiv4MNmym7 for <notmuch@notmuchmail.org>;\r
+       Sat, 14 Apr 2012 12:21:50 -0700 (PDT)\r
+Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com\r
+       [209.85.212.173]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id 629DF429E27\r
+       for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 12:21:45 -0700 (PDT)\r
+Received: by wibhq7 with SMTP id hq7so6114674wib.2\r
+       for <notmuch@notmuchmail.org>; Sat, 14 Apr 2012 12:21:44 -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=bBzpGblhZzOa3AopxPFdYPMqUEo4zJv3c7k9X22Gv7U=;\r
+       b=HPRwL6u2JwWdlx7N7CDDsq98c4dPrV2MGjKt9g+IF4rZZBlv465at+Ry/PSfUy87Cz\r
+       9lud+ysfYjwUEvoxTAxmrwPknqWCOAIsGXpLaEurKP5EMbgL6ZjL77lqyXUGY4eAYUJI\r
+       rfrjtIFKt2Ze8ditUjIBUHGFER6O2tXcY52cPRAK3buI3DW2RXjxoiuZ22ytN0UCxvxl\r
+       XKQYn7uBNb58xRQM4IzOFm6bdftq0sKLojhYLz7IxYK2228TGcURJVjjtWQWw2sXdJvR\r
+       EDV9h2BceHUE8rceB5pmMj8XxcYOftZHd3mSTIYDcw3JDNi811bJtsYddIk1NUo7Kmr7\r
+       lEHg==\r
+Received: by 10.180.92.228 with SMTP id cp4mr6048784wib.2.1334431303948;\r
+       Sat, 14 Apr 2012 12:21:43 -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
+ l5sm6598183wia.11.2012.04.14.12.21.42 (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Sat, 14 Apr 2012 12:21:43 -0700 (PDT)\r
+From: Mark Walters <markwalters1009@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH 3/3] emacs: allow notmuch-show-line-faces to use flags for\r
+       colouring\r
+Date: Sat, 14 Apr 2012 20:21:41 +0100\r
+Message-Id: <1334431301-27303-4-git-send-email-markwalters1009@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+In-Reply-To: <1334431301-27303-1-git-send-email-markwalters1009@gmail.com>\r
+References: <1334431301-27303-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: Sat, 14 Apr 2012 19:21:51 -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 3dbb25f..66b8ec7 100644\r
+--- a/emacs/notmuch-show.el\r
++++ b/emacs/notmuch-show.el\r
+@@ -97,14 +97,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
+@@ -872,11 +874,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
+@@ -905,7 +916,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