Re: [PATCH] emacs: breakout notmuch-show-advance functionality from notmuch-show...
authorPieter Praet <pieter@praet.org>
Thu, 12 Jan 2012 17:04:10 +0000 (18:04 +0100)
committerW. Trevor King <wking@tremily.us>
Fri, 7 Nov 2014 17:41:57 +0000 (09:41 -0800)
cd/bc460adf266b130ae7f1d1aec65913b2877c72 [new file with mode: 0644]

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