From d89635a19a5ed11de408d2af2bdf7a98dde0be63 Mon Sep 17 00:00:00 2001 From: Mark Walters Date: Sat, 14 Apr 2012 20:21:40 +0100 Subject: [PATCH] [PATCH 2/3] emacs: Add `notmuch-show-line-faces' and apply it. --- 9b/a1936a340462720043c4bebdd03fd475a88f98 | 149 ++++++++++++++++++++++ 1 file changed, 149 insertions(+) create mode 100644 9b/a1936a340462720043c4bebdd03fd475a88f98 diff --git a/9b/a1936a340462720043c4bebdd03fd475a88f98 b/9b/a1936a340462720043c4bebdd03fd475a88f98 new file mode 100644 index 000000000..f599ba8b3 --- /dev/null +++ b/9b/a1936a340462720043c4bebdd03fd475a88f98 @@ -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 E12CF431FD0 + for ; Sat, 14 Apr 2012 12:21:49 -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 VqBBJHf8af6t for ; + Sat, 14 Apr 2012 12:21:47 -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 3C040431FC2 + for ; Sat, 14 Apr 2012 12:21:43 -0700 (PDT) +Received: by wibhn6 with SMTP id hn6so3284596wib.2 + for ; Sat, 14 Apr 2012 12:21:41 -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=tFt6E5PF4Ik2i9JM3XCnxHqCRerCNv0s73mCKpUn8yk=; + b=SRxkeFzAMX7OVScMG4pO2iRHrMujWVoZo5iT8+x8OvkFtykavIRpLBdQDNuLIxvub7 + 0JEL7v5s915bgdFUvKeTMfgpHt0EsPYQgq3dRa6iWyaTHpw916MW0n5yyh5294oWV0uV + E1e6FxJCaUobXu5AJCqNnpoU4cwftl7d5vWBBnOmz+ELSZROUE4vigxfSpkEBpSbI5jB + 4nivmGeiQVHMIzcMHdI6rl6hpGxjMbGq0p5hnsQR6TadGhkgAI2OPLpgQ1qe08YrLyMK + wNmfhaGci1qX3znnRMSPkzMADrNB2JD5F3ufMs2zWu/v/YqMH7ZSuoLp+Bxls/f9GJrG + l3Aw== +Received: by 10.216.131.30 with SMTP id l30mr3425417wei.111.1334431301852; + Sat, 14 Apr 2012 12:21:41 -0700 (PDT) +Received: from localhost (94-192-233-223.zone6.bethere.co.uk. + [94.192.233.223]) by mx.google.com with ESMTPS id + fz9sm6623197wib.3.2012.04.14.12.21.40 (version=TLSv1/SSLv3 cipher=OTHER); + Sat, 14 Apr 2012 12:21:41 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [PATCH 2/3] emacs: Add `notmuch-show-line-faces' and apply it. +Date: Sat, 14 Apr 2012 20:21:40 +0100 +Message-Id: <1334431301-27303-3-git-send-email-markwalters1009@gmail.com> +X-Mailer: git-send-email 1.7.9.1 +In-Reply-To: <1334431301-27303-1-git-send-email-markwalters1009@gmail.com> +References: <1334431301-27303-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, 14 Apr 2012 19:21:50 -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 30b26d1..3dbb25f 100644 +--- a/emacs/notmuch-show.el ++++ b/emacs/notmuch-show.el +@@ -94,6 +94,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?" +@@ -412,7 +430,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)) + " (" +@@ -421,7 +440,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." +@@ -853,7 +874,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 +@@ -878,10 +900,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