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 B02CB429E25
\r
6 for <notmuch@notmuchmail.org>; Thu, 29 Dec 2011 04:08:18 -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 ET2v3gw7SuG0 for <notmuch@notmuchmail.org>;
\r
16 Thu, 29 Dec 2011 04:08:17 -0800 (PST)
\r
17 Received: from mail-qw0-f53.google.com (mail-qw0-f53.google.com
\r
18 [209.85.216.53]) (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 A983E431FB6
\r
21 for <notmuch@notmuchmail.org>; Thu, 29 Dec 2011 04:08:17 -0800 (PST)
\r
22 Received: by qadb15 with SMTP id b15so10219471qad.5
\r
23 for <notmuch@notmuchmail.org>; Thu, 29 Dec 2011 04:08:16 -0800 (PST)
\r
24 Received: by 10.224.212.10 with SMTP id gq10mr41984240qab.75.1325160495953;
\r
25 Thu, 29 Dec 2011 04:08:15 -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 ha3sm64862572qab.2.2011.12.29.04.08.14
\r
29 (version=TLSv1/SSLv3 cipher=OTHER);
\r
30 Thu, 29 Dec 2011 04:08:15 -0800 (PST)
\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)
\r
32 id 60F96A0B37; Thu, 29 Dec 2011 12:08:12 +0000 (GMT)
\r
33 From: David Edmondson <dme@dme.org>
\r
34 To: notmuch@notmuchmail.org
\r
35 Subject: [PATCH 1/2] emacs: Re-implement advance/rewind functions of
\r
37 Date: Thu, 29 Dec 2011 12:08:09 +0000
\r
38 Message-Id: <1325160490-23472-1-git-send-email-dme@dme.org>
\r
39 X-Mailer: git-send-email 1.7.7.3
\r
40 In-Reply-To: <1324665712-2419-1-git-send-email-dme@dme.org>
\r
41 References: <1324665712-2419-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, 29 Dec 2011 12:08:18 -0000
\r
56 The advance/rewind functions had become complex, which made it hard to
\r
57 determine how they are expected to behave. Re-implement them simply
\r
58 (!) in order to poll user-experience and expectation.
\r
61 Rework re-wind in light of discussion.
\r
63 emacs/notmuch-show.el | 156 +++++++++++++++++++++++++++++++------------------
\r
64 1 files changed, 99 insertions(+), 57 deletions(-)
\r
66 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
67 index 5502efd..60af88b 100644
\r
68 --- a/emacs/notmuch-show.el
\r
69 +++ b/emacs/notmuch-show.el
\r
70 @@ -1151,39 +1151,57 @@ Some useful entries are:
\r
71 ;; Commands typically bound to keys.
\r
73 (defun notmuch-show-advance ()
\r
74 - "Advance through thread.
\r
75 + "Advance through the current thread.
\r
77 -If the current message in the thread is not yet fully visible,
\r
78 -scroll by a near screenful to read more of the message.
\r
79 +Scroll the current message if the end of it is not visible,
\r
80 +otherwise move to the next message.
\r
82 -Otherwise, (the end of the current message is already within the
\r
83 -current window), advance to the next open message."
\r
84 +Return `t' if we are at the end of the last message, otherwise
\r
87 - (let* ((end-of-this-message (notmuch-show-message-bottom))
\r
88 - (visible-end-of-this-message (1- end-of-this-message))
\r
90 - (while (invisible-p visible-end-of-this-message)
\r
91 - (setq visible-end-of-this-message
\r
93 - (1- (previous-single-char-property-change
\r
94 - visible-end-of-this-message 'invisible)))))
\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 + ;; We are at the end of the buffer - move to the next thread.
\r
117 + ;; Ideally we would simply do:
\r
119 + ;; ((> (notmuch-show-message-bottom) (window-end))
\r
121 + ;; here, but that fails if the trailing text in the buffer is
\r
122 + ;; invisible (`window-end' returns the last _visible_ character,
\r
123 + ;; which can then be smaller than `notmuch-show-message-bottom').
\r
125 + ;; So we need to find the last visible character of the message. We
\r
126 + ;; do this by searching backwards from `(1-
\r
127 + ;; notmuch-show-message-bottom)' for changes in the `invisible'
\r
128 + ;; property until we find a non-invisible character. When we find
\r
129 + ;; such a character we test to see whether it is visible in the
\r
132 + ;; Properties change between characters - the return value of
\r
133 + ;; `previous-single-char-property-change' points to the first
\r
134 + ;; character _inside_ the region with the `invisible' property
\r
135 + ;; set. To allow for this we step backwards one character upon
\r
136 + ;; finding the start of the invisible region and also at the start
\r
137 + ;; of the search.
\r
139 + ((let ((visible-bottom (1- (notmuch-show-message-bottom))))
\r
140 + (while (invisible-p visible-bottom)
\r
141 + (setq visible-bottom (max (point-min)
\r
142 + (1- (previous-single-char-property-change
\r
143 + visible-bottom 'invisible)))))
\r
144 + (> visible-bottom (window-end)))
\r
145 + ;; The end of this message is not visible - scroll to show more of
\r
151 + ;; All of the current message has been seen - show the start of
\r
152 + ;; the next open message.
\r
153 + (notmuch-show-next-open-message)
\r
156 (defun notmuch-show-advance-and-archive ()
\r
157 "Advance through thread and archive.
\r
158 @@ -1201,40 +1219,64 @@ shown."
\r
159 (notmuch-show-archive-thread)))
\r
161 (defun notmuch-show-rewind ()
\r
162 - "Backup through the thread, (reverse scrolling compared to \\[notmuch-show-advance-and-archive]).
\r
163 + "Move backwards through a thread, the counterpart to \\[notmuch-show-advance-and-archive]."
\r
165 -Specifically, if the beginning of the previous email is fewer
\r
166 -than `window-height' lines from the current point, move to it
\r
167 -just like `notmuch-show-previous-message'.
\r
169 -Otherwise, just scroll down a screenful of the current message.
\r
171 -This command does not modify any message tags, (it does not undo
\r
172 -any effects from previous calls to
\r
173 -`notmuch-show-advance-and-archive'."
\r
175 - (let ((start-of-message (notmuch-show-message-top))
\r
176 - (start-of-window (window-start)))
\r
177 + (let ((start-of-message (notmuch-show-message-top)))
\r
179 - ;; Either this message is properly aligned with the start of the
\r
180 - ;; window or the start of this message is not visible on the
\r
181 - ;; screen - scroll.
\r
182 - ((or (= start-of-message start-of-window)
\r
183 - (< start-of-message start-of-window))
\r
184 + ((= start-of-message (point))
\r
185 + ;; The cursor is at the start of the current message.
\r
186 + (let ((start-of-previous (save-excursion
\r
187 + (while (and (notmuch-show-goto-message-previous)
\r
188 + (not (notmuch-show-message-visible-p))))
\r
189 + (notmuch-show-message-top))))
\r
190 + ;; If the start of the previous open message is visible on
\r
191 + ;; screen, move the cursor there, but do not adjust or scroll
\r
193 + (if (> start-of-previous (window-start))
\r
194 + (goto-char start-of-previous)
\r
196 + ;; Otherwise, the start of the previous open message is
\r
197 + ;; _not_ visible on screen.
\r
199 + ;; Scroll the window to show (some (more) of) the previous
\r
200 + ;; message and move up into it.
\r
202 + (forward-line -1)
\r
204 + ;; If the start of the previous message became visible on
\r
205 + ;; screen due to the scrolling, align it with the top of the
\r
207 + (if (> start-of-previous (window-start))
\r
209 + (goto-char start-of-previous)
\r
210 + (notmuch-show-message-adjust))
\r
211 + ;; Otherwise leave the cursor at the start of the window.
\r
212 + (goto-char (window-start))))))
\r
214 + ((< start-of-message (window-start))
\r
215 + ;; The start of the current message is not visible - scroll
\r
218 - ;; If a small number of lines from the previous message are
\r
219 - ;; visible, realign so that the top of the current message is at
\r
220 - ;; the top of the screen.
\r
221 - (if (<= (count-screen-lines (window-start) start-of-message)
\r
222 - next-screen-context-lines)
\r
223 + ;; If the start of the current message became visible, align it
\r
224 + ;; with the top of the window.
\r
225 + (if (> start-of-message (window-start))
\r
227 - (goto-char (notmuch-show-message-top))
\r
228 - (notmuch-show-message-adjust)))
\r
229 - ;; Move to the top left of the window.
\r
230 - (goto-char (window-start)))
\r
231 + (goto-char start-of-message)
\r
232 + (notmuch-show-message-adjust))
\r
233 + ;; Otherwise leave the cursor at the start of the window.
\r
234 + (goto-char (window-start))))
\r
236 + ((>= start-of-message (window-start))
\r
237 + ;; The start of the current message is visible in the window.
\r
239 + ;; Move the cursor to the start of the current message, but do
\r
240 + ;; not adjust or scroll the display.
\r
241 + (goto-char start-of-message))
\r
244 ;; Move to the previous message.
\r
245 - (notmuch-show-previous-message)))))
\r
246 + (notmuch-show-previous-open-message)))))
\r
248 (defun notmuch-show-reply (&optional prompt-for-sender)
\r
249 "Reply to the current message."
\r