From 8de840b83fe0ad8c486029d6f136a9010ee2ed73 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sun, 29 Apr 2012 23:48:16 +0100 Subject: [PATCH] [Patch v2 2/3] emacs: Add `notmuch-show-line-faces' and apply it. --- 5b/4e23b469c95369f397e168d581b824100044be | 149 ++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 5b/4e23b469c95369f397e168d581b824100044be diff --git a/5b/4e23b469c95369f397e168d581b824100044be b/5b/4e23b469c95369f397e168d581b824100044be new file mode 100644 index 000000000..57194d1a2 --- /dev/null +++ b/5b/4e23b469c95369f397e168d581b824100044be @@ -0,0 +1,149 @@ +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 2F1B3431FDB + for ; Sun, 29 Apr 2012 15:48:18 -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 EiHIWtLHkJdM for ; + Sun, 29 Apr 2012 15:48:15 -0700 (PDT) +Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com + [209.85.212.179]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id B8A2B429E30 + for ; Sun, 29 Apr 2012 15:48:09 -0700 (PDT) +Received: by wibhn6 with SMTP id hn6so1883957wib.2 + for ; Sun, 29 Apr 2012 15:48:08 -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=bNNT/YJ/3A1Z5RpWKaHgWEe+CYQ62jltKpaiP4qm1wo=; + b=POUUzcjaX4P0LNrlOArapvKkq6yq2Q7Gtj/uZXN0vYBwDYlLuMdAMHbBSnlEOnqpuz + S8+LzhHdBqmbgspYILONV1CJMy9jNsSX+hTPBmgwjJB8macv0fGutQZBJ63shTauxxFA + JP4qtu6IPaSEto/PjRdaNYfmMPOf+93zZkpBIZZlR+P6SdGSzDJZdm3VXBFlfHJlB1vH + meP0JlHxopnMyEd0HaYNSoLOhGxtLZIzuoAgq/oaadsVn0gH5/lpifKjvU6XDyWcL+5H + AURqO9sWpuitIcgnMOdG2hQbSx+YBjC8mVHYQZ3vZeUYJp3+FPzKfvphvzrdIaFOxOTO + we0Q== +Received: by 10.180.78.105 with SMTP id a9mr23754226wix.20.1335739688473; + Sun, 29 Apr 2012 15:48:08 -0700 (PDT) +Received: from localhost (94-192-233-223.zone6.bethere.co.uk. + [94.192.233.223]) by mx.google.com with ESMTPS id + k6sm24217932wiy.7.2012.04.29.15.48.06 (version=TLSv1/SSLv3 cipher=OTHER); + Sun, 29 Apr 2012 15:48:07 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [Patch v2 2/3] emacs: Add `notmuch-show-line-faces' and apply it. +Date: Sun, 29 Apr 2012 23:48:16 +0100 +Message-Id: <1335739697-8501-3-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1335739697-8501-1-git-send-email-markwalters1009@gmail.com> +References: <1335739697-8501-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: Sun, 29 Apr 2012 22:48:18 -0000 + +Similar to `notmuch-search-line-faces', `notmuch-show-line-faces' +allows the header line in `notmuch-show-mode' buffers to be coloured +according to the tags of the message. This is just a rebased version of +the emacs/notmuch-show.el of David Edmondson's patch +id:"1325006003-27152-1-git-send-email-dme@dme.org" +--- + emacs/notmuch-show.el | 33 +++++++++++++++++++++++++++++---- + 1 files changed, 29 insertions(+), 4 deletions(-) + +diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el +index 37f0ebb..bb7db6e 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -93,6 +93,24 @@ any given message." + :group 'notmuch-show + :group 'notmuch-hooks) + ++(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. ++ (the following text would be placed in your ~/.emacs file): ++ ++ (setq notmuch-search-line-faces '((\"delete\" . (:foreground \"red\" ++ :background \"blue\")) ++ (\"unread\" . (:foreground \"green\")))) ++ ++The attributes defined for matching tags 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." ++ :type '(alist :key-type (string) :value-type (custom-face-edit)) ++ :group 'notmuch-show ++ :group 'notmuch-faces) ++ + ;; Mostly useful for debugging. + (defcustom notmuch-show-all-multipart/alternative-parts t + "Should all parts of multipart/alternative parts be shown?" +@@ -411,7 +429,8 @@ unchanged ADDRESS if parsing fails." + (defun notmuch-show-insert-headerline (headers date tags depth) + "Insert a notmuch style headerline based on HEADERS for a + message at DEPTH in the current thread." +- (let ((start (point))) ++ (let ((start (point)) ++ overlay) + (insert (notmuch-show-spaces-n (* notmuch-show-indent-messages-width depth)) + (notmuch-show-clean-address (plist-get headers :From)) + " (" +@@ -420,7 +439,9 @@ message at DEPTH in the current thread." + (propertize (mapconcat 'identity tags " ") + 'face 'notmuch-tag-face) + ")\n") +- (overlay-put (make-overlay start (point)) 'face 'notmuch-message-summary-face))) ++ (setq overlay (make-overlay start (point))) ++ (overlay-put overlay 'face 'notmuch-message-summary-face) ++ (overlay-put overlay 'priority 2))) + + (defun notmuch-show-insert-header (header header-value) + "Insert a single header." +@@ -852,7 +873,8 @@ current buffer, if possible." + body-start body-end + (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)))) ++ (bare-subject (notmuch-show-strip-re (plist-get headers :Subject))) ++ (tags (plist-get msg :tags))) + + ;; Set `buffer-invisibility-spec' to `nil' (a list), otherwise + ;; removing items from `buffer-invisibility-spec' (which is what +@@ -877,10 +899,13 @@ current buffer, if possible." + (plist-get msg :date_relative) + nil) + (plist-get headers :Date)) +- (plist-get msg :tags) depth) ++ tags depth) + + (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) ++ + (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