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 B5A2F431FD0
\r
6 for <notmuch@notmuchmail.org>; Fri, 23 Dec 2011 10:42:00 -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 J08g-re0-sLs for <notmuch@notmuchmail.org>;
\r
16 Fri, 23 Dec 2011 10:41:58 -0800 (PST)
\r
17 Received: from mail-ww0-f41.google.com (mail-ww0-f41.google.com
\r
18 [74.125.82.41]) (using TLSv1 with cipher RC4-SHA (128/128 bits)) (No client
\r
19 certificate requested) by olra.theworths.org (Postfix) with ESMTPS id
\r
20 91960431FB6 for <notmuch@notmuchmail.org>; Fri, 23 Dec 2011 10:41:58 -0800
\r
22 Received: by wgbdt12 with SMTP id dt12so12817417wgb.2
\r
23 for <notmuch@notmuchmail.org>; Fri, 23 Dec 2011 10:41:57 -0800 (PST)
\r
24 Received: by 10.216.131.90 with SMTP id l68mr14206691wei.36.1324665717236;
\r
25 Fri, 23 Dec 2011 10:41:57 -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
\r
29 en10sm10698317wbb.11.2011.12.23.10.41.55
\r
30 (version=TLSv1/SSLv3 cipher=OTHER);
\r
31 Fri, 23 Dec 2011 10:41:56 -0800 (PST)
\r
32 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)
\r
33 id 64C88A031E; Fri, 23 Dec 2011 18:41:54 +0000 (GMT)
\r
34 From: David Edmondson <dme@dme.org>
\r
35 To: notmuch@notmuchmail.org
\r
36 Subject: [RFC][PATCH v4] emacs: Re-implement advance/rewind functions of
\r
38 Date: Fri, 23 Dec 2011 18:41:52 +0000
\r
39 Message-Id: <1324665712-2419-1-git-send-email-dme@dme.org>
\r
40 X-Mailer: git-send-email 1.7.7.3
\r
41 In-Reply-To: <id:"1324553312-10972-1-git-send-email-dme@dme.org">
\r
42 References: <id:"1324553312-10972-1-git-send-email-dme@dme.org">
\r
43 X-BeenThere: notmuch@notmuchmail.org
\r
44 X-Mailman-Version: 2.1.13
\r
46 List-Id: "Use and development of the notmuch mail system."
\r
47 <notmuch.notmuchmail.org>
\r
48 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,
\r
49 <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>
\r
50 List-Archive: <http://notmuchmail.org/pipermail/notmuch>
\r
51 List-Post: <mailto:notmuch@notmuchmail.org>
\r
52 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>
\r
53 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,
\r
54 <mailto:notmuch-request@notmuchmail.org?subject=subscribe>
\r
55 X-List-Received-Date: Fri, 23 Dec 2011 18:42:00 -0000
\r
57 The advance/rewind functions had become complex, which made it hard to
\r
58 determine how they are expected to behave. Re-implement them simply in
\r
59 order to poll user-experience and expectation.
\r
62 Switched back to using `previous-single-char-property-change' now that
\r
63 Aaron explained it. Fix a bug rewinding when the start of the current
\r
66 emacs/notmuch-show.el | 132 +++++++++++++++++++++++++++----------------------
\r
67 1 files changed, 73 insertions(+), 59 deletions(-)
\r
69 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el
\r
70 index 46525aa..e914ce1 100644
\r
71 --- a/emacs/notmuch-show.el
\r
72 +++ b/emacs/notmuch-show.el
\r
73 @@ -1156,38 +1156,56 @@ Some useful entries are:
\r
74 ;; Commands typically bound to keys.
\r
76 (defun notmuch-show-advance ()
\r
77 - "Advance through thread.
\r
78 + "Advance through the current thread.
\r
80 -If the current message in the thread is not yet fully visible,
\r
81 -scroll by a near screenful to read more of the message.
\r
82 +Scroll the current message if the end of it is not visible,
\r
83 +otherwise move to the next message.
\r
85 -Otherwise, (the end of the current message is already within the
\r
86 -current window), advance to the next open message."
\r
87 +Return `t' if we are at the end of the last message, otherwise
\r
90 - (let* ((end-of-this-message (notmuch-show-message-bottom))
\r
91 - (visible-end-of-this-message (1- end-of-this-message))
\r
93 - (while (invisible-p visible-end-of-this-message)
\r
94 - (setq visible-end-of-this-message
\r
95 - (previous-single-char-property-change visible-end-of-this-message
\r
98 - ;; Ideally we would test `end-of-this-message' against the result
\r
99 - ;; of `window-end', but that doesn't account for the fact that
\r
100 - ;; the end of the message might be hidden.
\r
101 - ((and visible-end-of-this-message
\r
102 - (> visible-end-of-this-message (window-end)))
\r
103 - ;; The bottom of this message is not visible - scroll.
\r
106 - ((not (= end-of-this-message (point-max)))
\r
107 - ;; This is not the last message - move to the next visible one.
\r
108 - (notmuch-show-next-open-message))
\r
111 - ;; This is the last message - change the return value
\r
116 + ;; We are at the end of the buffer - move to the next thread.
\r
119 + ;; Ideally we would simply do:
\r
121 + ;; ((> (notmuch-show-message-bottom) (window-end))
\r
123 + ;; here, but that fails if the trailing text in the buffer is
\r
124 + ;; invisible (`window-end' returns the last _visible_ character,
\r
125 + ;; which can then be smaller than `notmuch-show-message-bottom').
\r
127 + ;; So we need to find the last visible character of the message. We
\r
128 + ;; do this by searching backwards from
\r
129 + ;; `notmuch-show-message-bottom' for changes in the `invisible'
\r
130 + ;; property until we find a non-invisible character. When we find
\r
131 + ;; such a character we test to see whether it is visible in the
\r
134 + ;; Properties change between characters - the return value of
\r
135 + ;; `previous-single-char-property-change' points to the first
\r
136 + ;; character _inside_ the region with the `invisible' property
\r
137 + ;; set. To allow for this we step backwards one character upon
\r
138 + ;; finding the start of the invisible region.
\r
140 + ((> (let ((visible-bottom (notmuch-show-message-bottom)))
\r
141 + (while (invisible-p visible-bottom)
\r
142 + (setq visible-bottom (max (point-min)
\r
143 + (1- (previous-single-char-property-change
\r
144 + visible-bottom 'invisible)))))
\r
145 + visible-bottom) (window-end))
\r
146 + ;; The end of this message is not visible - scroll to show more of
\r
152 + ;; All of the current message has been seen - show the start of
\r
153 + ;; the next open message.
\r
154 + (notmuch-show-next-open-message)
\r
157 (defun notmuch-show-advance-and-archive ()
\r
158 "Advance through thread and archive.
\r
159 @@ -1201,44 +1219,40 @@ from each message), kills the buffer, and displays the next
\r
160 thread from the search from which this thread was originally
\r
163 - (if (notmuch-show-advance)
\r
164 - (notmuch-show-archive-thread)))
\r
165 + (when (notmuch-show-advance)
\r
166 + (notmuch-show-archive-thread)))
\r
168 (defun notmuch-show-rewind ()
\r
169 - "Backup through the thread, (reverse scrolling compared to \\[notmuch-show-advance-and-archive]).
\r
170 + "Move backwards through a thread, the counterpart to \\[notmuch-show-advance-and-archive]."
\r
172 -Specifically, if the beginning of the previous email is fewer
\r
173 -than `window-height' lines from the current point, move to it
\r
174 -just like `notmuch-show-previous-message'.
\r
176 -Otherwise, just scroll down a screenful of the current message.
\r
178 -This command does not modify any message tags, (it does not undo
\r
179 -any effects from previous calls to
\r
180 -`notmuch-show-advance-and-archive'."
\r
182 - (let ((start-of-message (notmuch-show-message-top))
\r
183 - (start-of-window (window-start)))
\r
184 + (let ((start-of-message (notmuch-show-message-top)))
\r
186 - ;; Either this message is properly aligned with the start of the
\r
187 - ;; window or the start of this message is not visible on the
\r
188 - ;; screen - scroll.
\r
189 - ((or (= start-of-message start-of-window)
\r
190 - (< start-of-message start-of-window))
\r
191 + ((= start-of-message (point))
\r
192 + ;; The cursor is at the start of the current message - move to
\r
193 + ;; the previous open message.
\r
194 + (notmuch-show-previous-open-message))
\r
196 + ((< start-of-message (window-start))
\r
197 + ;; The start of the current message is not visible - scroll
\r
200 - ;; If a small number of lines from the previous message are
\r
201 - ;; visible, realign so that the top of the current message is at
\r
202 - ;; the top of the screen.
\r
203 - (if (<= (count-screen-lines (window-start) start-of-message)
\r
204 - next-screen-context-lines)
\r
206 - (goto-char (notmuch-show-message-top))
\r
207 - (notmuch-show-message-adjust)))
\r
208 - ;; Move to the top left of the window.
\r
209 - (goto-char (window-start)))
\r
210 + ;; If the start of the current message became visible, align it
\r
211 + ;; with the top of the window.
\r
212 + (when (> start-of-message (window-start))
\r
213 + (goto-char start-of-message)
\r
214 + (notmuch-show-message-adjust)))
\r
216 + ((>= start-of-message (window-start))
\r
217 + ;; The start of the current message is visible in the window.
\r
219 + ;; If the cursor is not at the start of the current message,
\r
220 + ;; move it there, but do not adjust or scroll the display.
\r
221 + (goto-char start-of-message))
\r
224 ;; Move to the previous message.
\r
225 - (notmuch-show-previous-message)))))
\r
226 + (notmuch-show-previous-open-message)))))
\r
228 (defun notmuch-show-reply (&optional prompt-for-sender)
\r
229 "Reply to the current message."
\r