unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
From: David Edmondson <dme@dme.org>
To: notmuch@notmuchmail.org
Subject: [PATCH] emacs: Fix `notmuch-search-insert-field'
Date: Mon, 26 Apr 2010 13:16:07 +0100	[thread overview]
Message-ID: <1272284167-6335-1-git-send-email-dme@dme.org> (raw)
In-Reply-To: <1272018249-10300-1-git-send-email-dme@dme.org>

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

  parent reply	other threads:[~2010-04-26 12:16 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-21 23:09 problem with notmuch-search-authors-width in JSON emacs implementation Jameson Rollins
2010-04-21 23:23 ` Dirk Hohndel
2010-04-22  4:37 ` Jameson Rollins
2010-04-22  7:52   ` David Edmondson
2010-04-22 13:22     ` Jameson Rollins
2010-04-22 14:04       ` David Edmondson
2010-04-22 14:12         ` Jameson Rollins
2010-04-22 14:38           ` David Edmondson
2010-04-22 15:20             ` Jameson Rollins
2010-04-22 16:44               ` David Edmondson
2010-04-23 10:24                 ` [PATCH] emacs: Remove `notmuch-search-authors-width' and fix the use of `notmuch-search-result-format' accordingly David Edmondson
2010-04-23 17:22                   ` Jameson Rollins
2010-04-23 19:17                     ` Carl Worth
2010-04-26 12:16                   ` David Edmondson [this message]
2010-04-26 15:25                     ` [PATCH] emacs: Fix `notmuch-search-insert-field' Carl Worth

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=1272284167-6335-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).