Return-Path: X-Original-To: notmuch@notmuchmail.org Delivered-To: notmuch@notmuchmail.org Received: from localhost (localhost [127.0.0.1]) by olra.theworths.org (Postfix) with ESMTP id 550684196F0 for ; Mon, 26 Apr 2010 05:16:03 -0700 (PDT) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -1.9 X-Spam-Level: X-Spam-Status: No, score=-1.9 tagged_above=-999 required=5 tests=[BAYES_00=-1.9] autolearn=ham Received: from olra.theworths.org ([127.0.0.1]) by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id m6nF5ZoNAamc for ; Mon, 26 Apr 2010 05:16:02 -0700 (PDT) Received: from mail-wy0-f181.google.com (mail-wy0-f181.google.com [74.125.82.181]) by olra.theworths.org (Postfix) with ESMTP id 7EA3B431FC1 for ; Mon, 26 Apr 2010 05:16:02 -0700 (PDT) Received: by wyj26 with SMTP id 26so650078wyj.26 for ; Mon, 26 Apr 2010 05:16:01 -0700 (PDT) Received: by 10.216.90.201 with SMTP id e51mr5152604wef.72.1272284160063; Mon, 26 Apr 2010 05:16:00 -0700 (PDT) Received: from ut.hh.sledj.net (host83-217-165-81.dsl.vispa.com [83.217.165.81]) by mx.google.com with ESMTPS id t27sm21708121wbc.17.2010.04.26.05.15.58 (version=TLSv1/SSLv3 cipher=RC4-MD5); Mon, 26 Apr 2010 05:15:59 -0700 (PDT) Received: by ut.hh.sledj.net (Postfix, from userid 1000) id A77DA59413B; Mon, 26 Apr 2010 13:16:09 +0100 (BST) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH] emacs: Fix `notmuch-search-insert-field' Date: Mon, 26 Apr 2010 13:16:07 +0100 Message-Id: <1272284167-6335-1-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.0 In-Reply-To: <1272018249-10300-1-git-send-email-dme@dme.org> References: <1272018249-10300-1-git-send-email-dme@dme.org> X-BeenThere: notmuch@notmuchmail.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Apr 2010 12:16:03 -0000 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