1 Return-Path: <dme@dme.org>
\r
2 X-Original-To: notmuch@notmuchmail.org
\r
3 Delivered-To: notmuch@notmuchmail.org
\r
4 Received: from localhost (localhost [127.0.0.1])
\r
5 by olra.theworths.org (Postfix) with ESMTP id DFE2A431FD0
\r
6 for <notmuch@notmuchmail.org>; Thu, 22 Dec 2011 04:38:46 -0800 (PST)
\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org
\r
11 X-Spam-Status: No, score=-0.7 tagged_above=-999 required=5
\r
12 tests=[RCVD_IN_DNSWL_LOW=-0.7] autolearn=disabled
\r
13 Received: from olra.theworths.org ([127.0.0.1])
\r
14 by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)
\r
15 with ESMTP id AGuxIkDiYb82 for <notmuch@notmuchmail.org>;
\r
16 Thu, 22 Dec 2011 04:38:46 -0800 (PST)
\r
17 Received: from mail-we0-f181.google.com (mail-we0-f181.google.com
\r
18 [74.125.82.181]) (using TLSv1 with cipher RC4-SHA (128/128 bits))
\r
19 (No client certificate requested)
\r
20 by olra.theworths.org (Postfix) with ESMTPS id DDF1B431FB6
\r
21 for <notmuch@notmuchmail.org>; Thu, 22 Dec 2011 04:38:45 -0800 (PST)
\r
22 Received: by werm12 with SMTP id m12so4109236wer.26
\r
23 for <notmuch@notmuchmail.org>; Thu, 22 Dec 2011 04:38:43 -0800 (PST)
\r
24 Received: by 10.216.138.148 with SMTP id a20mr11347087wej.15.1324557523413;
\r
25 Thu, 22 Dec 2011 04:38:43 -0800 (PST)
\r
26 Received: from hotblack-desiato.hh.sledj.net
\r
27 (host81-149-164-25.in-addr.btopenworld.com. [81.149.164.25])
\r
28 by mx.google.com with ESMTPS id z5sm22147967wix.5.2011.12.22.04.38.41
\r
29 (version=TLSv1/SSLv3 cipher=OTHER);
\r
30 Thu, 22 Dec 2011 04:38:42 -0800 (PST)
\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)
\r
32 id 634C49FC4F; Thu, 22 Dec 2011 12:38:40 +0000 (GMT)
\r
33 From: David Edmondson <dme@dme.org>
\r
34 To: notmuch@notmuchmail.org
\r
35 Subject: [RFC][PATCH v3] emacs: Re-implement advance/rewind functions of
\r
37 Date: Thu, 22 Dec 2011 12:38:38 +0000
\r
38 Message-Id: <1324557518-19269-1-git-send-email-dme@dme.org>
\r
39 X-Mailer: git-send-email 1.7.7.3
\r
40 In-Reply-To: <1324556204-15700-1-git-send-email-dme@dme.org>
\r
41 References: <1324556204-15700-1-git-send-email-dme@dme.org>
\r
42 X-BeenThere: notmuch@notmuchmail.org
\r
43 X-Mailman-Version: 2.1.13
\r
45 List-Id: "Use and development of the notmuch mail system."
\r
46 <notmuch.notmuchmail.org>
\r
47 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
48 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
49 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
50 List-Post: <mailto:notmuch@notmuchmail.org>
\r
51 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
52 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
53 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
54 X-List-Received-Date: Thu, 22 Dec 2011 12:38:47 -0000
\r
56 The advance/rewind functions had become complex, which made it hard to
\r
57 determine who they are expected to behave. Re-implement them simply in
\r
58 order to poll user-experience and expectation.
\r
61 This one passes the test suite and, consequently, works better when
\r
62 the last open message in a thread has trailing invisible text.
\r
64 emacs/notmuch-show.el | 124 +++++++++++++++++++++++++-----------------------
\r
65 1 files changed, 65 insertions(+), 59 deletions(-)
\r
67 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
68 index 46525aa..9fec499 100644
\r
69 --- a/emacs/notmuch-show.el
\r
70 +++ b/emacs/notmuch-show.el
\r
71 @@ -1156,38 +1156,49 @@ Some useful entries are:
\r
72 ;; Commands typically bound to keys.
\r
74 (defun notmuch-show-advance ()
\r
75 - "Advance through thread.
\r
76 + "Advance through the current thread.
\r
78 -If the current message in the thread is not yet fully visible,
\r
79 -scroll by a near screenful to read more of the message.
\r
80 +Scroll the current message if the end of it is not visible,
\r
81 +otherwise move to the next message.
\r
83 -Otherwise, (the end of the current message is already within the
\r
84 -current window), advance to the next open message."
\r
85 +Return `t' if we are at the end of the last message, otherwise
\r
88 - (let* ((end-of-this-message (notmuch-show-message-bottom))
\r
89 - (visible-end-of-this-message (1- end-of-this-message))
\r
91 - (while (invisible-p visible-end-of-this-message)
\r
92 - (setq visible-end-of-this-message
\r
93 - (previous-single-char-property-change visible-end-of-this-message
\r
96 - ;; Ideally we would test `end-of-this-message' against the result
\r
97 - ;; of `window-end', but that doesn't account for the fact that
\r
98 - ;; the end of the message might be hidden.
\r
99 - ((and visible-end-of-this-message
\r
100 - (> visible-end-of-this-message (window-end)))
\r
101 - ;; The bottom of this message is not visible - scroll.
\r
104 - ((not (= end-of-this-message (point-max)))
\r
105 - ;; This is not the last message - move to the next visible one.
\r
106 - (notmuch-show-next-open-message))
\r
109 - ;; This is the last message - change the return value
\r
114 + ;; If we are at the end of the buffer then move to the next
\r
118 + ;; Ideally we would simply do:
\r
120 + ;; ((> (notmuch-show-message-bottom) (window-end))
\r
122 + ;; here, but that fails if the trailing text in the buffer is
\r
123 + ;; invisible (`window-end' returns the last visible character,
\r
124 + ;; which can then be smaller than `notmuch-show-message-bottom').
\r
126 + ;; So we need to find the last _visible_ character of the
\r
127 + ;; message. We do this by checking the invisibility of the
\r
128 + ;; characters from `notmuch-show-message-bottom'-1 towards the start
\r
129 + ;; of the message. When we find a non-invisible character, we test
\r
130 + ;; to see whether it is visible in the window.
\r
132 + ((let ((visible-bottom
\r
134 + (goto-char (1- (notmuch-show-message-bottom)))
\r
135 + (while (invisible-p (point))
\r
138 + (> visible-bottom (window-end)))
\r
139 + ;; The end of this message is not visible - scroll.
\r
144 + ;; Show the start of the next message.
\r
145 + (notmuch-show-next-open-message)
\r
148 (defun notmuch-show-advance-and-archive ()
\r
149 "Advance through thread and archive.
\r
150 @@ -1201,44 +1212,39 @@ from each message), kills the buffer, and displays the next
\r
151 thread from the search from which this thread was originally
\r
154 - (if (notmuch-show-advance)
\r
155 - (notmuch-show-archive-thread)))
\r
156 + (when (notmuch-show-advance)
\r
157 + (notmuch-show-archive-thread)))
\r
159 (defun notmuch-show-rewind ()
\r
160 - "Backup through the thread, (reverse scrolling compared to \\[notmuch-show-advance-and-archive]).
\r
161 + "Move backwards through a thread, the counterpart to \\[notmuch-show-advance-and-archive]."
\r
163 -Specifically, if the beginning of the previous email is fewer
\r
164 -than `window-height' lines from the current point, move to it
\r
165 -just like `notmuch-show-previous-message'.
\r
167 -Otherwise, just scroll down a screenful of the current message.
\r
169 -This command does not modify any message tags, (it does not undo
\r
170 -any effects from previous calls to
\r
171 -`notmuch-show-advance-and-archive'."
\r
173 - (let ((start-of-message (notmuch-show-message-top))
\r
174 - (start-of-window (window-start)))
\r
175 + (let ((start-of-message (notmuch-show-message-top)))
\r
177 - ;; Either this message is properly aligned with the start of the
\r
178 - ;; window or the start of this message is not visible on the
\r
179 - ;; screen - scroll.
\r
180 - ((or (= start-of-message start-of-window)
\r
181 - (< start-of-message start-of-window))
\r
182 + ((= start-of-message (point))
\r
183 + ;; If the cursor is at the start of the current message, move to
\r
184 + ;; the previous open message.
\r
185 + (notmuch-show-previous-open-message))
\r
187 + ((< start-of-message (window-start))
\r
188 + ;; If the start of the current message is not visible, scroll
\r
191 - ;; If a small number of lines from the previous message are
\r
192 - ;; visible, realign so that the top of the current message is at
\r
193 - ;; the top of the screen.
\r
194 - (if (<= (count-screen-lines (window-start) start-of-message)
\r
195 - next-screen-context-lines)
\r
197 - (goto-char (notmuch-show-message-top))
\r
198 - (notmuch-show-message-adjust)))
\r
199 - ;; Move to the top left of the window.
\r
200 - (goto-char (window-start)))
\r
201 + ;; If the start of the current message became visible, align it
\r
202 + ;; with the top of the window.
\r
203 + (when (> start-of-message (window-start))
\r
204 + (goto-char start-of-message)
\r
205 + (notmuch-show-message-adjust)))
\r
207 + ((> start-of-message (window-start))
\r
208 + ;; If the cursor is not at the start of the current (visible)
\r
209 + ;; message, move it there, but do not adjust or scroll the
\r
211 + (goto-char start-of-message))
\r
214 ;; Move to the previous message.
\r
215 - (notmuch-show-previous-message)))))
\r
216 + (notmuch-show-previous-open-message)))))
\r
218 (defun notmuch-show-reply (&optional prompt-for-sender)
\r
219 "Reply to the current message."
\r