unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] emacs: Display non-matching authors in italic.
@ 2010-04-28 18:00 David Edmondson
  2010-04-28 18:43 ` Jameson Rollins
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: David Edmondson @ 2010-04-28 18:00 UTC (permalink / raw)
  To: notmuch

In search mode some messages don't match the search criteria. Show
their authors names in italic.
---

Whilst enjoying knowing which authors match, I disliked the pipe
symbol. This is a proposed improvement.

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

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 7457da9..0a7a398 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -576,6 +576,22 @@ 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 'italic))
+		truncated-string)))))
+
 (defun notmuch-search-insert-field (field date count authors subject tags)
   (cond
    ((string-equal field "date")
@@ -583,13 +599,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

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-06-03 23:58 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 ` [PATCH 1/2] emacs: Display non-matching authors with a different face David Edmondson
2010-06-03 23:58   ` Carl Worth
2010-04-29  6:52 ` [PATCH 2/2] emacs: Set the `face' property rather than `font-lock-face' David Edmondson

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).