emacs: get rid of trailing spaces in notmuch-hello view

This patch removes trailing spaces in notmuch-hello view.

A side effect of this change is that tag/query buttons no longer
include a space at the end.  This means that pressing RET when the
point is at the first character after the tag/query button no longer
works (note that this is the standard behavior for buttons).  We may
change this behavior in the future (without adding trailing spaces
back) if people would find this change inconvenient.
This commit is contained in:
Dmitry Kurochkin 2012-03-10 07:54:15 +04:00 committed by David Bremner
parent 075d7df01e
commit 6409a27b2c
9 changed files with 23 additions and 29 deletions

View file

@ -429,7 +429,8 @@ Such a list can be computed with `notmuch-hello-query-counts'."
(let* ((widest (notmuch-hello-longest-label searches)) (let* ((widest (notmuch-hello-longest-label searches))
(tags-and-width (notmuch-hello-tags-per-line widest)) (tags-and-width (notmuch-hello-tags-per-line widest))
(tags-per-line (car tags-and-width)) (tags-per-line (car tags-and-width))
(widest (cdr tags-and-width)) (column-width (cdr tags-and-width))
(column-indent 0)
(count 0) (count 0)
(reordered-list (notmuch-hello-reflect searches tags-per-line)) (reordered-list (notmuch-hello-reflect searches tags-per-line))
;; Hack the display of the buttons used. ;; Hack the display of the buttons used.
@ -441,32 +442,25 @@ Such a list can be computed with `notmuch-hello-query-counts'."
(mapc (lambda (elem) (mapc (lambda (elem)
;; (not elem) indicates an empty slot in the matrix. ;; (not elem) indicates an empty slot in the matrix.
(when elem (when elem
(if (> column-indent 0)
(widget-insert (make-string column-indent ? )))
(let* ((name (first elem)) (let* ((name (first elem))
(query (second elem)) (query (second elem))
(msg-count (third elem)) (msg-count (third elem)))
(formatted-name (format "%s " name)))
(widget-insert (format "%8s " (widget-insert (format "%8s "
(notmuch-hello-nice-number msg-count))) (notmuch-hello-nice-number msg-count)))
(if (string= formatted-name notmuch-hello-target) (if (string= name notmuch-hello-target)
(setq found-target-pos (point-marker))) (setq found-target-pos (point-marker)))
(widget-create 'push-button (widget-create 'push-button
:notify #'notmuch-hello-widget-search :notify #'notmuch-hello-widget-search
:notmuch-search-terms query :notmuch-search-terms query
formatted-name) name)
(unless (eq (% count tags-per-line) (1- tags-per-line)) (setq column-indent
;; If this is not the last tag on the line, insert (1+ (max 0 (- column-width (length name)))))))
;; 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 0
(- widest (length name)))
? )))))
(setq count (1+ count)) (setq count (1+ count))
(if (eq (% count tags-per-line) 0) (when (eq (% count tags-per-line) 0)
(widget-insert "\n"))) (setq column-indent 0)
(widget-insert "\n")))
reordered-list) reordered-list)
;; If the last line was not full (and hence did not include a ;; If the last line was not full (and hence did not include a

View file

@ -39,7 +39,7 @@ test_begin_subtest "Navigation of notmuch-hello to search results"
test_emacs '(notmuch-hello) test_emacs '(notmuch-hello)
(goto-char (point-min)) (goto-char (point-min))
(re-search-forward "inbox") (re-search-forward "inbox")
(widget-button-press (point)) (widget-button-press (1- (point)))
(notmuch-test-wait) (notmuch-test-wait)
(test-output)' (test-output)'
test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox

View file

@ -2,7 +2,7 @@
Saved searches: [edit] Saved searches: [edit]
52 inbox 52 unread 52 inbox 52 unread
Search: . Search: .

View file

@ -2,14 +2,14 @@
Saved searches: [edit] Saved searches: [edit]
52 inbox 52 unread 52 inbox 52 unread
Search: . Search: .
All tags: [hide] All tags: [hide]
52 a-very-long-tag 52 inbox 52 unread 52 a-very-long-tag 52 inbox 52 unread
4 attachment 7 signed 4 attachment 7 signed
Type a search query and hit RET to view matching threads. Type a search query and hit RET to view matching threads.
Edit saved searches with the `edit' button. Edit saved searches with the `edit' button.

View file

@ -1,4 +1,4 @@
Test: [hide] Test: [hide]
52 inbox 52 inbox

View file

@ -1,5 +1,5 @@
Test-with-counts: [hide] Test-with-counts: [hide]
2 attachment 7 signed 2 attachment 7 signed
7 inbox 7 unread 7 inbox 7 unread

View file

@ -1,4 +1,4 @@
Test-with-filtered: [hide] Test-with-filtered: [hide]
4 attachment 52 inbox 7 signed 4 attachment 52 inbox 7 signed

View file

@ -1,4 +1,4 @@
Test-with-empty: [hide] Test-with-empty: [hide]
52 inbox 52 inbox

View file

@ -2,7 +2,7 @@
Saved searches: [edit] Saved searches: [edit]
52 inbox 52 unread 0 empty 52 inbox 52 unread 0 empty
Search: . Search: .