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
|
24
|
119 (progn (scroll-up arg) nil)
|
|
120 ;; this looks like it should work, but doesn't because the
|
|
121 ;; redisplay code is schizophrenic when it comes to updates. A
|
|
122 ;; window position may no longer be visible but
|
|
123 ;; pos-visible-in-window-p will still say it is because it was
|
|
124 ;; visible before some window size change happened.
|
|
125 ;; (progn
|
|
126 ;; (if (and (> direction 0)
|
|
127 ;; (pos-visible-in-window-p
|
|
128 ;; (vm-text-end-of (car vm-message-pointer))))
|
|
129 ;; (signal 'end-of-buffer nil)
|
|
130 ;; (scroll-up arg))
|
|
131 ;; nil )
|
0
|
132 (error
|
|
133 (if (or (and (< direction 0)
|
|
134 (> (point-min) (vm-text-of (car vm-message-pointer))))
|
|
135 (and (>= direction 0)
|
|
136 (/= (point-max)
|
|
137 (vm-text-end-of (car vm-message-pointer)))))
|
|
138 (progn
|
|
139 (vm-widen-page)
|
|
140 (if (>= direction 0)
|
|
141 (progn
|
|
142 (forward-page 1)
|
|
143 (set-window-start w (point))
|
|
144 nil )
|
|
145 (if (or (bolp)
|
|
146 (not (save-excursion
|
|
147 (beginning-of-line)
|
|
148 (looking-at page-delimiter))))
|
|
149 (forward-page -1))
|
|
150 (beginning-of-line)
|
|
151 (set-window-start w (point))
|
|
152 'tryagain))
|
|
153 (if (eq (car error-data) 'end-of-buffer)
|
|
154 (if vm-auto-next-message
|
|
155 'next-message
|
|
156 (set-window-point w (point))
|
|
157 'end-of-message)))))))
|
|
158
|
|
159 ;; exploratory scrolling, what a concept.
|
|
160 ;;
|
|
161 ;; we do this because pos-visible-in-window-p checks the current
|
|
162 ;; window configuration, while this exploratory scrolling forces
|
|
163 ;; Emacs to recompute the display, giving us an up to the moment
|
|
164 ;; answer about where the end of the message is going to be
|
|
165 ;; visible when redisplay finally does occur.
|
|
166 (defun vm-howl-if-eom ()
|
|
167 (let ((w (vm-get-visible-buffer-window (current-buffer))))
|
|
168 (and w
|
|
169 (save-excursion
|
|
170 (save-window-excursion
|
|
171 (condition-case ()
|
|
172 (let ((next-screen-context-lines 0))
|
|
173 (select-window w)
|
|
174 (save-excursion
|
|
175 (save-window-excursion
|
|
176 ;; scroll-fix.el replaces scroll-up and
|
|
177 ;; doesn't behave properly when it hits
|
|
178 ;; end of buffer. It does this!
|
|
179 ;; (ding)
|
|
180 ;; (message (get 'beginning-of-buffer 'error-message))
|
|
181 (let ((scroll-in-place-replace-original nil))
|
|
182 (scroll-up nil))))
|
|
183 nil)
|
|
184 (error t))))
|
|
185 (= (vm-text-end-of (car vm-message-pointer)) (point-max))
|
|
186 (vm-emit-eom-blurb))))
|
|
187
|
|
188 (defun vm-emit-eom-blurb ()
|
|
189 (if (vm-full-name-of (car vm-message-pointer))
|
26
|
190 (message "End of message %s from %s"
|
0
|
191 (vm-number-of (car vm-message-pointer))
|
|
192 (vm-full-name-of (car vm-message-pointer)))
|
26
|
193 (message "End of message %s"
|
0
|
194 (vm-number-of (car vm-message-pointer)))))
|
|
195
|
|
196 (defun vm-scroll-backward (arg)
|
|
197 "Scroll backward a screenful of text.
|
|
198 Prefix N scrolls backward N lines."
|
|
199 (interactive "P")
|
|
200 (vm-scroll-forward (cond ((null arg) '-)
|
|
201 ((consp arg) (list (- (car arg))))
|
|
202 ((numberp arg) (- arg))
|
|
203 ((symbolp arg) nil)
|
|
204 (t arg))))
|
|
205
|
|
206 (defun vm-highlight-headers ()
|
|
207 (cond
|
|
208 ((and (vm-xemacs-p) vm-use-lucid-highlighting)
|
|
209 (require 'highlight-headers)
|
|
210 ;; disable the url marking stuff, since VM has its own interface.
|
|
211 (let ((highlight-headers-mark-urls nil)
|
|
212 (highlight-headers-regexp (or vm-highlighted-header-regexp
|
|
213 highlight-headers-regexp)))
|
|
214 (highlight-headers (point-min) (point-max) t)))
|
|
215 ((vm-xemacs-p)
|
|
216 (let (e)
|
|
217 (map-extents (function
|
|
218 (lambda (e ignore)
|
|
219 (if (extent-property e 'vm-highlight)
|
|
220 (delete-extent e))
|
|
221 nil))
|
|
222 (current-buffer) (point-min) (point-max))
|
|
223 (goto-char (point-min))
|
|
224 (while (vm-match-header)
|
|
225 (cond ((vm-match-header vm-highlighted-header-regexp)
|
|
226 (setq e (make-extent (vm-matched-header-contents-start)
|
|
227 (vm-matched-header-contents-end)))
|
|
228 (set-extent-property e 'face vm-highlighted-header-face)
|
|
229 (set-extent-property e 'vm-highlight t)))
|
|
230 (goto-char (vm-matched-header-end)))))
|
|
231 ((fboundp 'overlay-put)
|
|
232 (let (o-lists p)
|
|
233 (setq o-lists (overlay-lists)
|
|
234 p (car o-lists))
|
|
235 (while p
|
|
236 (and (overlay-get (car p) 'vm-highlight)
|
|
237 (delete-overlay (car p)))
|
|
238 (setq p (cdr p)))
|
|
239 (setq p (cdr o-lists))
|
|
240 (while p
|
|
241 (and (overlay-get (car p) 'vm-highlight)
|
|
242 (delete-overlay (car p)))
|
|
243 (setq p (cdr p)))
|
|
244 (goto-char (point-min))
|
|
245 (while (vm-match-header)
|
|
246 (cond ((vm-match-header vm-highlighted-header-regexp)
|
|
247 (setq p (make-overlay (vm-matched-header-contents-start)
|
|
248 (vm-matched-header-contents-end)))
|
|
249 (overlay-put p 'face vm-highlighted-header-face)
|
|
250 (overlay-put p 'vm-highlight t)))
|
|
251 (goto-char (vm-matched-header-end)))))))
|
|
252
|
|
253 (defun vm-energize-urls ()
|
|
254 ;; Don't search too long in large regions. If the region is
|
|
255 ;; large, search just the head and the tail of the region since
|
|
256 ;; they tend to contain the interesting text.
|
|
257 (let ((search-limit vm-url-search-limit)
|
20
|
258 search-pairs n)
|
0
|
259 (if (and search-limit (> (- (point-max) (point-min)) search-limit))
|
|
260 (setq search-pairs (list (cons (point-min)
|
|
261 (+ (point-min) (/ search-limit 2)))
|
|
262 (cons (- (point-max) (/ search-limit 2))
|
|
263 (point-max))))
|
|
264 (setq search-pairs (list (cons (point-min) (point-max)))))
|
|
265 (cond
|
|
266 ((vm-xemacs-p)
|
|
267 (let (e)
|
|
268 (map-extents (function
|
|
269 (lambda (e ignore)
|
|
270 (if (extent-property e 'vm-url)
|
|
271 (delete-extent e))
|
|
272 nil))
|
|
273 (current-buffer) (point-min) (point-max))
|
|
274 (while search-pairs
|
|
275 (goto-char (car (car search-pairs)))
|
|
276 (while (re-search-forward vm-url-regexp (cdr (car search-pairs)) t)
|
20
|
277 (setq n 1)
|
|
278 (while (null (match-beginning n))
|
|
279 (vm-increment n))
|
|
280 (setq e (make-extent (match-beginning n) (match-end n)))
|
0
|
281 (set-extent-property e 'vm-url t)
|
|
282 (if vm-highlight-url-face
|
|
283 (set-extent-property e 'face vm-highlight-url-face))
|
|
284 (if vm-url-browser
|
|
285 (let ((keymap (make-sparse-keymap)))
|
|
286 (define-key keymap 'button2 'vm-mouse-send-url-at-event)
|
20
|
287 (if vm-popup-menu-on-mouse-3
|
|
288 (define-key keymap 'button3 'vm-menu-popup-url-browser-menu))
|
0
|
289 (define-key keymap "\r"
|
|
290 (function (lambda () (interactive)
|
|
291 (vm-mouse-send-url-at-position (point)))))
|
|
292 (set-extent-property e 'keymap keymap)
|
|
293 (set-extent-property e 'balloon-help 'vm-url-help)
|
|
294 (set-extent-property e 'highlight t))))
|
|
295 (setq search-pairs (cdr search-pairs)))))
|
|
296 ((and (vm-fsfemacs-19-p)
|
|
297 (fboundp 'overlay-put))
|
|
298 (let (o-lists o p)
|
|
299 (setq o-lists (overlay-lists)
|
|
300 p (car o-lists))
|
|
301 (while p
|
|
302 (and (overlay-get (car p) 'vm-url)
|
|
303 (delete-overlay (car p)))
|
|
304 (setq p (cdr p)))
|
|
305 (setq p (cdr o-lists))
|
|
306 (while p
|
|
307 (and (overlay-get (car p) 'vm-url)
|
|
308 (delete-overlay (car p)))
|
|
309 (setq p (cdr p)))
|
|
310 (while search-pairs
|
|
311 (goto-char (car (car search-pairs)))
|
|
312 (while (re-search-forward vm-url-regexp (cdr (car search-pairs)) t)
|
20
|
313 (setq n 1)
|
|
314 (while (null (match-beginning n))
|
|
315 (vm-increment n))
|
|
316 (setq o (make-overlay (match-beginning n) (match-end n)))
|
0
|
317 (overlay-put o 'vm-url t)
|
|
318 (if vm-highlight-url-face
|
|
319 (overlay-put o 'face vm-highlight-url-face))
|
|
320 (if vm-url-browser
|
20
|
321 (let ((keymap (make-sparse-keymap)))
|
|
322 (overlay-put o 'mouse-face 'highlight)
|
|
323 (setq keymap (nconc keymap (current-local-map)))
|
|
324 (define-key keymap "\r"
|
|
325 (function (lambda () (interactive)
|
|
326 (vm-mouse-send-url-at-position (point)))))
|
|
327 (overlay-put o 'local-map keymap))))
|
0
|
328 (setq search-pairs (cdr search-pairs))))))))
|
|
329
|
|
330 (defun vm-energize-headers ()
|
|
331 (cond
|
|
332 ((vm-xemacs-p)
|
|
333 (let ((search-tuples '(("^From:" vm-menu-author-menu)
|
|
334 ("^Subject:" vm-menu-subject-menu)))
|
|
335 regexp menu keymap e)
|
|
336 (map-extents (function
|
|
337 (lambda (e ignore)
|
|
338 (if (extent-property e 'vm-header)
|
|
339 (delete-extent e))
|
|
340 nil))
|
|
341 (current-buffer) (point-min) (point-max))
|
|
342 (while search-tuples
|
|
343 (goto-char (point-min))
|
|
344 (setq regexp (nth 0 (car search-tuples))
|
|
345 menu (symbol-value (nth 1 (car search-tuples))))
|
|
346 (while (re-search-forward regexp nil t)
|
|
347 (save-excursion (goto-char (match-beginning 0)) (vm-match-header))
|
|
348 (setq e (make-extent (vm-matched-header-contents-start)
|
|
349 (vm-matched-header-contents-end)))
|
|
350 (set-extent-property e 'vm-header t)
|
|
351 (setq keymap (make-sparse-keymap))
|
|
352 ;; Might as well make button2 do what button3 does in
|
|
353 ;; this case, since there is no default 'select'
|
|
354 ;; action.
|
|
355 (define-key keymap 'button2
|
|
356 (list 'lambda () '(interactive)
|
|
357 (list 'popup-menu (list 'quote menu))))
|
20
|
358 (if vm-popup-menu-on-mouse-3
|
|
359 (define-key keymap 'button3
|
|
360 (list 'lambda () '(interactive)
|
|
361 (list 'popup-menu (list 'quote menu)))))
|
0
|
362 (set-extent-property e 'keymap keymap)
|
|
363 (set-extent-property e 'balloon-help 'vm-mouse-3-help)
|
|
364 (set-extent-property e 'highlight t))
|
|
365 (setq search-tuples (cdr search-tuples)))))
|
|
366 ((and (vm-fsfemacs-19-p)
|
|
367 (fboundp 'overlay-put))
|
|
368 (let ((search-tuples '(("^From:" vm-menu-fsfemacs-author-menu)
|
|
369 ("^Subject:" vm-menu-fsfemacs-subject-menu)))
|
|
370 regexp menu
|
|
371 o-lists o p)
|
|
372 (setq o-lists (overlay-lists)
|
|
373 p (car o-lists))
|
|
374 (while p
|
|
375 (and (overlay-get (car p) 'vm-header)
|
|
376 (delete-overlay (car p)))
|
|
377 (setq p (cdr p)))
|
|
378 (setq p (cdr o-lists))
|
|
379 (while p
|
|
380 (and (overlay-get (car p) 'vm-header)
|
|
381 (delete-overlay (car p)))
|
|
382 (setq p (cdr p)))
|
|
383 (while search-tuples
|
|
384 (goto-char (point-min))
|
|
385 (setq regexp (nth 0 (car search-tuples))
|
|
386 menu (symbol-value (nth 1 (car search-tuples))))
|
|
387 (while (re-search-forward regexp nil t)
|
|
388 (goto-char (match-end 0))
|
|
389 (save-excursion (goto-char (match-beginning 0)) (vm-match-header))
|
|
390 (setq o (make-overlay (vm-matched-header-contents-start)
|
|
391 (vm-matched-header-contents-end)))
|
|
392 (overlay-put o 'vm-header menu)
|
|
393 (overlay-put o 'mouse-face 'highlight))
|
|
394 (setq search-tuples (cdr search-tuples)))))))
|
|
395
|
|
396 (defun vm-display-xface ()
|
|
397 (let ((case-fold-search t) e g h)
|
|
398 (if (map-extents (function
|
|
399 (lambda (e ignore)
|
|
400 (if (extent-property e 'vm-xface)
|
|
401 t
|
|
402 nil)))
|
|
403 (current-buffer) (point-min) (point-max))
|
|
404 nil
|
|
405 (goto-char (point-min))
|
|
406 (if (find-face 'vm-xface)
|
|
407 nil
|
|
408 (make-face 'vm-xface)
|
|
409 (set-face-background 'vm-xface "white")
|
|
410 (set-face-foreground 'vm-xface "black"))
|
|
411 (if (re-search-forward "^X-Face:" nil t)
|
|
412 (progn
|
|
413 (goto-char (match-beginning 0))
|
|
414 (vm-match-header)
|
30
|
415 (setq h (concat "X-Face: " (vm-matched-header-contents)))
|
0
|
416 (setq g (intern h vm-xface-cache))
|
|
417 (if (boundp g)
|
|
418 (setq g (symbol-value g))
|
|
419 (set g (make-glyph h))
|
|
420 (setq g (symbol-value g))
|
|
421 ;; XXX broken. Gives extra pixel lines at the
|
|
422 ;; bottom of the glyph in 19.12
|
|
423 ;;(set-glyph-baseline g 100)
|
|
424 (set-glyph-face g 'vm-xface))
|
|
425 (setq e (make-extent (vm-vheaders-of (car vm-message-pointer))
|
|
426 (vm-vheaders-of (car vm-message-pointer))))
|
|
427 (set-extent-property e 'vm-xface t)
|
|
428 (set-extent-begin-glyph e g))))))
|
|
429
|
|
430 (defun vm-url-help (object)
|
|
431 (format
|
|
432 "Use mouse button 2 to send the URL to %s.
|
|
433 Use mouse button 3 to choose a Web browser for the URL."
|
|
434 (cond ((stringp vm-url-browser) vm-url-browser)
|
|
435 ((eq vm-url-browser 'w3-fetch)
|
|
436 "Emacs W3")
|
|
437 ((eq vm-url-browser 'w3-fetch-other-frame)
|
|
438 "Emacs W3")
|
|
439 ((eq vm-url-browser 'vm-mouse-send-url-to-mosaic)
|
|
440 "Mosaic")
|
|
441 ((eq vm-url-browser 'vm-mouse-send-url-to-netscape)
|
|
442 "Netscape")
|
|
443 (t (symbol-name vm-url-browser)))))
|
|
444
|
20
|
445 (defun vm-energize-urls-in-message-region (&optional start end)
|
|
446 (save-excursion
|
|
447 (or start (setq start (vm-headers-of (car vm-message-pointer))))
|
|
448 (or end (setq end (vm-text-end-of (car vm-message-pointer))))
|
|
449 ;; energize the URLs
|
|
450 (if (or vm-highlight-url-face vm-url-browser)
|
|
451 (save-restriction
|
|
452 (widen)
|
|
453 (narrow-to-region start
|
|
454 end)
|
|
455 (vm-energize-urls)))))
|
|
456
|
|
457 (defun vm-highlight-headers-maybe ()
|
|
458 ;; highlight the headers
|
|
459 (if (or vm-highlighted-header-regexp
|
|
460 (and (vm-xemacs-p) vm-use-lucid-highlighting))
|
|
461 (save-restriction
|
|
462 (widen)
|
|
463 (narrow-to-region (vm-headers-of (car vm-message-pointer))
|
|
464 (vm-text-end-of (car vm-message-pointer)))
|
|
465 (vm-highlight-headers))))
|
|
466
|
|
467 (defun vm-energize-headers-and-xfaces ()
|
|
468 ;; energize certain headers
|
|
469 (if (and vm-use-menus (vm-menu-support-possible-p))
|
|
470 (save-restriction
|
|
471 (widen)
|
|
472 (narrow-to-region (vm-headers-of (car vm-message-pointer))
|
|
473 (vm-text-of (car vm-message-pointer)))
|
|
474 (vm-energize-headers)))
|
|
475 ;; display xfaces, if we can
|
|
476 (if (and vm-display-xfaces
|
|
477 (vm-xemacs-p)
|
|
478 (vm-multiple-frames-possible-p)
|
|
479 (featurep 'xface))
|
|
480 (save-restriction
|
|
481 (widen)
|
|
482 (narrow-to-region (vm-headers-of (car vm-message-pointer))
|
|
483 (vm-text-of (car vm-message-pointer)))
|
|
484 (vm-display-xface))))
|
|
485
|
|
486 (defun vm-narrow-for-preview ()
|
0
|
487 (widen)
|
|
488 ;; hide as much of the message body as vm-preview-lines specifies
|
|
489 (narrow-to-region
|
|
490 (vm-vheaders-of (car vm-message-pointer))
|
|
491 (cond ((not (eq vm-preview-lines t))
|
|
492 (min
|
|
493 (vm-text-end-of (car vm-message-pointer))
|
|
494 (save-excursion
|
|
495 (goto-char (vm-text-of (car vm-message-pointer)))
|
|
496 (forward-line (if (natnump vm-preview-lines) vm-preview-lines 0))
|
|
497 (point))))
|
20
|
498 (t (vm-text-end-of (car vm-message-pointer))))))
|
|
499
|
|
500 (defun vm-preview-current-message ()
|
|
501 (vm-save-buffer-excursion
|
|
502 (setq vm-system-state 'previewing)
|
|
503 (if vm-real-buffers
|
|
504 (vm-make-virtual-copy (car vm-message-pointer)))
|
|
505
|
|
506 ;; run the message select hooks.
|
|
507 (save-excursion
|
|
508 (vm-select-folder-buffer)
|
|
509 (vm-run-message-hook (car vm-message-pointer) 'vm-select-message-hook)
|
|
510 (and vm-select-new-message-hook (vm-new-flag (car vm-message-pointer))
|
|
511 (vm-run-message-hook (car vm-message-pointer)
|
|
512 'vm-select-new-message-hook))
|
|
513 (and vm-select-unread-message-hook
|
|
514 (vm-unread-flag (car vm-message-pointer))
|
|
515 (vm-run-message-hook (car vm-message-pointer)
|
|
516 'vm-select-unread-message-hook)))
|
0
|
517
|
20
|
518 (vm-narrow-for-preview)
|
|
519 (if (or vm-mime-display-function
|
|
520 (and vm-display-using-mime
|
|
521 (not (vm-mime-plain-message-p (car vm-message-pointer)))))
|
|
522 (let ((layout (vm-mm-layout (car vm-message-pointer))))
|
|
523 (vm-make-presentation-copy (car vm-message-pointer))
|
|
524 (vm-save-buffer-excursion
|
|
525 (vm-replace-buffer-in-windows (current-buffer)
|
|
526 vm-presentation-buffer))
|
|
527 (set-buffer vm-presentation-buffer)
|
|
528 (setq vm-system-state 'previewing)
|
|
529 (vm-narrow-for-preview))
|
|
530 (setq vm-presentation-buffer nil)
|
|
531 (and vm-presentation-buffer-handle
|
|
532 (vm-replace-buffer-in-windows vm-presentation-buffer-handle
|
|
533 (current-buffer))))
|
0
|
534
|
20
|
535 ;; at this point the current buffer is the presentation buffer
|
|
536 ;; if we're using one for this message.
|
|
537
|
30
|
538 (vm-unbury-buffer (current-buffer))
|
20
|
539 (vm-energize-urls-in-message-region)
|
|
540 (vm-highlight-headers-maybe)
|
|
541 (vm-energize-headers-and-xfaces)
|
0
|
542
|
20
|
543 (if vm-honor-page-delimiters
|
|
544 (vm-narrow-to-page))
|
|
545 (goto-char (vm-text-of (car vm-message-pointer)))
|
|
546 ;; If we have a window, set window start appropriately.
|
|
547 (let ((w (vm-get-visible-buffer-window (current-buffer))))
|
|
548 (if w
|
|
549 (progn (set-window-start w (point-min))
|
|
550 (set-window-point w (vm-text-of (car vm-message-pointer))))))
|
|
551 (if (or (null vm-preview-lines)
|
|
552 (and (not vm-preview-read-messages)
|
|
553 (not (vm-new-flag (car vm-message-pointer)))
|
|
554 (not (vm-unread-flag (car vm-message-pointer)))))
|
|
555 (vm-show-current-message)
|
|
556 (vm-update-summary-and-mode-line))))
|
0
|
557
|
|
558 (defun vm-show-current-message ()
|
20
|
559 (and vm-display-using-mime
|
|
560 vm-auto-decode-mime-messages
|
24
|
561 (if vm-mail-buffer
|
|
562 (not (vm-buffer-variable-value vm-mail-buffer 'vm-mime-decoded))
|
|
563 (not vm-mime-decoded))
|
20
|
564 (not (vm-mime-plain-message-p (car vm-message-pointer)))
|
|
565 (vm-decode-mime-message))
|
|
566 (vm-save-buffer-excursion
|
|
567 (save-excursion
|
|
568 (save-excursion
|
|
569 (goto-char (point-min))
|
|
570 (widen)
|
|
571 (narrow-to-region (point) (vm-text-end-of (car vm-message-pointer))))
|
|
572 (if vm-honor-page-delimiters
|
|
573 (progn
|
|
574 (if (looking-at page-delimiter)
|
|
575 (forward-page 1))
|
|
576 (vm-narrow-to-page))))
|
|
577 ;; don't mark the message as read if the user can't see it!
|
|
578 (if (vm-get-visible-buffer-window (current-buffer))
|
|
579 (progn
|
|
580 (save-excursion
|
|
581 (setq vm-system-state 'showing)
|
|
582 (if vm-mail-buffer
|
|
583 (vm-set-buffer-variable vm-mail-buffer 'vm-system-state
|
|
584 'showing))
|
|
585 ;; We could be in the presentation buffer here. Since
|
|
586 ;; the presentation buffer's message pointer and sole
|
|
587 ;; message are a mockup, they will cause trouble if
|
|
588 ;; passed into the undo/update system. So we switch
|
|
589 ;; into the real message buffer to do attribute
|
|
590 ;; updates.
|
|
591 (vm-select-folder-buffer)
|
|
592 (cond ((vm-new-flag (car vm-message-pointer))
|
|
593 (vm-set-new-flag (car vm-message-pointer) nil)))
|
|
594 (cond ((vm-unread-flag (car vm-message-pointer))
|
|
595 (vm-set-unread-flag (car vm-message-pointer) nil))))
|
|
596 (vm-update-summary-and-mode-line)
|
|
597 (vm-howl-if-eom))
|
|
598 (vm-update-summary-and-mode-line))))
|
0
|
599
|
|
600 (defun vm-expose-hidden-headers ()
|
|
601 "Toggle exposing and hiding message headers that are normally not visible."
|
|
602 (interactive)
|
|
603 (vm-follow-summary-cursor)
|
|
604 (vm-select-folder-buffer)
|
|
605 (vm-check-for-killed-summary)
|
20
|
606 (vm-check-for-killed-presentation)
|
0
|
607 (vm-error-if-folder-empty)
|
20
|
608 (and vm-presentation-buffer
|
|
609 (set-buffer vm-presentation-buffer))
|
0
|
610 (vm-display (current-buffer) t '(vm-expose-hidden-headers)
|
|
611 '(vm-expose-hidden-headers reading-message))
|
|
612 (let* ((exposed (= (point-min) (vm-start-of (car vm-message-pointer)))))
|
|
613 (vm-widen-page)
|
|
614 (goto-char (point-max))
|
|
615 (widen)
|
|
616 (if exposed
|
|
617 (narrow-to-region (point) (vm-vheaders-of (car vm-message-pointer)))
|
|
618 (narrow-to-region (point) (vm-start-of (car vm-message-pointer))))
|
|
619 (goto-char (point-min))
|
|
620 (let (w)
|
|
621 (setq w (vm-get-visible-buffer-window (current-buffer)))
|
|
622 (and w (set-window-point w (point-min)))
|
|
623 (and w
|
|
624 (= (window-start w) (vm-vheaders-of (car vm-message-pointer)))
|
|
625 (not exposed)
|
|
626 (set-window-start w (vm-start-of (car vm-message-pointer)))))
|
|
627 (if vm-honor-page-delimiters
|
|
628 (vm-narrow-to-page))))
|
|
629
|
|
630 (defun vm-widen-page ()
|
|
631 (if (or (> (point-min) (vm-text-of (car vm-message-pointer)))
|
|
632 (/= (point-max) (vm-text-end-of (car vm-message-pointer))))
|
|
633 (narrow-to-region (vm-vheaders-of (car vm-message-pointer))
|
|
634 (if (or (vm-new-flag (car vm-message-pointer))
|
|
635 (vm-unread-flag (car vm-message-pointer)))
|
|
636 (vm-text-of (car vm-message-pointer))
|
|
637 (vm-text-end-of (car vm-message-pointer))))))
|
|
638
|
|
639 (defun vm-narrow-to-page ()
|
|
640 (save-excursion
|
|
641 (let (min max (omin (point-min)) (omax (point-max)))
|
|
642 (if (or (bolp) (not (save-excursion
|
|
643 (beginning-of-line)
|
|
644 (looking-at page-delimiter))))
|
|
645 (forward-page -1))
|
|
646 (setq min (point))
|
|
647 (forward-page 1)
|
|
648 (beginning-of-line)
|
|
649 (setq max (point))
|
|
650 (narrow-to-region min max))))
|
|
651
|
|
652 (defun vm-beginning-of-message ()
|
|
653 "Moves to the beginning of the current message."
|
|
654 (interactive)
|
|
655 (vm-follow-summary-cursor)
|
|
656 (vm-select-folder-buffer)
|
|
657 (vm-check-for-killed-summary)
|
20
|
658 (vm-check-for-killed-presentation)
|
0
|
659 (vm-error-if-folder-empty)
|
20
|
660 (and vm-presentation-buffer
|
|
661 (set-buffer vm-presentation-buffer))
|
0
|
662 (vm-widen-page)
|
|
663 (push-mark)
|
|
664 (vm-display (current-buffer) t '(vm-beginning-of-message)
|
|
665 '(vm-beginning-of-message reading-message))
|
|
666 (let ((osw (selected-window)))
|
|
667 (unwind-protect
|
|
668 (progn
|
|
669 (select-window (vm-get-visible-buffer-window (current-buffer)))
|
|
670 (goto-char (point-min)))
|
|
671 (if (not (eq osw (selected-window)))
|
|
672 (select-window osw))))
|
|
673 (if vm-honor-page-delimiters
|
|
674 (vm-narrow-to-page)))
|
|
675
|
|
676 (defun vm-end-of-message ()
|
|
677 "Moves to the end of the current message, exposing and flagging it read
|
|
678 as necessary."
|
|
679 (interactive)
|
|
680 (vm-follow-summary-cursor)
|
|
681 (vm-select-folder-buffer)
|
|
682 (vm-check-for-killed-summary)
|
20
|
683 (vm-check-for-killed-presentation)
|
0
|
684 (vm-error-if-folder-empty)
|
20
|
685 (and vm-presentation-buffer
|
|
686 (set-buffer vm-presentation-buffer))
|
0
|
687 (if (eq vm-system-state 'previewing)
|
|
688 (vm-show-current-message))
|
|
689 (setq vm-system-state 'reading)
|
|
690 (vm-widen-page)
|
|
691 (push-mark)
|
|
692 (vm-display (current-buffer) t '(vm-end-of-message)
|
|
693 '(vm-end-of-message reading-message))
|
|
694 (let ((osw (selected-window)))
|
|
695 (unwind-protect
|
|
696 (progn
|
|
697 (select-window (vm-get-visible-buffer-window (current-buffer)))
|
|
698 (goto-char (point-max)))
|
|
699 (if (not (eq osw (selected-window)))
|
|
700 (select-window osw))))
|
|
701 (if vm-honor-page-delimiters
|
|
702 (vm-narrow-to-page)))
|