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 E8E0A431E62 for ; Mon, 16 Jan 2012 02:30:56 -0800 (PST) X-Virus-Scanned: Debian amavisd-new at olra.theworths.org X-Spam-Flag: NO X-Spam-Score: -0.7 X-Spam-Level: X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5 tests=[RCVD_IN_DNSWL_LOW=-0.7] 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 VOPJpp-PDITe for ; Mon, 16 Jan 2012 02:30:46 -0800 (PST) Received: from mail-we0-f181.google.com (mail-we0-f181.google.com [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client certificate requested) by olra.theworths.org (Postfix) with ESMTPS id CC3E4431FC0 for ; Mon, 16 Jan 2012 02:30:45 -0800 (PST) Received: by werh12 with SMTP id h12so1290957wer.26 for ; Mon, 16 Jan 2012 02:30:44 -0800 (PST) Received: by 10.216.138.148 with SMTP id a20mr3389412wej.15.1326709844649; Mon, 16 Jan 2012 02:30:44 -0800 (PST) Received: from localhost ([109.131.75.86]) by mx.google.com with ESMTPS id l8sm18662987wiy.5.2012.01.16.02.30.43 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 16 Jan 2012 02:30:43 -0800 (PST) From: Pieter Praet To: Jameson Graef Rollins Subject: Re: [PATCH] emacs: breakout notmuch-show-advance functionality from notmuch-show-advance-and-archive In-Reply-To: <87r4z4lunp.fsf@praet.org> References: <1321219008-11690-1-git-send-email-jrollins@finestructure.net> <1321219008-11690-2-git-send-email-jrollins@finestructure.net> <87r517bs6e.fsf@praet.org> <87r4z4lunp.fsf@praet.org> User-Agent: Notmuch/0.11+78~g6c58370 (http://notmuchmail.org) Emacs/23.3.1 (x86_64-unknown-linux-gnu) Date: Mon, 16 Jan 2012 11:28:54 +0100 Message-ID: <877h0s2b6h.fsf@praet.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Notmuch Mail 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, 16 Jan 2012 10:30:57 -0000 On Thu, 12 Jan 2012 18:04:10 +0100, Pieter Praet wrote: > On Wed, 16 Nov 2011 23:47:53 +0100, Pieter Praet wrote: > > On Sun, 13 Nov 2011 13:16:48 -0800, Jameson Graef Rollins wrote: > > > This patch breaks out much of the functionality of > > > notmuch-show-advance-and-archive into a new function: > > > notmuch-show-advance. This new function does all the advancing > > > through a show buffer that notmuch-show-advance-and-archive did, > > > without all the invasive thread archiving. The return value of > > > notmuch-show-advance is nil if the bottom of the thread is not > > > reached, and t if it is. > > > > > > notmuch-show-advance-and-archive is modified to just call > > > notmuch-show-advance, and then call notmuch-show-archive-thread if the > > > return value is true. In this way the previous functionality of > > > notmuch-show-advance-and-archive is preserved. > > > > > > This provides a way for people to rebind the space bar to a more sane > > > function if they don't like the default behavior. > > > --- > > > emacs/notmuch-show.el | 38 +++++++++++++++++++++++--------------- > > > 1 files changed, 23 insertions(+), 15 deletions(-) > > > > > > diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el > > > index d5c95d8..a7f3263 100644 > > > --- a/emacs/notmuch-show.el > > > +++ b/emacs/notmuch-show.el > > > @@ -1135,26 +1135,18 @@ All currently available key bindings: > > > > > > ;; Commands typically bound to keys. > > > > > > -(defun notmuch-show-advance-and-archive () > > > - "Advance through thread and archive. > > > - > > > -This command is intended to be one of the simplest ways to > > > -process a thread of email. It does the following: > > > +(defun notmuch-show-advance () > > > + "Advance through thread. > > > > > > If the current message in the thread is not yet fully visible, > > > scroll by a near screenful to read more of the message. > > > > > > Otherwise, (the end of the current message is already within the > > > -current window), advance to the next open message. > > > - > > > -Finally, if there is no further message to advance to, and this > > > -last message is already read, then archive the entire current > > > -thread, (remove the \"inbox\" tag from each message). Also kill > > > -this buffer, and display the next thread from the search from > > > -which this thread was originally shown." > > > +current window), advance to the next open message." > > > (interactive) > > > (let* ((end-of-this-message (notmuch-show-message-bottom)) > > > - (visible-end-of-this-message (1- end-of-this-message))) > > > + (visible-end-of-this-message (1- end-of-this-message)) > > > + (ret nil)) > > > (while (invisible-p visible-end-of-this-message) > > > (setq visible-end-of-this-message > > > (previous-single-char-property-change visible-end-of-this-message > > > @@ -1173,8 +1165,24 @@ which this thread was originally shown." > > > (notmuch-show-next-open-message)) > > > > > > (t > > > - ;; This is the last message - archive the thread. > > > - (notmuch-show-archive-thread))))) > > > + ;; This is the last message - change the return value > > > + (setq ret t))) > > > + ret)) > > > + > > > +(defun notmuch-show-advance-and-archive () > > > + "Advance through thread and archive. > > > + > > > +This command is intended to be one of the simplest ways to > > > +process a thread of email. It works exactly like > > > +notmuch-show-advance, in that it scrolls through messages in a > > > +show buffer, except that when it gets to the end of the buffer it > > > +archives the entire current thread, (remove the \"inbox\" tag > > > +from each message), kills the buffer, and displays the next > > > +thread from the search from which this thread was originally > > > +shown." > > > + (interactive) > > > + (if (notmuch-show-advance) > > > + (notmuch-show-archive-thread))) > > > > > > (defun notmuch-show-rewind () > > > "Backup through the thread, (reverse scrolling compared to \\[notmuch-show-advance-and-archive]). > > > -- > > > 1.7.7.1 > > > > > > _______________________________________________ > > > notmuch mailing list > > > notmuch@notmuchmail.org > > > http://notmuchmail.org/mailman/listinfo/notmuch > > > > > > Nice one! > > > > Signed-off-by: Pieter Praet ;) > > > > > > This has also exposed a pre-existing bug: When the last visible message > > is longer than a screenful and contains a *hidden* signature, you'll > > never get to see the end of it. > > > > The culprit is presumably seeking shelter from the flyswatter @ > > `notmuch-show-message-extent' or one of its relatives: Cc'ing our > > resident invisibility guru. > > > > > > Peace > > > > -- > > Pieter > > > FYI, this bug has been fixed by Aaron Ecay [1], commit 8392a7cc, which > will be included in v0.12. Not accompanied by a test, though, so keep > an eye out for regressions. > > Maybe the following might be of use to someone: > > #+begin_src sh > msg_lines=25 > sh -c "stty rows 24 cols 80; \ > emacs -Q -nw --eval \ > '(progn > (dotimes (i ${msg_lines}) (insert \"\n\")) > (goto-char (point-min)) > (scroll-up nil) > (princ (line-number-at-pos nil)))'" > #+end_src > > This correctly returns "20", but when running the exact same thing > with Emacs in batch mode (add '--batch' option), it returns "7" ?!? > > Minor clarification, in the unlikely event anyone's wondering: A result of "20" is correct because we have 24 lines of which 3 are lost to interface (mode line, echo area and menu bar are enabled by default), and another one is "lost" due to `scroll-up' moving point to the penultimate visible line. > Peace > > -- > Pieter > > [1] id:"1324563860-21986-1-git-send-email-aaronecay@gmail.com" Peace -- Pieter