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 382184196F2 for ; Fri, 23 Apr 2010 03:24:17 -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 aFasxxK5Q2C1 for ; Fri, 23 Apr 2010 03:24:16 -0700 (PDT) Received: from mail-ww0-f53.google.com (mail-ww0-f53.google.com [74.125.82.53]) by olra.theworths.org (Postfix) with ESMTP id 4590B431FC1 for ; Fri, 23 Apr 2010 03:24:16 -0700 (PDT) Received: by wwb28 with SMTP id 28so2887942wwb.26 for ; Fri, 23 Apr 2010 03:24:15 -0700 (PDT) Received: by 10.216.157.145 with SMTP id o17mr8066609wek.125.1272018255026; Fri, 23 Apr 2010 03:24:15 -0700 (PDT) Received: from ut.hh.sledj.net (gmp-ea-fw-1.sun.com [192.18.1.36]) by mx.google.com with ESMTPS id z34sm499609wbv.8.2010.04.23.03.24.13 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 23 Apr 2010 03:24:14 -0700 (PDT) Received: by ut.hh.sledj.net (Postfix, from userid 1000) id 004E3594135; Fri, 23 Apr 2010 11:24:12 +0100 (BST) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH] emacs: Remove `notmuch-search-authors-width' and fix the use of `notmuch-search-result-format' accordingly Date: Fri, 23 Apr 2010 11:24:09 +0100 Message-Id: <1272018249-10300-1-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.0 In-Reply-To: <87633jo2st.fsf@ut.hh.sledj.net> References: <87633jo2st.fsf@ut.hh.sledj.net> 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: Fri, 23 Apr 2010 10:24:17 -0000 The width of the authors field in search output was previously specified in two places: - `notmuch-search-authors-width': the limit beyond which the authors names are truncated, - `notmuch-search-result-format': the layout of the search results. Changing the configuration of one of these may have required the user to know about and adapt the other accordingly. This led to confusion. Instead, remove `notmuch-search-authors-width' and perform truncation based on the relevant field in `notmuch-search-result-format'. --- Jamie, could you test this patch please? My main concern is that it makes a small assumption about the value of `notmuch-search-result-format' - namely that the `authors' field ends with a space. emacs/notmuch.el | 16 ++++++---------- 1 files changed, 6 insertions(+), 10 deletions(-) diff --git a/emacs/notmuch.el b/emacs/notmuch.el index f96394a..d40c36e 100644 --- a/emacs/notmuch.el +++ b/emacs/notmuch.el @@ -55,15 +55,10 @@ (require 'notmuch-show) (require 'notmuch-mua) -(defcustom notmuch-search-authors-width 20 - "Number of columns to use to display authors in a notmuch-search buffer." - :type 'integer - :group 'notmuch) - (defcustom notmuch-search-result-format `(("date" . "%s ") ("count" . "%-7s ") - ("authors" . ,(format "%%-%ds " notmuch-search-authors-width)) + ("authors" . "%-20s ") ("subject" . "%s ") ("tags" . "(%s)")) "Search result formating. Supported fields are: @@ -585,7 +580,11 @@ matching will be applied." ((string-equal field "count") (insert (format (cdr (assoc field notmuch-search-result-format)) count))) ((string-equal field "authors") - (insert (format (cdr (assoc field notmuch-search-result-format)) 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))))) ((string-equal field "subject") (insert (format (cdr (assoc field notmuch-search-result-format)) subject))) ((string-equal field "tags") @@ -614,12 +613,9 @@ matching will be applied." (date (match-string 2 string)) (count (match-string 3 string)) (authors (match-string 4 string)) - (authors-length (length authors)) (subject (match-string 5 string)) (tags (match-string 6 string)) (tag-list (if tags (save-match-data (split-string tags))))) - (if (> authors-length notmuch-search-authors-width) - (set 'authors (concat (substring authors 0 (- notmuch-search-authors-width 3)) "..."))) (goto-char (point-max)) (let ((beg (point-marker))) (notmuch-search-show-result date count authors subject tags) -- 1.7.0