emacs: Improve `notmuch-hello' display on ttys.

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.
This commit is contained in:
David Edmondson 2012-01-10 10:15:28 +00:00 committed by David Bremner
parent 3f9d73884e
commit 38546e4acb

View file

@ -299,15 +299,17 @@ should be. Returns a cons cell `(tags-per-line width)'."
:notify #'notmuch-hello-widget-search :notify #'notmuch-hello-widget-search
:notmuch-search-terms query :notmuch-search-terms query
formatted-name) formatted-name)
;; Insert enough space to consume the rest of the (unless (eq (% count tags-per-line) (1- tags-per-line))
;; column. Because the button for the name is `(1+ ;; If this is not the last tag on the line, insert
;; (length name))' long (due to the trailing space) we ;; enough space to consume the rest of the column.
;; can just insert `(- widest (length name))' spaces - ;; Because the button for the name is `(1+ (length
;; the column separator is included in the button if ;; name))' long (due to the trailing space) we can
;; `(equal widest (length name)'. ;; just insert `(- widest (length name))' spaces - the
(widget-insert (make-string (max 1 ;; column separator is included in the button if
(- widest (length name))) ;; `(equal widest (length name)'.
? )))) (widget-insert (make-string (max 1
(- widest (length name)))
? )))))
(setq count (1+ count)) (setq count (1+ count))
(if (eq (% count tags-per-line) 0) (if (eq (% count tags-per-line) 0)
(widget-insert "\n"))) (widget-insert "\n")))