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 1/3] emacs: Move colour line from search to lib
Date: Sun, 29 Apr 2012 23:48:15 +0100	[thread overview]
Message-ID: <1335739697-8501-2-git-send-email-markwalters1009@gmail.com> (raw)
In-Reply-To: <1335739697-8501-1-git-send-email-markwalters1009@gmail.com>

This patch moves the overlay/colouring from notmuch.el to
notmuch-lib.el. This is in preparation for its use by notmuch-show in
the next patch. This is just a rebased version of the emacs/notmuch.el
and emacs/notmuch-lib.el parts of David Edmondson's patch (see
id:"1325006003-27152-1-git-send-email-dme@dme.org")
---
 emacs/notmuch-lib.el |   18 ++++++++++++++++++
 emacs/notmuch.el     |   15 +--------------
 2 files changed, 19 insertions(+), 14 deletions(-)

diff --git a/emacs/notmuch-lib.el b/emacs/notmuch-lib.el
index 6907a5f..c8a9351 100644
--- a/emacs/notmuch-lib.el
+++ b/emacs/notmuch-lib.el
@@ -148,6 +148,24 @@ the user hasn't set this variable with the old or new value."
   "Return a query that matches the message with id ID."
   (concat "id:\"" (replace-regexp-in-string "\"" "\"\"" id t t) "\""))
 
+(defun notmuch-color-line (start end line-tag-list spec)
+  "Colorize a line based on tags."
+  ;; Create the overlay only if the message has tags which match one
+  ;; of those specified in `spec'.
+  (let (overlay)
+    (mapc (lambda (elem)
+	    (let ((tag (car elem))
+		  (attributes (cdr elem)))
+	      (when (member tag line-tag-list)
+		(when (not overlay)
+		  (setq overlay (make-overlay start end))
+		  (overlay-put overlay 'priority 5))
+		;; Merge the specified properties with any already
+		;; applied from an earlier match.
+		(overlay-put overlay 'face
+			     (append (overlay-get overlay 'face) attributes)))))
+	  spec)))
+
 ;;
 
 (defun notmuch-common-do-stash (text)
diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index c6236db..d5f40e2 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -612,20 +612,7 @@ foreground and blue background."
 
 (defun notmuch-search-color-line (start end line-tag-list)
   "Colorize lines in `notmuch-show' based on tags."
-  ;; Create the overlay only if the message has tags which match one
-  ;; of those specified in `notmuch-search-line-faces'.
-  (let (overlay)
-    (mapc (lambda (elem)
-	    (let ((tag (car elem))
-		  (attributes (cdr elem)))
-	      (when (member tag line-tag-list)
-		(when (not overlay)
-		  (setq overlay (make-overlay start end)))
-		;; Merge the specified properties with any already
-		;; applied from an earlier match.
-		(overlay-put overlay 'face
-			     (append (overlay-get overlay 'face) attributes)))))
-	  notmuch-search-line-faces)))
+  (notmuch-color-line start end line-tag-list notmuch-search-line-faces))
 
 (defun notmuch-search-author-propertize (authors)
   "Split `authors' into matching and non-matching authors and
-- 
1.7.9.1

  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 ` Mark Walters [this message]
2012-04-29 22:48 ` [Patch v2 2/3] emacs: Add `notmuch-show-line-faces' and apply it Mark Walters
2012-05-05 11:45   ` 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-2-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).