unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Edmondson <dme@dme.org>
To: notmuch@notmuchmail.org
Subject: [PATCH 1/2] emacs: Display non-matching authors with a different face.
Date: Thu, 29 Apr 2010 07:52:22 +0100	[thread overview]
Message-ID: <1272523943-25588-1-git-send-email-dme@dme.org> (raw)
In-Reply-To: <1272477627-10562-1-git-send-email-dme@dme.org>

In search mode some messages don't match the search criteria. Show
their authors names with a different face - generally darker than
those that do match.
---

At Sebastian's request, allow the face to be customised.

 emacs/notmuch.el |   36 +++++++++++++++++++++++++++++-------
 1 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 7457da9..60c0ee5 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -297,6 +297,17 @@ For a mouse binding, return nil."
   "Notmuch search mode face used to highligh tags."
   :group 'notmuch)
 
+(defface notmuch-search-non-matching-authors
+  '((((class color)
+      (background dark))
+     (:foreground "grey30"))
+    (((class color)
+      (background light))
+     (:foreground "grey60"))
+    (t (:italic t)))
+  "Face used in search mode for authors not matching the query."
+  :group 'notmuch)
+
 ;;;###autoload
 (defun notmuch-search-mode ()
   "Major mode displaying results of a notmuch search.
@@ -576,6 +587,23 @@ matching will be applied."
 		  (t
 		   (setq tags-faces (cdr tags-faces)))))))))
 
+(defun notmuch-search-insert-authors (format-string authors)
+  (insert (let* ((formatted-sample (format format-string ""))
+		 (formatted-authors (format format-string authors))
+		 (truncated-string
+		  (if (> (length formatted-authors)
+			 (length formatted-sample))
+		      (concat (substring authors 0 (- (length formatted-sample) 4)) "... ")
+		    formatted-authors)))
+	    ;; Need to save the match data to avoid interfering with
+	    ;; `notmuch-search-process-filter'.
+	    (save-match-data
+	      (if (string-match "\\(.*\\)|\\(..*\\)" truncated-string)
+		  (concat (match-string 1 truncated-string) ","
+			  (propertize (match-string 2 truncated-string)
+				      'face 'notmuch-search-non-matching-authors))
+		truncated-string)))))
+
 (defun notmuch-search-insert-field (field date count authors subject tags)
   (cond
    ((string-equal field "date")
@@ -583,13 +611,7 @@ matching will be applied."
    ((string-equal field "count")
     (insert (format (cdr (assoc field notmuch-search-result-format)) count)))
    ((string-equal field "authors")
-    (insert (let* ((format-string (cdr (assoc field notmuch-search-result-format)))
-		   (formatted-sample (format format-string ""))
-		   (formatted-authors (format format-string authors)))
-	      (if (> (length formatted-authors)
-		     (length formatted-sample))
-		  (concat (substring authors 0 (- (length formatted-sample) 4)) "... ")
-		formatted-authors))))
+    (notmuch-search-insert-authors (cdr (assoc field notmuch-search-result-format)) authors))
    ((string-equal field "subject")
     (insert (format (cdr (assoc field notmuch-search-result-format)) subject)))
    ((string-equal field "tags")
-- 
1.7.0

  parent reply	other threads:[~2010-04-29  6:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-28 18:00 [PATCH] emacs: Display non-matching authors in italic David Edmondson
2010-04-28 18:43 ` Jameson Rollins
2010-04-28 18:55   ` Dirk Hohndel
2010-04-28 19:15     ` David Edmondson
2010-04-28 19:22       ` Jameson Rollins
2010-04-29  6:52 ` David Edmondson [this message]
2010-06-03 23:58   ` [PATCH 1/2] emacs: Display non-matching authors with a different face Carl Worth
2010-04-29  6:52 ` [PATCH 2/2] emacs: Set the `face' property rather than `font-lock-face' David Edmondson

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=1272523943-25588-1-git-send-email-dme@dme.org \
    --to=dme@dme.org \
    --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).