unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: Mark Walters <markwalters1009@gmail.com>
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	[thread overview]
Message-ID: <1335739697-8501-3-git-send-email-markwalters1009@gmail.com> (raw)
In-Reply-To: <1335739697-8501-1-git-send-email-markwalters1009@gmail.com>

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

  parent reply	other threads:[~2012-04-29 22:48 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-29 22:48 [Patch v2 0/3] emacs: allow show to colour based on tags and flags Mark Walters
2012-04-29 22:48 ` [Patch v2 1/3] emacs: Move colour line from search to lib Mark Walters
2012-04-29 22:48 ` Mark Walters [this message]
2012-05-05 11:45   ` [Patch v2 2/3] emacs: Add `notmuch-show-line-faces' and apply it Jani Nikula
2012-04-29 22:48 ` [Patch v2 3/3] emacs: allow notmuch-show-line-faces to use flags for colouring Mark Walters
2012-04-30  4:49   ` Tomi Ollila
2012-04-29 23:02 ` [Patch v2 0/3] emacs: allow show to colour based on tags and flags Austin Clements
2012-04-29 23:37   ` Mark Walters
2012-05-02  0:30   ` Jameson Graef Rollins
2012-05-04  5:46     ` Mark Walters
2012-05-04 14:22       ` Jameson Graef Rollins
2012-05-05 11:57       ` Jani Nikula

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://notmuchmail.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1335739697-8501-3-git-send-email-markwalters1009@gmail.com \
    --to=markwalters1009@gmail.com \
    --cc=notmuch@notmuchmail.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).