]> git.notmuchmail.org Git - notmuch/commitdiff
emacs: get rid of trailing spaces in notmuch-hello view
authorDmitry Kurochkin <dmitry.kurochkin@gmail.com>
Sat, 10 Mar 2012 03:54:15 +0000 (07:54 +0400)
committerDavid Bremner <bremner@debian.org>
Thu, 12 Apr 2012 11:40:33 +0000 (08:40 -0300)
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.

emacs/notmuch-hello.el
test/emacs
test/emacs.expected-output/notmuch-hello
test/emacs.expected-output/notmuch-hello-long-names
test/emacs.expected-output/notmuch-hello-new-section
test/emacs.expected-output/notmuch-hello-section-counts
test/emacs.expected-output/notmuch-hello-section-hidden-tag
test/emacs.expected-output/notmuch-hello-section-with-empty
test/emacs.expected-output/notmuch-hello-with-empty

index 6b4b2c14de5cd16fc1a2c74da4f199c228ea19e7..71d37b8b9396260bf20e0c228752e7218d757e17 100644 (file)
@@ -429,7 +429,8 @@ Such a list can be computed with `notmuch-hello-query-counts'."
   (let* ((widest (notmuch-hello-longest-label searches))
         (tags-and-width (notmuch-hello-tags-per-line widest))
         (tags-per-line (car tags-and-width))
-        (widest (cdr tags-and-width))
+        (column-width (cdr tags-and-width))
+        (column-indent 0)
         (count 0)
         (reordered-list (notmuch-hello-reflect searches tags-per-line))
         ;; 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)
            ;; (not elem) indicates an empty slot in the matrix.
            (when elem
+             (if (> column-indent 0)
+                 (widget-insert (make-string column-indent ? )))
              (let* ((name (first elem))
                     (query (second elem))
-                    (msg-count (third elem))
-                    (formatted-name (format "%s " name)))
+                    (msg-count (third elem)))
                (widget-insert (format "%8s "
                                       (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)))
                (widget-create 'push-button
                               :notify #'notmuch-hello-widget-search
                               :notmuch-search-terms query
-                              formatted-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 0
-                                                  (- widest (length name)))
-                                             ? )))))
+                              name)
+               (setq column-indent
+                     (1+ (max 0 (- column-width (length name)))))))
            (setq count (1+ count))
-           (if (eq (% count tags-per-line) 0)
-               (widget-insert "\n")))
+           (when (eq (% count tags-per-line) 0)
+             (setq column-indent 0)
+             (widget-insert "\n")))
          reordered-list)
 
     ;; If the last line was not full (and hence did not include a
index c7510e913714e94c9c471631b508c37b348ad5b8..38decd0a7d22cab3b37086c05efea369747774ed 100755 (executable)
@@ -39,7 +39,7 @@ test_begin_subtest "Navigation of notmuch-hello to search results"
 test_emacs '(notmuch-hello)
            (goto-char (point-min))
            (re-search-forward "inbox")
-           (widget-button-press (point))
+           (widget-button-press (1- (point)))
            (notmuch-test-wait)
            (test-output)'
 test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox
index 147079064ec94e20ffd43e4bd18c7c6283594bae..2d698917ed992737707f7aa6618615b816f17881 100644 (file)
@@ -2,7 +2,7 @@
 
 Saved searches: [edit]
 
-         52 inbox           52 unread    
+         52 inbox           52 unread
 
 Search:                                                                     .
 
index be6d2c564f1786dfed7bc9e37ff4b400dde6d949..486d0d9ae0c8cf2e69de64f8c495c79c5e974054 100644 (file)
@@ -2,14 +2,14 @@
 
 Saved searches: [edit]
 
-         52 inbox           52 unread    
+         52 inbox           52 unread
 
 Search:                                                                     .
 
 All tags: [hide]
 
-         52 a-very-long-tag       52 inbox                 52 unread 
-          4 attachment             7 signed          
+         52 a-very-long-tag       52 inbox                 52 unread
+          4 attachment             7 signed
 
         Type a search query and hit RET to view matching threads.
                Edit saved searches with the `edit' button.
index 6a339aae3a381bb11b5063f00b743b5773b58bab..67fdef244cd371cc2a30566bccd1a9f4d40b832d 100644 (file)
@@ -1,4 +1,4 @@
 Test: [hide]
 
-         52 inbox 
+         52 inbox
 
index 9d796590360554d71728e888c94e957dd8efcadf..7a9827cf6be45b1bef1cc39044398eb3d3658076 100644 (file)
@@ -1,5 +1,5 @@
 Test-with-counts: [hide]
 
-          2 attachment             7 signed          
-          7 inbox                  7 unread          
+          2 attachment             7 signed
+          7 inbox                  7 unread
 
index 3688e7cd1126e29adbf559341c05a13414c8a959..809a1142bd8718e2aeca2da7afe674c4280f85fa 100644 (file)
@@ -1,4 +1,4 @@
 Test-with-filtered: [hide]
 
-          4 attachment            52 inbox                  7 signed 
+          4 attachment            52 inbox                  7 signed
 
index dc2568def7ddd1d3197b5802544deeeb0797b44d..5c673179239455d8c2cbb5b03c038474578bb882 100644 (file)
@@ -1,4 +1,4 @@
 Test-with-empty: [hide]
 
-         52 inbox 
+         52 inbox
 
index 5e5322210dbdfb96db71adedd84a6d8100a0a80f..854e0c2a22e891c2e00c5c7a426208af324cf604 100644 (file)
@@ -2,7 +2,7 @@
 
 Saved searches: [edit]
 
-         52 inbox           52 unread           0 empty     
+         52 inbox           52 unread           0 empty
 
 Search:                                                                     .