From: Mark Walters Date: Sat, 5 May 2012 13:39:45 +0000 (+0100) Subject: [Patch v3 2/4] emacs: Add `notmuch-show-line-faces' and apply it. X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=e340824944fee78cf29e0c130d09e836b813eb89;p=notmuch-archives.git [Patch v3 2/4] emacs: Add `notmuch-show-line-faces' and apply it. --- diff --git a/65/b43b49133228eaa5b0a17b45c848e7bb692d69 b/65/b43b49133228eaa5b0a17b45c848e7bb692d69 new file mode 100644 index 000000000..245766595 --- /dev/null +++ b/65/b43b49133228eaa5b0a17b45c848e7bb692d69 @@ -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 EE5E6431FD5 + for ; Sat, 5 May 2012 06:39:48 -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 jlDrU+XvWMd4 for ; + Sat, 5 May 2012 06:39:46 -0700 (PDT) +Received: from mail-wi0-f173.google.com (mail-wi0-f173.google.com + [209.85.212.173]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id CEBF8431FC9 + for ; Sat, 5 May 2012 06:39:42 -0700 (PDT) +Received: by mail-wi0-f173.google.com with SMTP id hr7so1498669wib.2 + for ; Sat, 05 May 2012 06:39:42 -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=eTrMf2YDfMZtzWu1CzWLU1VdCsDJwwkBwJ2Oyaqr28g=; + b=IpUbk7UIkGXnAGCnDyj0QPbyUXfpOVqjZwHxyuPNzAmVRZ/8Su8NjM38bX7xZIEZ3a + pOTZoMyIcyg+nZTAeWopMouJjYQnEyxhFtnJ5wg8AltFrLNB8Um69/zPOafAYMQaCU+w + IWTcmAh/hnVr5zIloMZQaD7n0jOm3z5KoO4q/RsiraReINJwX6+KlmZXiUS5oulR1C4H + 4wcymNUAI/wut6Fqc36sUH3s3DbrCCUJR7OZ2O4YC+7C7pDuO8t66undrNMAkIUSGYA7 + Vzuhcsi6h4tqnm4z7b176WdQggMgIP6iyza/0PoDlCdG8BmJ2ER4dPspOAaxA8lw0x0r + a72Q== +Received: by 10.180.77.4 with SMTP id o4mr21353989wiw.17.1336225182580; + Sat, 05 May 2012 06:39:42 -0700 (PDT) +Received: from localhost (94-192-233-223.zone6.bethere.co.uk. + [94.192.233.223]) by mx.google.com with ESMTPS id + 6sm5808799wiz.1.2012.05.05.06.39.41 (version=TLSv1/SSLv3 cipher=OTHER); Sat, + 05 May 2012 06:39:41 -0700 (PDT) +From: Mark Walters +To: notmuch@notmuchmail.org +Subject: [Patch v3 2/4] emacs: Add `notmuch-show-line-faces' and apply it. +Date: Sat, 5 May 2012 14:39:45 +0100 +Message-Id: <1336225187-8772-3-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:49 -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..e62f0a0 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-show-line-faces '((\"deleted\" . (: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 +