[PATCH] emacs: Fix `notmuch-search-insert-field'

David Edmondson dme at dme.org
Mon Apr 26 05:16:07 PDT 2010


Compare the formatted version of the authors with the formatted sample
string rather than the un-formatted authors with the formatted sample
string.
---

Carl, please pull this in for 0.3. The previous fix didn't work
correctly when the authors string was one character shorter than the
length specified in the format string (presuming that the format
string is broadly unchanged from the default).

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

diff --git a/emacs/notmuch.el b/emacs/notmuch.el
index 378c004..eecff23 100644
--- a/emacs/notmuch.el
+++ b/emacs/notmuch.el
@@ -582,11 +582,13 @@ matching will be applied."
    ((string-equal field "count")
     (insert (format (cdr (assoc field notmuch-search-result-format)) count)))
    ((string-equal field "authors")
-    (insert (let ((sample (format (cdr (assoc field notmuch-search-result-format)) "")))
-	      (if (> (length authors)
-		     (length sample))
-		  (concat (substring authors 0 (- (length sample) 4)) "... ")
-		(format (cdr (assoc field notmuch-search-result-format)) 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))))
    ((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