0
|
1 ;;; Commands to move around within a VM message
|
20
|
2 ;;; Copyright (C) 1989-1997 Kyle E. Jones
|
0
|
3 ;;;
|
|
4 ;;; This program is free software; you can redistribute it and/or modify
|
|
5 ;;; it under the terms of the GNU General Public License as published by
|
|
6 ;;; the Free Software Foundation; either version 1, or (at your option)
|
|
7 ;;; any later version.
|
|
8 ;;;
|
|
9 ;;; This program is distributed in the hope that it will be useful,
|
|
10 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 ;;; GNU General Public License for more details.
|
|
13 ;;;
|
|
14 ;;; You should have received a copy of the GNU General Public License
|
|
15 ;;; along with this program; if not, write to the Free Software
|
|
16 ;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
17
|
|
18 (provide 'vm-page)
|
|
19
|
|
20 (defun vm-scroll-forward (&optional arg)
|
|
21 "Scroll forward a screenful of text.
|
|
22 If the current message is being previewed, the message body is revealed.
|
|
23 If at the end of the current message, moves to the next message iff the
|
|
24 value of vm-auto-next-message is non-nil.
|
|
25 Prefix argument N means scroll forward N lines."
|
|
26 (interactive "P")
|
|
27 (let ((mp-changed (vm-follow-summary-cursor))
|
|
28 (was-invisible nil))
|
|
29 (vm-select-folder-buffer)
|
|
30 (vm-check-for-killed-summary)
|
20
|
31 (vm-check-for-killed-presentation)
|
0
|
32 (vm-error-if-folder-empty)
|
20
|
33 (and vm-presentation-buffer
|
|
34 (set-buffer vm-presentation-buffer))
|
|
35 (let ((point (point))
|
|
36 (w (vm-get-visible-buffer-window (current-buffer))))
|
|
37 (if (or (null w)
|
|
38 (not (vm-frame-totally-visible-p (vm-window-frame w))))
|
|
39 (progn
|
|
40 (vm-display (current-buffer) t
|
|
41 '(vm-scroll-forward vm-scroll-backward)
|
|
42 (list this-command 'reading-message))
|
|
43 ;; window start sticks to end of clip region when clip
|
|
44 ;; region moves back past it in the buffer. fix it.
|
|
45 (setq w (vm-get-visible-buffer-window (current-buffer)))
|
0
|
46 (if (= (window-start w) (point-max))
|
20
|
47 (set-window-start w (point-min)))
|
|
48 (setq was-invisible t))))
|
0
|
49 (if (or mp-changed was-invisible
|
|
50 (and (eq vm-system-state 'previewing)
|
|
51 (pos-visible-in-window-p
|
|
52 (point-max)
|
|
53 (vm-get-visible-buffer-window (current-buffer)))))
|
|
54 (progn
|
|
55 (if (not was-invisible)
|
|
56 (let ((w (vm-get-visible-buffer-window (current-buffer)))
|
|
57 old-w-start)
|
|
58 (setq old-w-start (window-start w))
|
|
59 (vm-display nil nil '(vm-scroll-forward vm-scroll-backward)
|
|
60 (list this-command 'reading-message))
|
|
61 (setq w (vm-get-visible-buffer-window (current-buffer)))
|
|
62 (and w (set-window-start w old-w-start))))
|
|
63 (if (eq vm-system-state 'previewing)
|
|
64 (vm-show-current-message))
|
|
65 (vm-howl-if-eom))
|
|
66 (let ((vmp vm-message-pointer)
|
|
67 (msg-buf (current-buffer))
|
|
68 (h-diff 0)
|
|
69 w old-w old-w-height old-w-start result)
|
|
70 (if (eq vm-system-state 'previewing)
|
|
71 (vm-show-current-message))
|
|
72 (setq vm-system-state 'reading)
|
|
73 (setq old-w (vm-get-visible-buffer-window msg-buf)
|
|
74 old-w-height (window-height old-w)
|
|
75 old-w-start (window-start old-w))
|
|
76 (vm-display nil nil '(vm-scroll-forward vm-scroll-backward)
|
|
77 (list this-command 'reading-message))
|
|
78 (setq w (vm-get-visible-buffer-window msg-buf))
|
|
79 (if (null w)
|
|
80 (error "current window configuration hides the message buffer.")
|
|
81 (setq h-diff (- (window-height w) old-w-height)))
|
|
82 ;; must restore this since it gets clobbered by window
|
|
83 ;; teardown and rebuild done by the window config stuff.
|
|
84 (set-window-start w old-w-start)
|
|
85 (setq old-w (selected-window))
|
|
86 (unwind-protect
|
|
87 (progn
|
|
88 (select-window w)
|
|
89 (let ((next-screen-context-lines
|
|
90 (+ next-screen-context-lines h-diff)))
|
|
91 (while (eq (setq result (vm-scroll-forward-internal arg))
|
|
92 'tryagain))
|
|
93 (cond ((and (not (eq result 'next-message))
|
|
94 vm-honor-page-delimiters)
|
|
95 (vm-narrow-to-page)
|
|
96 ;; This voodoo is required! For some
|
|
97 ;; reason the 18.52 emacs display
|
|
98 ;; doesn't immediately reflect the
|
|
99 ;; clip region change that occurs
|
|
100 ;; above without this mantra.
|
|
101 (scroll-up 0)))))
|
|
102 (select-window old-w))
|
|
103 (set-buffer msg-buf)
|
|
104 (cond ((eq result 'next-message)
|
|
105 (vm-next-message))
|
|
106 ((eq result 'end-of-message)
|
|
107 (let ((vm-message-pointer vmp))
|
|
108 (vm-emit-eom-blurb)))
|
|
109 (t
|
|
110 (and (> (prefix-numeric-value arg) 0)
|
|
111 (vm-howl-if-eom)))))))
|
20
|
112 (if (not vm-startup-message-displayed)
|
0
|
113 (vm-display-startup-message)))
|
|
114
|
|
115 (defun vm-scroll-forward-internal (arg)
|
|
116 (let ((direction (prefix-numeric-value arg))
|
|
117 (w (selected-window)))
|
|
118 (condition-case error-data
|
20
|
119 (progn
|
|
120 (if (and (> direction 0)
|
|
121 (pos-visible-in-window-p
|
|
122 (vm-text-end-of (car vm-message-pointer))))
|
|
123 (signal 'end-of-buffer nil)
|
|
124 (scroll-up arg))
|
|
125 nil )
|
0
|
126 (error
|
|
127 (if (or (and (< direction 0)
|
|
128 (> (point-min) (vm-text-of (car vm-message-pointer))))
|
|
129 (and (>= direction 0)
|
|
130 (/= (point-max)
|
|
131 (vm-text-end-of (car vm-message-pointer)))))
|
|
132 (progn
|
|
133 (vm-widen-page)
|
|
134 (if (>= direction 0)
|
|
135 (progn
|
|
136 (forward-page 1)
|
|
137 (set-window-start w (point))
|
|
138 nil )
|
|
139 (if (or (bolp)
|
|
140 (not (save-excursion
|
|
141 (beginning-of-line)
|
|
142 (looking-at page-delimiter))))
|
|
143 (forward-page -1))
|
|
144 (beginning-of-line)
|
|
145 (set-window-start w (point))
|
|
146 'tryagain))
|
|
147 (if (eq (car error-data) 'end-of-buffer)
|
|
148 (if vm-auto-next-message
|
|
149 'next-message
|
|
150 (set-window-point w (point))
|
|
151 'end-of-message)))))))
|
|
152
|
|
153 ;; exploratory scrolling, what a concept.
|
|
154 ;;
|
|
155 ;; we do this because pos-visible-in-window-p checks the current
|
|
156 ;; window configuration, while this exploratory scrolling forces
|
|
157 ;; Emacs to recompute the display, giving us an up to the moment
|
|
158 ;; answer about where the end of the message is going to be
|
|
159 ;; visible when redisplay finally does occur.
|
|
160 (defun vm-howl-if-eom ()
|
|
161 (let ((w (vm-get-visible-buffer-window (current-buffer))))
|
|
162 (and w
|
|
163 (save-excursion
|
|
164 (save-window-excursion
|
|
165 (condition-case ()
|
|
166 (let ((next-screen-context-lines 0))
|
|
167 (select-window w)
|
|
168 (save-excursion
|
|
169 (save-window-excursion
|
|
170 ;; scroll-fix.el replaces scroll-up and
|
|
171 ;; doesn't behave properly when it hits
|
|
172 ;; end of buffer. It does this!
|
|
173 ;; (ding)
|
|
174 ;; (message (get 'beginning-of-buffer 'error-message))
|
|
175 (let ((scroll-in-place-replace-original nil))
|
|
176 (scroll-up nil))))
|
|
177 nil)
|
|
178 (error t))))
|
|
179 (= (vm-text-end-of (car vm-message-pointer)) (point-max))
|
|
180 (vm-emit-eom-blurb))))
|
|
181
|
|
182 (defun vm-emit-eom-blurb ()
|
|
183 (if (vm-full-name-of (car vm-message-pointer))
|
|
184 (vm-unsaved-message "End of message %s from %s"
|
|
185 (vm-number-of (car vm-message-pointer))
|
|
186 (vm-full-name-of (car vm-message-pointer)))
|
|
187 (vm-unsaved-message "End of message %s"
|
|
188 (vm-number-of (car vm-message-pointer)))))
|
|
189
|
|
190 (defun vm-scroll-backward (arg)
|
|
191 "Scroll backward a screenful of text.
|
|
192 Prefix N scrolls backward N lines."
|
|
193 (interactive "P")
|
|
194 (vm-scroll-forward (cond ((null arg) '-)
|
|
195 ((consp arg) (list (- (car arg))))
|
|
196 ((numberp arg) (- arg))
|
|
197 ((symbolp arg) nil)
|
|
198 (t arg))))
|
|
199
|
|
200 (defun vm-highlight-headers ()
|
|
201 (cond
|
|
202 ((and (vm-xemacs-p) vm-use-lucid-highlighting)
|
|
203 (require 'highlight-headers)
|
|
204 ;; disable the url marking stuff, since VM has its own interface.
|
|
205 (let ((highlight-headers-mark-urls nil)
|
|
206 (highlight-headers-regexp (or vm-highlighted-header-regexp
|
|
207 highlight-headers-regexp)))
|
|
208 (highlight-headers (point-min) (point-max) t)))
|
|
209 ((vm-xemacs-p)
|
|
210 (let (e)
|
|
211 (map-extents (function
|
|
212 (lambda (e ignore)
|
|
213 (if (extent-property e 'vm-highlight)
|
|
214 (delete-extent e))
|
|
215 nil))
|
|
216 (current-buffer) (point-min) (point-max))
|
|
217 (goto-char (point-min))
|
|
218 (while (vm-match-header)
|
|
219 (cond ((vm-match-header vm-highlighted-header-regexp)
|
|
220 (setq e (make-extent (vm-matched-header-contents-start)
|
|
221 (vm-matched-header-contents-end)))
|
|
222 (set-extent-property e 'face vm-highlighted-header-face)
|
|
223 (set-extent-property e 'vm-highlight t)))
|
|
224 (goto-char (vm-matched-header-end)))))
|
|
225 ((fboundp 'overlay-put)
|
|
226 (let (o-lists p)
|
|
227 (setq o-lists (overlay-lists)
|
|
228 p (car o-lists))
|
|
229 (while p
|
|
230 (and (overlay-get (car p) 'vm-highlight)
|
|
231 (delete-overlay (car p)))
|
|
232 (setq p (cdr p)))
|
|
233 (setq p (cdr o-lists))
|
|
234 (while p
|
|
235 (and (overlay-get (car p) 'vm-highlight)
|
|
236 (delete-overlay (car p)))
|
|
237 (setq p (cdr p)))
|
|
238 (goto-char (point-min))
|
|
239 (while (vm-match-header)
|
|
240 (cond ((vm-match-header vm-highlighted-header-regexp)
|
|
241 (setq p (make-overlay (vm-matched-header-contents-start)
|
|
242 (vm-matched-header-contents-end)))
|
|
243 (overlay-put p 'face vm-highlighted-header-face)
|
|
244 (overlay-put p 'vm-highlight t)))
|
|
245 (goto-char (vm-matched-header-end)))))))
|
|
246
|
|
247 (defun vm-energize-urls ()
|
|
248 ;; Don't search too long in large regions. If the region is
|
|
249 ;; large, search just the head and the tail of the region since
|
|
250 ;; they tend to contain the interesting text.
|
|
251 (let ((search-limit vm-url-search-limit)
|
20
|
252 search-pairs n)
|
0
|
253 (if (and search-limit (> (- (point-max) (point-min)) search-limit))
|
|
254 (setq search-pairs (list (cons (point-min)
|
|
255 (+ (point-min) (/ search-limit 2)))
|
|
256 (cons (- (point-max) (/ search-limit 2))
|
|
257 (point-max))))
|
|
258 (setq search-pairs (list (cons (point-min) (point-max)))))
|
|
259 (cond
|
|
260 ((vm-xemacs-p)
|
|
261 (let (e)
|
|
262 (map-extents (function
|
|
263 (lambda (e ignore)
|
|
264 (if (extent-property e 'vm-url)
|
|
265 (delete-extent e))
|
|
266 nil))
|
|
267 (current-buffer) (point-min) (point-max))
|
|
268 (while search-pairs
|
|
269 (goto-char (car (car search-pairs)))
|
|
270 (while (re-search-forward vm-url-regexp (cdr (car search-pairs)) t)
|
20
|
271 (setq n 1)
|
|
272 (while (null (match-beginning n))
|
|
273 (vm-increment n))
|
|
274 (setq e (make-extent (match-beginning n) (match-end n)))
|
0
|
275 (set-extent-property e 'vm-url t)
|
|
276 (if vm-highlight-url-face
|
|
277 (set-extent-property e 'face vm-highlight-url-face))
|
|
278 (if vm-url-browser
|
|
279 (let ((keymap (make-sparse-keymap)))
|
|
280 (define-key keymap 'button2 'vm-mouse-send-url-at-event)
|
20
|
281 (if vm-popup-menu-on-mouse-3
|
|
282 (define-key keymap 'button3 'vm-menu-popup-url-browser-menu))
|
0
|
283 (define-key keymap "\r"
|
|
284 (function (lambda () (interactive)
|
|
285 (vm-mouse-send-url-at-position (point)))))
|
|
286 (set-extent-property e 'keymap keymap)
|
|
287 (set-extent-property e 'balloon-help 'vm-url-help)
|
|
288 (set-extent-property e 'highlight t))))
|
|
289 (setq search-pairs (cdr search-pairs)))))
|
|
290 ((and (vm-fsfemacs-19-p)
|
|
291 (fboundp 'overlay-put))
|
|
292 (let (o-lists o p)
|
|
293 (setq o-lists (overlay-lists)
|
|
294 p (car o-lists))
|
|
295 (while p
|
|
296 (and (overlay-get (car p) 'vm-url)
|
|
297 (delete-overlay (car p)))
|
|
298 (setq p (cdr p)))
|
|
299 (setq p (cdr o-lists))
|
|
300 (while p
|
|
301 (and (overlay-get (car p) 'vm-url)
|
|
302 (delete-overlay (car p)))
|
|
303 (setq p (cdr p)))
|
|
304 (while search-pairs
|
|
305 (goto-char (car (car search-pairs)))
|
|
306 (while (re-search-forward vm-url-regexp (cdr (car search-pairs)) t)
|
20
|
307 (setq n 1)
|
|
308 (while (null (match-beginning n))
|
|
309 (vm-increment n))
|
|
310 (setq o (make-overlay (match-beginning n) (match-end n)))
|
0
|
311 (overlay-put o 'vm-url t)
|
|
312 (if vm-highlight-url-face
|
|
313 (overlay-put o 'face vm-highlight-url-face))
|
|
314 (if vm-url-browser
|
20
|
315 (let ((keymap (make-sparse-keymap)))
|
|
316 (overlay-put o 'mouse-face 'highlight)
|
|
317 (setq keymap (nconc keymap (current-local-map)))
|
|
318 (define-key keymap "\r"
|
|
319 (function (lambda () (interactive)
|
|
320 (vm-mouse-send-url-at-position (point)))))
|
|
321 (overlay-put o 'local-map keymap))))
|
0
|
322 (setq search-pairs (cdr search-pairs))))))))
|
|
323
|
|
324 (defun vm-energize-headers ()
|
|
325 (cond
|
|
326 ((vm-xemacs-p)
|
|
327 (let ((search-tuples '(("^From:" vm-menu-author-menu)
|
|
328 ("^Subject:" vm-menu-subject-menu)))
|
|
329 regexp menu keymap e)
|
|
330 (map-extents (function
|
|
331 (lambda (e ignore)
|
|
332 (if (extent-property e 'vm-header)
|
|
333 (delete-extent e))
|
|
334 nil))
|
|
335 (current-buffer) (point-min) (point-max))
|
|
336 (while search-tuples
|
|
337 (goto-char (point-min))
|
|
338 (setq regexp (nth 0 (car search-tuples))
|
|
339 menu (symbol-value (nth 1 (car search-tuples))))
|
|
340 (while (re-search-forward regexp nil t)
|
|
341 (save-excursion (goto-char (match-beginning 0)) (vm-match-header))
|
|
342 (setq e (make-extent (vm-matched-header-contents-start)
|
|
343 (vm-matched-header-contents-end)))
|
|
344 (set-extent-property e 'vm-header t)
|
|
345 (setq keymap (make-sparse-keymap))
|
|
346 ;; Might as well make button2 do what button3 does in
|
|
347 ;; this case, since there is no default 'select'
|
|
348 ;; action.
|
|
349 (define-key keymap 'button2
|
|
350 (list 'lambda () '(interactive)
|
|
351 (list 'popup-menu (list 'quote menu))))
|
20
|
352 (if vm-popup-menu-on-mouse-3
|
|
353 (define-key keymap 'button3
|
|
354 (list 'lambda () '(interactive)
|
|
355 (list 'popup-menu (list 'quote menu)))))
|
0
|
356 (set-extent-property e 'keymap keymap)
|
|
357 (set-extent-property e 'balloon-help 'vm-mouse-3-help)
|
|
358 (set-extent-property e 'highlight t))
|
|
359 (setq search-tuples (cdr search-tuples)))))
|
|
360 ((and (vm-fsfemacs-19-p)
|
|
361 (fboundp 'overlay-put))
|
|
362 (let ((search-tuples '(("^From:" vm-menu-fsfemacs-author-menu)
|
|
363 ("^Subject:" vm-menu-fsfemacs-subject-menu)))
|
|
364 regexp menu
|
|
365 o-lists o p)
|
|
366 (setq o-lists (overlay-lists)
|
|
367 p (car o-lists))
|
|
368 (while p
|
|
369 (and (overlay-get (car p) 'vm-header)
|
|
370 (delete-overlay (car p)))
|
|
371 (setq p (cdr p)))
|
|
372 (setq p (cdr o-lists))
|
|
373 (while p
|
|
374 (and (overlay-get (car p) 'vm-header)
|
|
375 (delete-overlay (car p)))
|
|
376 (setq p (cdr p)))
|
|
377 (while search-tuples
|
|
378 (goto-char (point-min))
|
|
379 (setq regexp (nth 0 (car search-tuples))
|
|
380 menu (symbol-value (nth 1 (car search-tuples))))
|
|
381 (while (re-search-forward regexp nil t)
|
|
382 (goto-char (match-end 0))
|
|
383 (save-excursion (goto-char (match-beginning 0)) (vm-match-header))
|
|
384 (setq o (make-overlay (vm-matched-header-contents-start)
|
|
385 (vm-matched-header-contents-end)))
|
|
386 (overlay-put o 'vm-header menu)
|
|
387 (overlay-put o 'mouse-face 'highlight))
|
|
388 (setq search-tuples (cdr search-tuples)))))))
|
|
389
|
|
390 (defun vm-display-xface ()
|
|
391 (let ((case-fold-search t) e g h)
|
|
392 (if (map-extents (function
|
|
393 (lambda (e ignore)
|
|
394 (if (extent-property e 'vm-xface)
|
|
395 t
|
|
396 nil)))
|
|
397 (current-buffer) (point-min) (point-max))
|
|
398 nil
|
|
399 (goto-char (point-min))
|
|
400 (if (find-face 'vm-xface)
|
|
401 nil
|
|
402 (make-face 'vm-xface)
|
|
403 (set-face-background 'vm-xface "white")
|
|
404 (set-face-foreground 'vm-xface "black"))
|
|
405 (if (re-search-forward "^X-Face:" nil t)
|
|
406 (progn
|
|
407 (goto-char (match-beginning 0))
|
|
408 (vm-match-header)
|
|
409 (setq h (vm-matched-header))
|
|
410 (setq g (intern h vm-xface-cache))
|
|
411 (if (boundp g)
|
|
412 (setq g (symbol-value g))
|
|
413 (set g (make-glyph h))
|
|
414 (setq g (symbol-value g))
|
|
415 ;; XXX broken. Gives extra pixel lines at the
|
|
416 ;; bottom of the glyph in 19.12
|
|
417 ;;(set-glyph-baseline g 100)
|
|
418 (set-glyph-face g 'vm-xface))
|
|
419 (setq e (make-extent (vm-vheaders-of (car vm-message-pointer))
|
|
420 (vm-vheaders-of (car vm-message-pointer))))
|
|
421 (set-extent-property e 'vm-xface t)
|
|
422 (set-extent-begin-glyph e g))))))
|
|
423
|
|
424 (defun vm-url-help (object)
|
|
425 (format
|
|
426 "Use mouse button 2 to send the URL to %s.
|
|
427 Use mouse button 3 to choose a Web browser for the URL."
|
|
428 (cond ((stringp vm-url-browser) vm-url-browser)
|
|
429 ((eq vm-url-browser 'w3-fetch)
|
|
430 "Emacs W3")
|
|
431 ((eq vm-url-browser 'w3-fetch-other-frame)
|
|
432 "Emacs W3")
|
|
433 ((eq vm-url-browser 'vm-mouse-send-url-to-mosaic)
|
|
434 "Mosaic")
|
|
435 ((eq vm-url-browser 'vm-mouse-send-url-to-netscape)
|
|
436 "Netscape")
|
|
437 (t (symbol-name vm-url-browser)))))
|
|
438
|
20
|
439 (defun vm-energize-urls-in-message-region (&optional start end)
|
|
440 (save-excursion
|
|
441 (or start (setq start (vm-headers-of (car vm-message-pointer))))
|
|
442 (or end (setq end (vm-text-end-of (car vm-message-pointer))))
|
|
443 ;; energize the URLs
|
|
444 (if (or vm-highlight-url-face vm-url-browser)
|
|
445 (save-restriction
|
|
446 (widen)
|
|
447 (narrow-to-region start
|
|
448 end)
|
|
449 (vm-energize-urls)))))
|
|
450
|
|
451 (defun vm-highlight-headers-maybe ()
|
|
452 ;; highlight the headers
|
|
453 (if (or vm-highlighted-header-regexp
|
|
454 (and (vm-xemacs-p) vm-use-lucid-highlighting))
|
|
455 (save-restriction
|
|
456 (widen)
|
|
457 (narrow-to-region (vm-headers-of (car vm-message-pointer))
|
|
458 (vm-text-end-of (car vm-message-pointer)))
|
|
459 (vm-highlight-headers))))
|
|
460
|
|
461 (defun vm-energize-headers-and-xfaces ()
|
|
462 ;; energize certain headers
|
|
463 (if (and vm-use-menus (vm-menu-support-possible-p))
|
|
464 (save-restriction
|
|
465 (widen)
|
|
466 (narrow-to-region (vm-headers-of (car vm-message-pointer))
|
|
467 (vm-text-of (car vm-message-pointer)))
|
|
468 (vm-energize-headers)))
|
|
469 ;; display xfaces, if we can
|
|
470 (if (and vm-display-xfaces
|
|
471 (vm-xemacs-p)
|
|
472 (vm-multiple-frames-possible-p)
|
|
473 (featurep 'xface))
|
|
474 (save-restriction
|
|
475 (widen)
|
|
476 (narrow-to-region (vm-headers-of (car vm-message-pointer))
|
|
477 (vm-text-of (car vm-message-pointer)))
|
|
478 (vm-display-xface))))
|
|
479
|
|
480 (defun vm-narrow-for-preview ()
|
0
|
481 (widen)
|
|
482 ;; hide as much of the message body as vm-preview-lines specifies
|
|
483 (narrow-to-region
|
|
484 (vm-vheaders-of (car vm-message-pointer))
|
|
485 (cond ((not (eq vm-preview-lines t))
|
|
486 (min
|
|
487 (vm-text-end-of (car vm-message-pointer))
|
|
488 (save-excursion
|
|
489 (goto-char (vm-text-of (car vm-message-pointer)))
|
|
490 (forward-line (if (natnump vm-preview-lines) vm-preview-lines 0))
|
|
491 (point))))
|
20
|
492 (t (vm-text-end-of (car vm-message-pointer))))))
|
|
493
|
|
494 (defun vm-preview-current-message ()
|
|
495 (vm-save-buffer-excursion
|
|
496 (setq vm-system-state 'previewing)
|
|
497 (if vm-real-buffers
|
|
498 (vm-make-virtual-copy (car vm-message-pointer)))
|
|
499
|
|
500 ;; run the message select hooks.
|
|
501 (save-excursion
|
|
502 (vm-select-folder-buffer)
|
|
503 (vm-run-message-hook (car vm-message-pointer) 'vm-select-message-hook)
|
|
504 (and vm-select-new-message-hook (vm-new-flag (car vm-message-pointer))
|
|
505 (vm-run-message-hook (car vm-message-pointer)
|
|
506 'vm-select-new-message-hook))
|
|
507 (and vm-select-unread-message-hook
|
|
508 (vm-unread-flag (car vm-message-pointer))
|
|
509 (vm-run-message-hook (car vm-message-pointer)
|
|
510 'vm-select-unread-message-hook)))
|
0
|
511
|
20
|
512 (vm-narrow-for-preview)
|
|
513 (if (or vm-mime-display-function
|
|
514 (and vm-display-using-mime
|
|
515 (not (vm-mime-plain-message-p (car vm-message-pointer)))))
|
|
516 (let ((layout (vm-mm-layout (car vm-message-pointer))))
|
|
517 (vm-make-presentation-copy (car vm-message-pointer))
|
|
518 (vm-save-buffer-excursion
|
|
519 (vm-replace-buffer-in-windows (current-buffer)
|
|
520 vm-presentation-buffer))
|
|
521 (set-buffer vm-presentation-buffer)
|
|
522 (setq vm-system-state 'previewing)
|
|
523 (vm-narrow-for-preview))
|
|
524 (setq vm-presentation-buffer nil)
|
|
525 (and vm-presentation-buffer-handle
|
|
526 (vm-replace-buffer-in-windows vm-presentation-buffer-handle
|
|
527 (current-buffer))))
|
0
|
528
|
20
|
529 ;; at this point the current buffer is the presentation buffer
|
|
530 ;; if we're using one for this message.
|
|
531
|
|
532 (vm-energize-urls-in-message-region)
|
|
533 (vm-highlight-headers-maybe)
|
|
534 (vm-energize-headers-and-xfaces)
|
0
|
535
|
20
|
536 (if vm-honor-page-delimiters
|
|
537 (vm-narrow-to-page))
|
|
538 (goto-char (vm-text-of (car vm-message-pointer)))
|
|
539 ;; If we have a window, set window start appropriately.
|
|
540 (let ((w (vm-get-visible-buffer-window (current-buffer))))
|
|
541 (if w
|
|
542 (progn (set-window-start w (point-min))
|
|
543 (set-window-point w (vm-text-of (car vm-message-pointer))))))
|
|
544 (if (or (null vm-preview-lines)
|
|
545 (and (not vm-preview-read-messages)
|
|
546 (not (vm-new-flag (car vm-message-pointer)))
|
|
547 (not (vm-unread-flag (car vm-message-pointer)))))
|
|
548 (vm-show-current-message)
|
|
549 (vm-update-summary-and-mode-line))))
|
0
|
550
|
|
551 (defun vm-show-current-message ()
|
20
|
552 (and vm-display-using-mime
|
|
553 vm-auto-decode-mime-messages
|
|
554 (not vm-mime-decoded)
|
|
555 (not (vm-mime-plain-message-p (car vm-message-pointer)))
|
|
556 (vm-decode-mime-message))
|
|
557 (vm-save-buffer-excursion
|
|
558 (save-excursion
|
|
559 (save-excursion
|
|
560 (goto-char (point-min))
|
|
561 (widen)
|
|
562 (narrow-to-region (point) (vm-text-end-of (car vm-message-pointer))))
|
|
563 (if vm-honor-page-delimiters
|
|
564 (progn
|
|
565 (if (looking-at page-delimiter)
|
|
566 (forward-page 1))
|
|
567 (vm-narrow-to-page))))
|
|
568 ;; don't mark the message as read if the user can't see it!
|
|
569 (if (vm-get-visible-buffer-window (current-buffer))
|
|
570 (progn
|
|
571 (save-excursion
|
|
572 (setq vm-system-state 'showing)
|
|
573 (if vm-mail-buffer
|
|
574 (vm-set-buffer-variable vm-mail-buffer 'vm-system-state
|
|
575 'showing))
|
|
576 ;; We could be in the presentation buffer here. Since
|
|
577 ;; the presentation buffer's message pointer and sole
|
|
578 ;; message are a mockup, they will cause trouble if
|
|
579 ;; passed into the undo/update system. So we switch
|
|
580 ;; into the real message buffer to do attribute
|
|
581 ;; updates.
|
|
582 (vm-select-folder-buffer)
|
|
583 (cond ((vm-new-flag (car vm-message-pointer))
|
|
584 (vm-set-new-flag (car vm-message-pointer) nil)))
|
|
585 (cond ((vm-unread-flag (car vm-message-pointer))
|
|
586 (vm-set-unread-flag (car vm-message-pointer) nil))))
|
|
587 (vm-update-summary-and-mode-line)
|
|
588 (vm-howl-if-eom))
|
|
589 (vm-update-summary-and-mode-line))))
|
0
|
590
|
|
591 (defun vm-expose-hidden-headers ()
|
|
592 "Toggle exposing and hiding message headers that are normally not visible."
|
|
593 (interactive)
|
|
594 (vm-follow-summary-cursor)
|
|
595 (vm-select-folder-buffer)
|
|
596 (vm-check-for-killed-summary)
|
20
|
597 (vm-check-for-killed-presentation)
|
0
|
598 (vm-error-if-folder-empty)
|
20
|
599 (and vm-presentation-buffer
|
|
600 (set-buffer vm-presentation-buffer))
|
0
|
601 (vm-display (current-buffer) t '(vm-expose-hidden-headers)
|
|
602 '(vm-expose-hidden-headers reading-message))
|
|
603 (let* ((exposed (= (point-min) (vm-start-of (car vm-message-pointer)))))
|
|
604 (vm-widen-page)
|
|
605 (goto-char (point-max))
|
|
606 (widen)
|
|
607 (if exposed
|
|
608 (narrow-to-region (point) (vm-vheaders-of (car vm-message-pointer)))
|
|
609 (narrow-to-region (point) (vm-start-of (car vm-message-pointer))))
|
|
610 (goto-char (point-min))
|
|
611 (let (w)
|
|
612 (setq w (vm-get-visible-buffer-window (current-buffer)))
|
|
613 (and w (set-window-point w (point-min)))
|
|
614 (and w
|
|
615 (= (window-start w) (vm-vheaders-of (car vm-message-pointer)))
|
|
616 (not exposed)
|
|
617 (set-window-start w (vm-start-of (car vm-message-pointer)))))
|
|
618 (if vm-honor-page-delimiters
|
|
619 (vm-narrow-to-page))))
|
|
620
|
|
621 (defun vm-widen-page ()
|
|
622 (if (or (> (point-min) (vm-text-of (car vm-message-pointer)))
|
|
623 (/= (point-max) (vm-text-end-of (car vm-message-pointer))))
|
|
624 (narrow-to-region (vm-vheaders-of (car vm-message-pointer))
|
|
625 (if (or (vm-new-flag (car vm-message-pointer))
|
|
626 (vm-unread-flag (car vm-message-pointer)))
|
|
627 (vm-text-of (car vm-message-pointer))
|
|
628 (vm-text-end-of (car vm-message-pointer))))))
|
|
629
|
|
630 (defun vm-narrow-to-page ()
|
|
631 (save-excursion
|
|
632 (let (min max (omin (point-min)) (omax (point-max)))
|
|
633 (if (or (bolp) (not (save-excursion
|
|
634 (beginning-of-line)
|
|
635 (looking-at page-delimiter))))
|
|
636 (forward-page -1))
|
|
637 (setq min (point))
|
|
638 (forward-page 1)
|
|
639 (beginning-of-line)
|
|
640 (setq max (point))
|
|
641 (narrow-to-region min max))))
|
|
642
|
|
643 (defun vm-beginning-of-message ()
|
|
644 "Moves to the beginning of the current message."
|
|
645 (interactive)
|
|
646 (vm-follow-summary-cursor)
|
|
647 (vm-select-folder-buffer)
|
|
648 (vm-check-for-killed-summary)
|
20
|
649 (vm-check-for-killed-presentation)
|
0
|
650 (vm-error-if-folder-empty)
|
20
|
651 (and vm-presentation-buffer
|
|
652 (set-buffer vm-presentation-buffer))
|
0
|
653 (vm-widen-page)
|
|
654 (push-mark)
|
|
655 (vm-display (current-buffer) t '(vm-beginning-of-message)
|
|
656 '(vm-beginning-of-message reading-message))
|
|
657 (let ((osw (selected-window)))
|
|
658 (unwind-protect
|
|
659 (progn
|
|
660 (select-window (vm-get-visible-buffer-window (current-buffer)))
|
|
661 (goto-char (point-min)))
|
|
662 (if (not (eq osw (selected-window)))
|
|
663 (select-window osw))))
|
|
664 (if vm-honor-page-delimiters
|
|
665 (vm-narrow-to-page)))
|
|
666
|
|
667 (defun vm-end-of-message ()
|
|
668 "Moves to the end of the current message, exposing and flagging it read
|
|
669 as necessary."
|
|
670 (interactive)
|
|
671 (vm-follow-summary-cursor)
|
|
672 (vm-select-folder-buffer)
|
|
673 (vm-check-for-killed-summary)
|
20
|
674 (vm-check-for-killed-presentation)
|
0
|
675 (vm-error-if-folder-empty)
|
20
|
676 (and vm-presentation-buffer
|
|
677 (set-buffer vm-presentation-buffer))
|
0
|
678 (if (eq vm-system-state 'previewing)
|
|
679 (vm-show-current-message))
|
|
680 (setq vm-system-state 'reading)
|
|
681 (vm-widen-page)
|
|
682 (push-mark)
|
|
683 (vm-display (current-buffer) t '(vm-end-of-message)
|
|
684 '(vm-end-of-message reading-message))
|
|
685 (let ((osw (selected-window)))
|
|
686 (unwind-protect
|
|
687 (progn
|
|
688 (select-window (vm-get-visible-buffer-window (current-buffer)))
|
|
689 (goto-char (point-max)))
|
|
690 (if (not (eq osw (selected-window)))
|
|
691 (select-window osw))))
|
|
692 (if vm-honor-page-delimiters
|
|
693 (vm-narrow-to-page)))
|