Re: [PATCH v4 01/16] add util/search-path.{c, h} to test for executables in $PATH
[notmuch-archives.git] / 0a / e7d1b616610da8a74d558959229b704009fd62
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 7CBA5431FD0\r
6         for <notmuch@notmuchmail.org>; Thu, 22 Dec 2011 04:16:51 -0800 (PST)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: -0.7\r
10 X-Spam-Level: \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 JpR9w29sTpbG for <notmuch@notmuchmail.org>;\r
16         Thu, 22 Dec 2011 04:16:50 -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 84FCF431FB6\r
21         for <notmuch@notmuchmail.org>; Thu, 22 Dec 2011 04:16:50 -0800 (PST)\r
22 Received: by werm12 with SMTP id m12so4094491wer.26\r
23         for <notmuch@notmuchmail.org>; Thu, 22 Dec 2011 04:16:49 -0800 (PST)\r
24 Received: by 10.216.134.149 with SMTP id s21mr5786059wei.41.1324556209294;\r
25         Thu, 22 Dec 2011 04:16:49 -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 d17sm9483773wbh.19.2011.12.22.04.16.47\r
29         (version=TLSv1/SSLv3 cipher=OTHER);\r
30         Thu, 22 Dec 2011 04:16:47 -0800 (PST)\r
31 Received: by hotblack-desiato.hh.sledj.net (Postfix, from userid 30000)\r
32         id 982D59FC4F; Thu, 22 Dec 2011 12:16:45 +0000 (GMT)\r
33 From: David Edmondson <dme@dme.org>\r
34 To: notmuch@notmuchmail.org\r
35 Subject: [RFC][PATCH v2] emacs: Re-implement advance/rewind functions of\r
36         notmuch-show-mode.\r
37 Date: Thu, 22 Dec 2011 12:16:44 +0000\r
38 Message-Id: <1324556204-15700-1-git-send-email-dme@dme.org>\r
39 X-Mailer: git-send-email 1.7.7.3\r
40 In-Reply-To: <1324553312-10972-1-git-send-email-dme@dme.org>\r
41 References: <1324553312-10972-1-git-send-email-dme@dme.org>\r
42 X-BeenThere: notmuch@notmuchmail.org\r
43 X-Mailman-Version: 2.1.13\r
44 Precedence: list\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:16:51 -0000\r
55 \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
59 ---\r
60 \r
61 Re-introduce the detection of invisible trailers. Using\r
62 `previous-single-char-property-change' just didn't work in my testing,\r
63 so back to the original approach. Dmitry: can you explain why you\r
64 needed to change it?\r
65 \r
66  emacs/notmuch-show.el |  126 ++++++++++++++++++++++++++-----------------------\r
67  1 files changed, 67 insertions(+), 59 deletions(-)\r
68 \r
69 diff --git a/emacs/notmuch-show.el b/emacs/notmuch-show.el\r
70 index 46525aa..258814e 100644\r
71 --- a/emacs/notmuch-show.el\r
72 +++ b/emacs/notmuch-show.el\r
73 @@ -1156,38 +1156,51 @@ Some useful entries are:\r
74  ;; Commands typically bound to keys.\r
75  \r
76  (defun notmuch-show-advance ()\r
77 -  "Advance through thread.\r
78 +  "Advance through the current thread.\r
79  \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
84  \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
88 +`nil'."\r
89    (interactive)\r
90 -  (let* ((end-of-this-message (notmuch-show-message-bottom))\r
91 -        (visible-end-of-this-message (1- end-of-this-message))\r
92 -        (ret nil))\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
96 -                                                 'invisible)))\r
97 -    (cond\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
104 -      (scroll-up nil))\r
105 -\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
109 -\r
110 -     (t\r
111 -      ;; This is the last message - change the return value\r
112 -      (setq ret t)))\r
113 -    ret))\r
114 +  (cond\r
115 +   ((eobp)\r
116 +    ;; If we are at the end of the buffer then move to the next\r
117 +    ;; thread.\r
118 +    t)\r
119 +\r
120 +   ;; Ideally we would simply do:\r
121 +   ;; \r
122 +   ;;  ((> (notmuch-show-message-bottom) (window-end))\r
123 +   ;; \r
124 +   ;; here, but that fails if the trailing text in the buffer is\r
125 +   ;; invisible (`window-end' returns the last visible character,\r
126 +   ;; which can then be smaller than `notmuch-show-message-bottom').\r
127 +   ;;\r
128 +   ;; So we need to find the last _visible_ character of the\r
129 +   ;; message. We do this by checking the invisibility of the\r
130 +   ;; characters from `notmuch-show-message-bottom' towards the start\r
131 +   ;; of the message. When we find a non-invisible character, we test\r
132 +   ;; to see whether it is visible in the window (i.e. less than\r
133 +   ;; `window-end').\r
134 +\r
135 +   ((let* ((visible-bottom (notmuch-show-message-bottom))\r
136 +          (visible-bottom \r
137 +           (save-excursion\r
138 +             (goto-char visible-bottom)\r
139 +             (while (invisible-p (point))\r
140 +               (backward-char))\r
141 +             (point))))\r
142 +      (> visible-bottom (window-end)))\r
143 +    ;; The end of this message is not visible - scroll.\r
144 +    (scroll-up)\r
145 +    nil)\r
146 +\r
147 +   (t\r
148 +    ;; Show the start of the next message.\r
149 +    (notmuch-show-next-open-message)\r
150 +    nil)))\r
151  \r
152  (defun notmuch-show-advance-and-archive ()\r
153    "Advance through thread and archive.\r
154 @@ -1201,44 +1214,39 @@ from each message), kills the buffer, and displays the next\r
155  thread from the search from which this thread was originally\r
156  shown."\r
157    (interactive)\r
158 -  (if (notmuch-show-advance)\r
159 -      (notmuch-show-archive-thread)))\r
160 +  (when (notmuch-show-advance)\r
161 +    (notmuch-show-archive-thread)))\r
162  \r
163  (defun notmuch-show-rewind ()\r
164 -  "Backup through the thread, (reverse scrolling compared to \\[notmuch-show-advance-and-archive]).\r
165 +  "Move backwards through a thread, the counterpart to \\[notmuch-show-advance-and-archive]."\r
166  \r
167 -Specifically, if the beginning of the previous email is fewer\r
168 -than `window-height' lines from the current point, move to it\r
169 -just like `notmuch-show-previous-message'.\r
170 -\r
171 -Otherwise, just scroll down a screenful of the current message.\r
172 -\r
173 -This command does not modify any message tags, (it does not undo\r
174 -any effects from previous calls to\r
175 -`notmuch-show-advance-and-archive'."\r
176    (interactive)\r
177 -  (let ((start-of-message (notmuch-show-message-top))\r
178 -       (start-of-window (window-start)))\r
179 +  (let ((start-of-message (notmuch-show-message-top)))\r
180      (cond\r
181 -      ;; Either this message is properly aligned with the start of the\r
182 -      ;; window or the start of this message is not visible on the\r
183 -      ;; screen - scroll.\r
184 -     ((or (= start-of-message start-of-window)\r
185 -         (< start-of-message start-of-window))\r
186 +     ((= start-of-message (point))\r
187 +      ;; If the cursor is at the start of the current message, move to\r
188 +      ;; the previous open message.\r
189 +      (notmuch-show-previous-open-message))\r
190 +\r
191 +     ((< start-of-message (window-start))\r
192 +      ;; If the start of the current message is not visible, scroll\r
193 +      ;; down.\r
194        (scroll-down)\r
195 -      ;; If a small number of lines from the previous message are\r
196 -      ;; visible, realign so that the top of the current message is at\r
197 -      ;; the top of the screen.\r
198 -      (if (<= (count-screen-lines (window-start) start-of-message)\r
199 -             next-screen-context-lines)\r
200 -         (progn\r
201 -           (goto-char (notmuch-show-message-top))\r
202 -           (notmuch-show-message-adjust)))\r
203 -      ;; Move to the top left of the window.\r
204 -      (goto-char (window-start)))\r
205 +      ;; If the start of the current message became visible, align it\r
206 +      ;; with the top of the window.\r
207 +      (when (> start-of-message (window-start))\r
208 +       (goto-char start-of-message)\r
209 +       (notmuch-show-message-adjust)))\r
210 +\r
211 +     ((> start-of-message (window-start))\r
212 +      ;; If the cursor is not at the start of the current (visible)\r
213 +      ;; message, move it there, but do not adjust or scroll the\r
214 +      ;; display.\r
215 +      (goto-char start-of-message))\r
216 +\r
217       (t\r
218        ;; Move to the previous message.\r
219 -      (notmuch-show-previous-message)))))\r
220 +      (notmuch-show-previous-open-message)))))\r
221  \r
222  (defun notmuch-show-reply (&optional prompt-for-sender)\r
223    "Reply to the current message."\r
224 -- \r
225 1.7.7.3\r
226 \r