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 BF2D6431FD0 for ; Tue, 10 Jan 2012 02:15:34 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled 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 4QlGiRnYjAFK for ; Tue, 10 Jan 2012 02:15:34 -0800 (PST) Received: from mail-ww0-f45.google.com (mail-ww0-f45.google.com [74.125.82.45]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id 18592431FB6 for ; Tue, 10 Jan 2012 02:15:33 -0800 (PST) Received: by wgbds11 with SMTP id ds11so2349741wgb.2 for ; Tue, 10 Jan 2012 02:15:32 -0800 (PST) Received: by 10.180.106.165 with SMTP id gv5mr33342887wib.18.1326190532661; Tue, 10 Jan 2012 02:15:32 -0800 (PST) Received: from hotblack-desiato.hh.sledj.net (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25]) by mx.google.com with ESMTPS id y5sm907043wiw.3.2012.01.10.02.15.31 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 10 Jan 2012 02:15:31 -0800 (PST) Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000) id 0E0339FE69; Tue, 10 Jan 2012 10:15:30 +0000 (GMT) From: David Edmondson To: notmuch@notmuchmail.org Subject: [PATCH] emacs: Improve `notmuch-hello' display on ttys. Date: Tue, 10 Jan 2012 10:15:28 +0000 Message-Id: <1326190528-3548-1-git-send-email-dme@dme.org> X-Mailer: git-send-email 1.7.7.3 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: Tue, 10 Jan 2012 10:15:34 -0000 Inserting spaces to pad out columns is good, except when the padding makes the line wider than the window. This looks particularly bad on a tty where there is no fringe. Hence, avoid padding the last column on each row. --- Thanks to j4ni in #notmuch for spotting this. emacs/notmuch-hello.el | 20 +++++++++++--------- 1 files changed, 11 insertions(+), 9 deletions(-) diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el index 333d4c1..02017ce 100644 --- a/emacs/notmuch-hello.el +++ b/emacs/notmuch-hello.el @@ -299,15 +299,17 @@ should be. Returns a cons cell `(tags-per-line width)'." :notify #'notmuch-hello-widget-search :notmuch-search-terms query formatted-name) - ;; Insert enough space to consume the rest of the - ;; column. Because the button for the name is `(1+ - ;; (length name))' long (due to the trailing space) we - ;; can just insert `(- widest (length name))' spaces - - ;; the column separator is included in the button if - ;; `(equal widest (length name)'. - (widget-insert (make-string (max 1 - (- widest (length name))) - ? )))) + (unless (eq (% count tags-per-line) (1- tags-per-line)) + ;; If this is not the last tag on the line, insert + ;; enough space to consume the rest of the column. + ;; Because the button for the name is `(1+ (length + ;; name))' long (due to the trailing space) we can + ;; just insert `(- widest (length name))' spaces - the + ;; column separator is included in the button if + ;; `(equal widest (length name)'. + (widget-insert (make-string (max 1 + (- widest (length name))) + ? ))))) (setq count (1+ count)) (if (eq (% count tags-per-line) 0) (widget-insert "\n"))) -- 1.7.7.3