[PATCH] emacs: Display non-matching authors in italic.

David Edmondson dme at dme.org
Wed Apr 28 11:00:27 PDT 2010


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



More information about the notmuch mailing list