From: Mark Walters Date: Mon, 9 Apr 2012 21:57:27 +0000 (+0100) Subject: Re: [PATCH] emacs: get rid of trailing spaces in notmuch-hello view X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=0a04b864e88329ad40788c289bf353655c64f91c;p=notmuch-archives.git Re: [PATCH] emacs: get rid of trailing spaces in notmuch-hello view --- diff --git a/ff/9f73f5bbefde9481fc08dc702ec3b4d43d6bdb b/ff/9f73f5bbefde9481fc08dc702ec3b4d43d6bdb new file mode 100644 index 000000000..f4d551568 --- /dev/null +++ b/ff/9f73f5bbefde9481fc08dc702ec3b4d43d6bdb @@ -0,0 +1,268 @@ +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 94F7B4041E4 + for ; Mon, 9 Apr 2012 14:57:18 -0700 (PDT) +X-Virus-Scanned: Debian amavisd-new at olra.theworths.org +X-Spam-Flag: NO +X-Spam-Score: -1.098 +X-Spam-Level: +X-Spam-Status: No, score=-1.098 tagged_above=-999 required=5 + tests=[DKIM_ADSP_CUSTOM_MED=0.001, FREEMAIL_FROM=0.001, + NML_ADSP_CUSTOM_MED=1.2, RCVD_IN_DNSWL_MED=-2.3] 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 V7g6D5Rx6cmO for ; + Mon, 9 Apr 2012 14:57:17 -0700 (PDT) +Received: from mail2.qmul.ac.uk (mail2.qmul.ac.uk [138.37.6.6]) + (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) + (No client certificate requested) + by olra.theworths.org (Postfix) with ESMTPS id 5A1524041E1 + for ; Mon, 9 Apr 2012 14:57:17 -0700 (PDT) +Received: from smtp.qmul.ac.uk ([138.37.6.40]) + by mail2.qmul.ac.uk with esmtp (Exim 4.71) + (envelope-from ) + id 1SHMaF-0007tm-6o; Mon, 09 Apr 2012 22:57:13 +0100 +Received: from 94-192-233-223.zone6.bethere.co.uk ([94.192.233.223] + helo=localhost) + by smtp.qmul.ac.uk with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.69) + (envelope-from ) + id 1SHMaE-0007MH-M3; Mon, 09 Apr 2012 22:57:11 +0100 +From: Mark Walters +To: Dmitry Kurochkin , notmuch@notmuchmail.org +Subject: Re: [PATCH] emacs: get rid of trailing spaces in notmuch-hello view +In-Reply-To: <1331351655-16921-1-git-send-email-dmitry.kurochkin@gmail.com> +References: <1331351655-16921-1-git-send-email-dmitry.kurochkin@gmail.com> +User-Agent: Notmuch/0.12+111~g5c30f66 (http://notmuchmail.org) Emacs/23.3.1 + (x86_64-pc-linux-gnu) +Date: Mon, 09 Apr 2012 22:57:27 +0100 +Message-ID: <87ty0s7em0.fsf@qmul.ac.uk> +MIME-Version: 1.0 +Content-Type: text/plain; charset=us-ascii +X-Sender-Host-Address: 94.192.233.223 +X-QM-SPAM-Info: Sender has good ham record. :) +X-QM-Body-MD5: da980ce2e611f18173bdc00bb5f5e2d1 (of first 20000 bytes) +X-SpamAssassin-Score: -1.8 +X-SpamAssassin-SpamBar: - +X-SpamAssassin-Report: The QM spam filters have analysed this message to + determine if it is + spam. We require at least 5.0 points to mark a message as spam. + This message scored -1.8 points. + Summary of the scoring: + * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, + * medium trust + * [138.37.6.40 listed in list.dnswl.org] + * 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail + provider * (markwalters1009[at]gmail.com) + * -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay + * domain + * 0.5 AWL AWL: From: address is in the auto white-list +X-QM-Scan-Virus: ClamAV says the message is clean +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: Mon, 09 Apr 2012 21:57:18 -0000 + + +This looks fine to me (but I am not a lisp expert). + +Mark + +On Sat, 10 Mar 2012, Dmitry Kurochkin wrote: +> 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 | 30 ++++++++------------ +> test/emacs | 2 +- +> test/emacs.expected-output/notmuch-hello | 2 +- +> .../emacs.expected-output/notmuch-hello-long-names | 6 ++-- +> .../notmuch-hello-new-section | 2 +- +> .../notmuch-hello-section-counts | 4 +- +> .../notmuch-hello-section-hidden-tag | 2 +- +> .../notmuch-hello-section-with-empty | 2 +- +> .../emacs.expected-output/notmuch-hello-with-empty | 2 +- +> 9 files changed, 23 insertions(+), 29 deletions(-) +> +> diff --git a/emacs/notmuch-hello.el b/emacs/notmuch-hello.el +> index 28f39f1..17f7edd 100644 +> --- a/emacs/notmuch-hello.el +> +++ b/emacs/notmuch-hello.el +> @@ -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 +> diff --git a/test/emacs b/test/emacs +> index 29a489c..42780af 100755 +> --- a/test/emacs +> +++ b/test/emacs +> @@ -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 +> diff --git a/test/emacs.expected-output/notmuch-hello b/test/emacs.expected-output/notmuch-hello +> index 1470790..2d69891 100644 +> --- a/test/emacs.expected-output/notmuch-hello +> +++ b/test/emacs.expected-output/notmuch-hello +> @@ -2,7 +2,7 @@ +> +> Saved searches: [edit] +> +> - 52 inbox 52 unread +> + 52 inbox 52 unread +> +> Search: . +> +> diff --git a/test/emacs.expected-output/notmuch-hello-long-names b/test/emacs.expected-output/notmuch-hello-long-names +> index be6d2c5..486d0d9 100644 +> --- a/test/emacs.expected-output/notmuch-hello-long-names +> +++ b/test/emacs.expected-output/notmuch-hello-long-names +> @@ -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. +> diff --git a/test/emacs.expected-output/notmuch-hello-new-section b/test/emacs.expected-output/notmuch-hello-new-section +> index 6a339aa..67fdef2 100644 +> --- a/test/emacs.expected-output/notmuch-hello-new-section +> +++ b/test/emacs.expected-output/notmuch-hello-new-section +> @@ -1,4 +1,4 @@ +> Test: [hide] +> +> - 52 inbox +> + 52 inbox +> +> diff --git a/test/emacs.expected-output/notmuch-hello-section-counts b/test/emacs.expected-output/notmuch-hello-section-counts +> index 9d79659..7a9827c 100644 +> --- a/test/emacs.expected-output/notmuch-hello-section-counts +> +++ b/test/emacs.expected-output/notmuch-hello-section-counts +> @@ -1,5 +1,5 @@ +> Test-with-counts: [hide] +> +> - 2 attachment 7 signed +> - 7 inbox 7 unread +> + 2 attachment 7 signed +> + 7 inbox 7 unread +> +> diff --git a/test/emacs.expected-output/notmuch-hello-section-hidden-tag b/test/emacs.expected-output/notmuch-hello-section-hidden-tag +> index 3688e7c..809a114 100644 +> --- a/test/emacs.expected-output/notmuch-hello-section-hidden-tag +> +++ b/test/emacs.expected-output/notmuch-hello-section-hidden-tag +> @@ -1,4 +1,4 @@ +> Test-with-filtered: [hide] +> +> - 4 attachment 52 inbox 7 signed +> + 4 attachment 52 inbox 7 signed +> +> diff --git a/test/emacs.expected-output/notmuch-hello-section-with-empty b/test/emacs.expected-output/notmuch-hello-section-with-empty +> index dc2568d..5c67317 100644 +> --- a/test/emacs.expected-output/notmuch-hello-section-with-empty +> +++ b/test/emacs.expected-output/notmuch-hello-section-with-empty +> @@ -1,4 +1,4 @@ +> Test-with-empty: [hide] +> +> - 52 inbox +> + 52 inbox +> +> diff --git a/test/emacs.expected-output/notmuch-hello-with-empty b/test/emacs.expected-output/notmuch-hello-with-empty +> index 5e53222..854e0c2 100644 +> --- a/test/emacs.expected-output/notmuch-hello-with-empty +> +++ b/test/emacs.expected-output/notmuch-hello-with-empty +> @@ -2,7 +2,7 @@ +> +> Saved searches: [edit] +> +> - 52 inbox 52 unread 0 empty +> + 52 inbox 52 unread 0 empty +> +> Search: . +> +> -- +> 1.7.9.1 +> +> _______________________________________________ +> notmuch mailing list +> notmuch@notmuchmail.org +> http://notmuchmail.org/mailman/listinfo/notmuch