[PATCH] 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)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:45:22 +0000 (09:45 -0800)
6f/8610aa9d9f7f54c07bddd0fd7d503af1ac0782 [new file with mode: 0644]

diff --git a/6f/8610aa9d9f7f54c07bddd0fd7d503af1ac0782 b/6f/8610aa9d9f7f54c07bddd0fd7d503af1ac0782
new file mode 100644 (file)
index 0000000..68e4da0
--- /dev/null
@@ -0,0 +1,242 @@
+Return-Path: <dmitry.kurochkin@gmail.com>\r
+X-Original-To: notmuch@notmuchmail.org\r
+Delivered-To: notmuch@notmuchmail.org\r
+Received: from localhost (localhost [127.0.0.1])\r
+       by olra.theworths.org (Postfix) with ESMTP id C1280431FC3\r
+       for <notmuch@notmuchmail.org>; Fri,  9 Mar 2012 19:55:50 -0800 (PST)\r
+X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
+X-Spam-Flag: NO\r
+X-Spam-Score: -0.799\r
+X-Spam-Level: \r
+X-Spam-Status: No, score=-0.799 tagged_above=-999 required=5\r
+       tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1,\r
+       FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled\r
+Received: from olra.theworths.org ([127.0.0.1])\r
+       by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
+       with ESMTP id yT1GOGbn8Qf6 for <notmuch@notmuchmail.org>;\r
+       Fri,  9 Mar 2012 19:55:49 -0800 (PST)\r
+Received: from mail-bk0-f53.google.com (mail-bk0-f53.google.com\r
+       [209.85.214.53]) (using TLSv1 with cipher RC4-SHA (128/128 bits))\r
+       (No client certificate requested)\r
+       by olra.theworths.org (Postfix) with ESMTPS id A2CC7431FAE\r
+       for <notmuch@notmuchmail.org>; Fri,  9 Mar 2012 19:55:47 -0800 (PST)\r
+Received: by bkwj4 with SMTP id j4so1840558bkw.26\r
+       for <notmuch@notmuchmail.org>; Fri, 09 Mar 2012 19:55:46 -0800 (PST)\r
+DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113;\r
+       h=from:to:subject:date:message-id:x-mailer;\r
+       bh=fjq0DEuj2IDjFzIckUJomvNc7eDKMMCy7JL0pTMP93w=;\r
+       b=p6ZZQzigXwD/gc8Qx41pqiIb5U3OE5lcSAIih8JN23gWnCshKk8VUf0c1NBCkpdMSh\r
+       i1Uok9pbim7EkfHVrHehxoLmK437PCiHsmg8YbpN0FuEjmiyJv0T/lljr0cUDqXMDCOb\r
+       r4gAIRlQXZZa3JWtz1zsdFc52AgS0NzzpO1ncdGHPXtcMQD9VfcEFP3d1i3/7NgS1wce\r
+       x0Bap5SE9aC9oXgP2PpeeZd1UivCyQbKWXcYP1T6z6Mv81N1bUbezCZsWRrVT1E5xBNh\r
+       nZETy2s1C3EtfGYGU8uDO0VWweZPP8xXPL+TkCLO2UhIIieNotDjfaZytLsJ65Z98rJg\r
+       x9Nw==\r
+Received: by 10.205.136.12 with SMTP id ii12mr1804042bkc.98.1331351746398;\r
+       Fri, 09 Mar 2012 19:55:46 -0800 (PST)\r
+Received: from localhost ([91.144.186.21])\r
+       by mx.google.com with ESMTPS id d5sm12542132bkb.3.2012.03.09.19.55.45\r
+       (version=TLSv1/SSLv3 cipher=OTHER);\r
+       Fri, 09 Mar 2012 19:55:45 -0800 (PST)\r
+From: Dmitry Kurochkin <dmitry.kurochkin@gmail.com>\r
+To: notmuch@notmuchmail.org\r
+Subject: [PATCH] emacs: get rid of trailing spaces in notmuch-hello view\r
+Date: Sat, 10 Mar 2012 07:54:15 +0400\r
+Message-Id: <1331351655-16921-1-git-send-email-dmitry.kurochkin@gmail.com>\r
+X-Mailer: git-send-email 1.7.9.1\r
+X-BeenThere: notmuch@notmuchmail.org\r
+X-Mailman-Version: 2.1.13\r
+Precedence: list\r
+List-Id: "Use and development of the notmuch mail system."\r
+       <notmuch.notmuchmail.org>\r
+List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
+List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
+List-Post: <mailto:notmuch@notmuchmail.org>\r
+List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
+List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
+       <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
+X-List-Received-Date: Sat, 10 Mar 2012 03:55:51 -0000\r
+\r
+This patch removes trailing spaces in notmuch-hello view.\r
+\r
+A side effect of this change is that tag/query buttons no longer\r
+include a space at the end.  This means that pressing RET when the\r
+point is at the first character after the tag/query button no longer\r
+works (note that this is the standard behavior for buttons).  We may\r
+change this behavior in the future (without adding trailing spaces\r
+back) if people would find this change inconvenient.\r
+---\r
+ emacs/notmuch-hello.el                             |   30 ++++++++------------\r
+ test/emacs                                         |    2 +-\r
+ test/emacs.expected-output/notmuch-hello           |    2 +-\r
+ .../emacs.expected-output/notmuch-hello-long-names |    6 ++--\r
+ .../notmuch-hello-new-section                      |    2 +-\r
+ .../notmuch-hello-section-counts                   |    4 +-\r
+ .../notmuch-hello-section-hidden-tag               |    2 +-\r
+ .../notmuch-hello-section-with-empty               |    2 +-\r
+ .../emacs.expected-output/notmuch-hello-with-empty |    2 +-\r
+ 9 files changed, 23 insertions(+), 29 deletions(-)\r
+\r
+diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el\r
+index 28f39f1..17f7edd 100644\r
+--- a/emacs/notmuch-hello.el\r
++++ b/emacs/notmuch-hello.el\r
+@@ -429,7 +429,8 @@ Such a list can be computed with `notmuch-hello-query-counts'."\r
+   (let* ((widest (notmuch-hello-longest-label searches))\r
+        (tags-and-width (notmuch-hello-tags-per-line widest))\r
+        (tags-per-line (car tags-and-width))\r
+-       (widest (cdr tags-and-width))\r
++       (column-width (cdr tags-and-width))\r
++       (column-indent 0)\r
+        (count 0)\r
+        (reordered-list (notmuch-hello-reflect searches tags-per-line))\r
+        ;; Hack the display of the buttons used.\r
+@@ -441,32 +442,25 @@ Such a list can be computed with `notmuch-hello-query-counts'."\r
+     (mapc (lambda (elem)\r
+           ;; (not elem) indicates an empty slot in the matrix.\r
+           (when elem\r
++            (if (> column-indent 0)\r
++                (widget-insert (make-string column-indent ? )))\r
+             (let* ((name (first elem))\r
+                    (query (second elem))\r
+-                   (msg-count (third elem))\r
+-                   (formatted-name (format "%s " name)))\r
++                   (msg-count (third elem)))\r
+               (widget-insert (format "%8s "\r
+                                      (notmuch-hello-nice-number msg-count)))\r
+-              (if (string= formatted-name notmuch-hello-target)\r
++              (if (string= name notmuch-hello-target)\r
+                   (setq found-target-pos (point-marker)))\r
+               (widget-create 'push-button\r
+                              :notify #'notmuch-hello-widget-search\r
+                              :notmuch-search-terms query\r
+-                             formatted-name)\r
+-              (unless (eq (% count tags-per-line) (1- tags-per-line))\r
+-                ;; If this is not the last tag on the line, insert\r
+-                ;; enough space to consume the rest of the column.\r
+-                ;; Because the button for the name is `(1+ (length\r
+-                ;; name))' long (due to the trailing space) we can\r
+-                ;; just insert `(- widest (length name))' spaces - the\r
+-                ;; column separator is included in the button if\r
+-                ;; `(equal widest (length name)'.\r
+-                (widget-insert (make-string (max 0\r
+-                                                 (- widest (length name)))\r
+-                                            ? )))))\r
++                             name)\r
++              (setq column-indent\r
++                    (1+ (max 0 (- column-width (length name)))))))\r
+           (setq count (1+ count))\r
+-          (if (eq (% count tags-per-line) 0)\r
+-              (widget-insert "\n")))\r
++          (when (eq (% count tags-per-line) 0)\r
++            (setq column-indent 0)\r
++            (widget-insert "\n")))\r
+         reordered-list)\r
\r
+     ;; If the last line was not full (and hence did not include a\r
+diff --git a/test/emacs b/test/emacs\r
+index 29a489c..42780af 100755\r
+--- a/test/emacs\r
++++ b/test/emacs\r
+@@ -39,7 +39,7 @@ test_begin_subtest "Navigation of notmuch-hello to search results"\r
+ test_emacs '(notmuch-hello)\r
+           (goto-char (point-min))\r
+           (re-search-forward "inbox")\r
+-          (widget-button-press (point))\r
++          (widget-button-press (1- (point)))\r
+           (notmuch-test-wait)\r
+           (test-output)'\r
+ test_expect_equal_file OUTPUT $EXPECTED/notmuch-hello-view-inbox\r
+diff --git a/test/emacs.expected-output/notmuch-hello b/test/emacs.expected-output/notmuch-hello\r
+index 1470790..2d69891 100644\r
+--- a/test/emacs.expected-output/notmuch-hello\r
++++ b/test/emacs.expected-output/notmuch-hello\r
+@@ -2,7 +2,7 @@\r
\r
+ Saved searches: [edit]\r
\r
+-        52 inbox           52 unread    \r
++        52 inbox           52 unread\r
\r
+ Search:                                                                     .\r
\r
+diff --git a/test/emacs.expected-output/notmuch-hello-long-names b/test/emacs.expected-output/notmuch-hello-long-names\r
+index be6d2c5..486d0d9 100644\r
+--- a/test/emacs.expected-output/notmuch-hello-long-names\r
++++ b/test/emacs.expected-output/notmuch-hello-long-names\r
+@@ -2,14 +2,14 @@\r
\r
+ Saved searches: [edit]\r
\r
+-        52 inbox           52 unread    \r
++        52 inbox           52 unread\r
\r
+ Search:                                                                     .\r
\r
+ All tags: [hide]\r
\r
+-        52 a-very-long-tag       52 inbox                 52 unread \r
+-         4 attachment             7 signed          \r
++        52 a-very-long-tag       52 inbox                 52 unread\r
++         4 attachment             7 signed\r
\r
+        Type a search query and hit RET to view matching threads.\r
+               Edit saved searches with the `edit' button.\r
+diff --git a/test/emacs.expected-output/notmuch-hello-new-section b/test/emacs.expected-output/notmuch-hello-new-section\r
+index 6a339aa..67fdef2 100644\r
+--- a/test/emacs.expected-output/notmuch-hello-new-section\r
++++ b/test/emacs.expected-output/notmuch-hello-new-section\r
+@@ -1,4 +1,4 @@\r
+ Test: [hide]\r
\r
+-        52 inbox \r
++        52 inbox\r
\r
+diff --git a/test/emacs.expected-output/notmuch-hello-section-counts b/test/emacs.expected-output/notmuch-hello-section-counts\r
+index 9d79659..7a9827c 100644\r
+--- a/test/emacs.expected-output/notmuch-hello-section-counts\r
++++ b/test/emacs.expected-output/notmuch-hello-section-counts\r
+@@ -1,5 +1,5 @@\r
+ Test-with-counts: [hide]\r
\r
+-         2 attachment             7 signed          \r
+-         7 inbox                  7 unread          \r
++         2 attachment             7 signed\r
++         7 inbox                  7 unread\r
\r
+diff --git a/test/emacs.expected-output/notmuch-hello-section-hidden-tag b/test/emacs.expected-output/notmuch-hello-section-hidden-tag\r
+index 3688e7c..809a114 100644\r
+--- a/test/emacs.expected-output/notmuch-hello-section-hidden-tag\r
++++ b/test/emacs.expected-output/notmuch-hello-section-hidden-tag\r
+@@ -1,4 +1,4 @@\r
+ Test-with-filtered: [hide]\r
\r
+-         4 attachment            52 inbox                  7 signed \r
++         4 attachment            52 inbox                  7 signed\r
\r
+diff --git a/test/emacs.expected-output/notmuch-hello-section-with-empty b/test/emacs.expected-output/notmuch-hello-section-with-empty\r
+index dc2568d..5c67317 100644\r
+--- a/test/emacs.expected-output/notmuch-hello-section-with-empty\r
++++ b/test/emacs.expected-output/notmuch-hello-section-with-empty\r
+@@ -1,4 +1,4 @@\r
+ Test-with-empty: [hide]\r
\r
+-        52 inbox \r
++        52 inbox\r
\r
+diff --git a/test/emacs.expected-output/notmuch-hello-with-empty b/test/emacs.expected-output/notmuch-hello-with-empty\r
+index 5e53222..854e0c2 100644\r
+--- a/test/emacs.expected-output/notmuch-hello-with-empty\r
++++ b/test/emacs.expected-output/notmuch-hello-with-empty\r
+@@ -2,7 +2,7 @@\r
\r
+ Saved searches: [edit]\r
\r
+-        52 inbox           52 unread           0 empty     \r
++        52 inbox           52 unread           0 empty\r
\r
+ Search:                                                                     .\r
\r
+-- \r
+1.7.9.1\r
+\r