From e258cd22f6a0846e350e08bdfde0399526312cea Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sat, 5 May 2012 14:39:47 +0100 Subject: [PATCH] [Patch v3 4/4] emacs: allow notmuch-show-line-faces to use flags for colouring --- d6/7acf922f8df03bef2ebaf52af5fd3aa2a9eab7 | 143 ++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 d6/7acf922f8df03bef2ebaf52af5fd3aa2a9eab7 diff --git a/d6/7acf922f8df03bef2ebaf52af5fd3aa2a9eab7 b/d6/7acf922f8df03bef2ebaf52af5fd3aa2a9eab7 new file mode 100644 index 000000000..83642ed27 --- /dev/null +++ b/d6/7acf922f8df03bef2ebaf52af5fd3aa2a9eab7 @@ -0,0 +1,143 @@ +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 892E7431FC9 + for ; Sat, 5 May 2012 06:39:50 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: 0.201 +X-Spam-Level: +X-Spam-Status: No, score=0.201 tagged_above=-999 required=5 + tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, + FREEMAIL_ENVFROM_END_DIGIT=1, FREEMAIL_FROM=0.001, + RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled +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 YW5hurwn-XSp for ; + Sat, 5 May 2012 06:39:49 -0700 (PDT) +Received: from mail-we0-f181.google.com (mail-we0-f181.google.com + [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 76DF5431FC7 + for ; Sat, 5 May 2012 06:39:48 -0700 (PDT) +Received: by werm13 with SMTP id m13so2702719wer.26 + for ; Sat, 05 May 2012 06:39:47 -0700 (PDT) +DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; + h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; + bh=DPGmWp7F6nMRKhFdG4KmKYpQLCAlbv/iqYHlsehlwWU=; + b=YV3wv+nkeAoKBmO+vyE5SRx/LpbuLLvPf0sinqmc/g9jWMXe7MKOS4UhquonZCWmqq + ZYaUbxbm/DYzMHVns/d0tgSYFffCy/eJPR4O9SxadVhj2/iwVrzqyX7EiLj+o9t4sG7z + 5/+xU0elVAc+upJykUilsVPzXGxsj0nJfd8+G7EYozxl8PEU/tJx+53DVd9Pc8t6yN63 + 1w6r+CMOHwYw9Hkhqx0HH89fqy4PhAmffA889KPvpAJo00U6oVc4JZsvTU8mqO091T9i + KnFk+Td19Zm5UgU1g78495/squDNm56FBwH9ZPuDrqQCUXJuO8TWJVhg2UBaiHY+vxjK + HiMA== +Received: by 10.180.90.233 with SMTP id bz9mr20566468wib.21.1336225187128; + Sat, 05 May 2012 06:39:47 -0700 (PDT) +Received: from localhost (94-192-233-223.zone6.bethere.co.uk. + [94.192.233.223]) by mx.google.com with ESMTPS id + e6sm5781484wix.8.2012.05.05.06.39.45 (version=TLSv1/SSLv3 cipher=OTHER); Sat, + 05 May 2012 06:39:46 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [Patch v3 4/4] emacs: allow notmuch-show-line-faces to use flags for + colouring +Date: Sat, 5 May 2012 14:39:47 +0100 +Message-Id: <1336225187-8772-5-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1336225187-8772-1-git-send-email-markwalters1009@gmail.com> +References: <1336225187-8772-1-git-send-email-markwalters1009@gmail.com> +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: Sat, 05 May 2012 13:39:50 -0000 + +This allows header-lines `notmuch-show-mode' buffers to be coloured +based on the flags (match/excluded) of the message. It supplies the +line colouring function with a list of tags each prefixed with "tag:" +and a list of flags ("match" or "excluded") each prefixed with +"flag:". + +The match flag is obviously not equivalent to a tag; the excluded flag +looks equivalent but is subtly different: a message is not marked +excluded if that tag appeared in the query. +--- + emacs/notmuch-show.el | 28 ++++++++++++++++++++++------ + 1 files changed, 22 insertions(+), 6 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index e62f0a0..94399c5 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -96,17 +96,24 @@ any given message." + (defcustom notmuch-show-line-faces nil + "Tag to face mapping for header line highlighting in `notmuch-show-mode'. + +-Here is an example of how to color search results based on tags. ++Here is an example of how to color search results based on tags ++and flags (match and excluded). + (the following text would be placed in your ~/.emacs file): + +- (setq notmuch-show-line-faces '((\"deleted\" . (:foreground \"red\" ++ (setq notmuch-show-line-faces '((\"tag:deleted\" . (:foreground \"red\" + :background \"blue\")) +- (\"unread\" . (:foreground \"green\")))) ++ (\"tag:unread\" . (:foreground \"green\")) ++ (\"flag:excluded\" . (:background \"grey\")))) + +-The attributes defined for matching tags are merged, with later ++The attributes defined for matching tags/flags are merged, with later + attributes overriding earlier. A message having both \"delete\" + and \"unread\" tags with the above settings would have a green +-foreground and blue background." ++foreground and blue background. ++ ++Alternatively, here is an example of colouring using the same ++criteria as for search results: ++ (setq notmuch-show-line-faces notmuch-search-line-faces)" ++ + :type '(alist :key-type (string) :value-type (custom-face-edit)) + :group 'notmuch-show + :group 'notmuch-faces) +@@ -871,11 +878,20 @@ current buffer, if possible." + content-start content-end + headers-start headers-end + body-start body-end ++ tags-and-flags + (headers-invis-spec (notmuch-show-make-symbol "header")) + (message-invis-spec (notmuch-show-make-symbol "message")) + (bare-subject (notmuch-show-strip-re (plist-get headers :Subject))) + (tags (plist-get msg :tags))) + ++ (mapc (lambda (tag) ++ (setq tags-and-flags (cons (concat "tag:" tag) tags-and-flags))) ++ tags) ++ (if (plist-get msg :match) ++ (setq tags-and-flags (cons "flag:match" tags-and-flags))) ++ (if (plist-get msg :excluded) ++ (setq tags-and-flags (cons "flag:excluded" tags-and-flags))) ++ + ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise + ;; removing items from `buffer-invisibility-spec' (which is what + ;; `notmuch-show-headers-visible' and +@@ -904,8 +920,7 @@ current buffer, if possible." + (setq content-start (point-marker)) + + ;; Colour the header line according to the tags of the message. +- (notmuch-color-line message-start content-start tags notmuch-show-line-faces) ++ (notmuch-color-line message-start content-start tags-and-flags notmuch-show-line-faces) + + (plist-put msg :headers-invis-spec headers-invis-spec) + (plist-put msg :message-invis-spec message-invis-spec) +-- +1.7.9.1 + -- 2.26.2