0
|
1 ;;; Commands to move around within a VM message
|
98
|
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)
|
98
|
31 (vm-check-for-killed-presentation)
|
0
|
32 (vm-error-if-folder-empty)
|
98
|
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))
|
98
|
47 (set-window-start w (point-min)))
|
|
48 (setq was-invisible t))))
|
70
|
49 (if (or mp-changed was-invisible
|
0
|
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)))))))
|
98
|
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
|
100
|
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 ()
|
114
|
167 (let ((w (get-buffer-window (current-buffer))))
|
0
|
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))
|
102
|
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)))
|
102
|
193 (message "End of message %s"
|
0
|
194 (vm-number-of (car vm-message-pointer)))))
|
|
195
|
70
|
196 (defun vm-scroll-backward (arg)
|
0
|
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
|
120
|
208 ((and vm-xemacs-p vm-use-lucid-highlighting)
|
0
|
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)))
|
120
|
215 (vm-xemacs-p
|
0
|
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)
|
98
|
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
|
120
|
266 (vm-xemacs-p
|
0
|
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)
|
98
|
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
|
118
|
285 (let ((keymap (make-sparse-keymap))
|
|
286 (popup-function
|
|
287 (if (save-excursion
|
|
288 (goto-char (match-beginning n))
|
|
289 (looking-at "mailto:"))
|
|
290 'vm-menu-popup-mailto-url-browser-menu
|
|
291 'vm-menu-popup-url-browser-menu)))
|
0
|
292 (define-key keymap 'button2 'vm-mouse-send-url-at-event)
|
98
|
293 (if vm-popup-menu-on-mouse-3
|
118
|
294 (define-key keymap 'button3 popup-function))
|
0
|
295 (define-key keymap "\r"
|
|
296 (function (lambda () (interactive)
|
|
297 (vm-mouse-send-url-at-position (point)))))
|
|
298 (set-extent-property e 'keymap keymap)
|
|
299 (set-extent-property e 'balloon-help 'vm-url-help)
|
|
300 (set-extent-property e 'highlight t))))
|
|
301 (setq search-pairs (cdr search-pairs)))))
|
120
|
302 ((and vm-fsfemacs-19-p
|
0
|
303 (fboundp 'overlay-put))
|
|
304 (let (o-lists o p)
|
|
305 (setq o-lists (overlay-lists)
|
|
306 p (car o-lists))
|
|
307 (while p
|
|
308 (and (overlay-get (car p) 'vm-url)
|
|
309 (delete-overlay (car p)))
|
|
310 (setq p (cdr p)))
|
|
311 (setq p (cdr o-lists))
|
|
312 (while p
|
|
313 (and (overlay-get (car p) 'vm-url)
|
|
314 (delete-overlay (car p)))
|
|
315 (setq p (cdr p)))
|
|
316 (while search-pairs
|
|
317 (goto-char (car (car search-pairs)))
|
|
318 (while (re-search-forward vm-url-regexp (cdr (car search-pairs)) t)
|
98
|
319 (setq n 1)
|
|
320 (while (null (match-beginning n))
|
|
321 (vm-increment n))
|
|
322 (setq o (make-overlay (match-beginning n) (match-end n)))
|
0
|
323 (overlay-put o 'vm-url t)
|
|
324 (if vm-highlight-url-face
|
|
325 (overlay-put o 'face vm-highlight-url-face))
|
|
326 (if vm-url-browser
|
118
|
327 (let ((keymap (make-sparse-keymap))
|
|
328 (popup-function
|
|
329 (if (save-excursion
|
|
330 (goto-char (match-beginning n))
|
|
331 (looking-at "mailto:"))
|
|
332 'vm-menu-popup-mailto-url-browser-menu
|
|
333 'vm-menu-popup-url-browser-menu)))
|
98
|
334 (overlay-put o 'mouse-face 'highlight)
|
|
335 (setq keymap (nconc keymap (current-local-map)))
|
118
|
336 (if vm-popup-menu-on-mouse-3
|
|
337 (define-key keymap [mouse-3] popup-function))
|
98
|
338 (define-key keymap "\r"
|
|
339 (function (lambda () (interactive)
|
|
340 (vm-mouse-send-url-at-position (point)))))
|
|
341 (overlay-put o 'local-map keymap))))
|
0
|
342 (setq search-pairs (cdr search-pairs))))))))
|
|
343
|
|
344 (defun vm-energize-headers ()
|
|
345 (cond
|
120
|
346 (vm-xemacs-p
|
0
|
347 (let ((search-tuples '(("^From:" vm-menu-author-menu)
|
|
348 ("^Subject:" vm-menu-subject-menu)))
|
|
349 regexp menu keymap e)
|
|
350 (map-extents (function
|
|
351 (lambda (e ignore)
|
|
352 (if (extent-property e 'vm-header)
|
|
353 (delete-extent e))
|
|
354 nil))
|
|
355 (current-buffer) (point-min) (point-max))
|
|
356 (while search-tuples
|
|
357 (goto-char (point-min))
|
|
358 (setq regexp (nth 0 (car search-tuples))
|
|
359 menu (symbol-value (nth 1 (car search-tuples))))
|
|
360 (while (re-search-forward regexp nil t)
|
|
361 (save-excursion (goto-char (match-beginning 0)) (vm-match-header))
|
|
362 (setq e (make-extent (vm-matched-header-contents-start)
|
|
363 (vm-matched-header-contents-end)))
|
|
364 (set-extent-property e 'vm-header t)
|
|
365 (setq keymap (make-sparse-keymap))
|
|
366 ;; Might as well make button2 do what button3 does in
|
|
367 ;; this case, since there is no default 'select'
|
|
368 ;; action.
|
|
369 (define-key keymap 'button2
|
|
370 (list 'lambda () '(interactive)
|
|
371 (list 'popup-menu (list 'quote menu))))
|
98
|
372 (if vm-popup-menu-on-mouse-3
|
|
373 (define-key keymap 'button3
|
|
374 (list 'lambda () '(interactive)
|
|
375 (list 'popup-menu (list 'quote menu)))))
|
0
|
376 (set-extent-property e 'keymap keymap)
|
|
377 (set-extent-property e 'balloon-help 'vm-mouse-3-help)
|
|
378 (set-extent-property e 'highlight t))
|
|
379 (setq search-tuples (cdr search-tuples)))))
|
120
|
380 ((and vm-fsfemacs-19-p
|
0
|
381 (fboundp 'overlay-put))
|
|
382 (let ((search-tuples '(("^From:" vm-menu-fsfemacs-author-menu)
|
|
383 ("^Subject:" vm-menu-fsfemacs-subject-menu)))
|
|
384 regexp menu
|
|
385 o-lists o p)
|
|
386 (setq o-lists (overlay-lists)
|
|
387 p (car o-lists))
|
|
388 (while p
|
|
389 (and (overlay-get (car p) 'vm-header)
|
|
390 (delete-overlay (car p)))
|
|
391 (setq p (cdr p)))
|
|
392 (setq p (cdr o-lists))
|
|
393 (while p
|
|
394 (and (overlay-get (car p) 'vm-header)
|
|
395 (delete-overlay (car p)))
|
|
396 (setq p (cdr p)))
|
|
397 (while search-tuples
|
|
398 (goto-char (point-min))
|
|
399 (setq regexp (nth 0 (car search-tuples))
|
|
400 menu (symbol-value (nth 1 (car search-tuples))))
|
|
401 (while (re-search-forward regexp nil t)
|
|
402 (goto-char (match-end 0))
|
|
403 (save-excursion (goto-char (match-beginning 0)) (vm-match-header))
|
|
404 (setq o (make-overlay (vm-matched-header-contents-start)
|
|
405 (vm-matched-header-contents-end)))
|
|
406 (overlay-put o 'vm-header menu)
|
|
407 (overlay-put o 'mouse-face 'highlight))
|
|
408 (setq search-tuples (cdr search-tuples)))))))
|
|
409
|
|
410 (defun vm-display-xface ()
|
|
411 (let ((case-fold-search t) e g h)
|
|
412 (if (map-extents (function
|
|
413 (lambda (e ignore)
|
|
414 (if (extent-property e 'vm-xface)
|
|
415 t
|
|
416 nil)))
|
|
417 (current-buffer) (point-min) (point-max))
|
|
418 nil
|
|
419 (goto-char (point-min))
|
|
420 (if (find-face 'vm-xface)
|
|
421 nil
|
|
422 (make-face 'vm-xface)
|
|
423 (set-face-background 'vm-xface "white")
|
|
424 (set-face-foreground 'vm-xface "black"))
|
|
425 (if (re-search-forward "^X-Face:" nil t)
|
|
426 (progn
|
|
427 (goto-char (match-beginning 0))
|
|
428 (vm-match-header)
|
108
|
429 (setq h (concat "X-Face: " (vm-matched-header-contents)))
|
0
|
430 (setq g (intern h vm-xface-cache))
|
|
431 (if (boundp g)
|
|
432 (setq g (symbol-value g))
|
70
|
433 (set g (make-glyph h))
|
0
|
434 (setq g (symbol-value g))
|
|
435 ;; XXX broken. Gives extra pixel lines at the
|
|
436 ;; bottom of the glyph in 19.12
|
|
437 ;;(set-glyph-baseline g 100)
|
|
438 (set-glyph-face g 'vm-xface))
|
|
439 (setq e (make-extent (vm-vheaders-of (car vm-message-pointer))
|
|
440 (vm-vheaders-of (car vm-message-pointer))))
|
|
441 (set-extent-property e 'vm-xface t)
|
|
442 (set-extent-begin-glyph e g))))))
|
|
443
|
|
444 (defun vm-url-help (object)
|
|
445 (format
|
|
446 "Use mouse button 2 to send the URL to %s.
|
|
447 Use mouse button 3 to choose a Web browser for the URL."
|
|
448 (cond ((stringp vm-url-browser) vm-url-browser)
|
|
449 ((eq vm-url-browser 'w3-fetch)
|
|
450 "Emacs W3")
|
|
451 ((eq vm-url-browser 'w3-fetch-other-frame)
|
|
452 "Emacs W3")
|
|
453 ((eq vm-url-browser 'vm-mouse-send-url-to-mosaic)
|
|
454 "Mosaic")
|
|
455 ((eq vm-url-browser 'vm-mouse-send-url-to-netscape)
|
|
456 "Netscape")
|
|
457 (t (symbol-name vm-url-browser)))))
|
|
458
|
98
|
459 (defun vm-energize-urls-in-message-region (&optional start end)
|
|
460 (save-excursion
|
|
461 (or start (setq start (vm-headers-of (car vm-message-pointer))))
|
|
462 (or end (setq end (vm-text-end-of (car vm-message-pointer))))
|
|
463 ;; energize the URLs
|
|
464 (if (or vm-highlight-url-face vm-url-browser)
|
|
465 (save-restriction
|
|
466 (widen)
|
114
|
467 (narrow-to-region start end)
|
98
|
468 (vm-energize-urls)))))
|
|
469
|
|
470 (defun vm-highlight-headers-maybe ()
|
|
471 ;; highlight the headers
|
|
472 (if (or vm-highlighted-header-regexp
|
120
|
473 (and vm-xemacs-p vm-use-lucid-highlighting))
|
98
|
474 (save-restriction
|
|
475 (widen)
|
|
476 (narrow-to-region (vm-headers-of (car vm-message-pointer))
|
|
477 (vm-text-end-of (car vm-message-pointer)))
|
|
478 (vm-highlight-headers))))
|
|
479
|
|
480 (defun vm-energize-headers-and-xfaces ()
|
|
481 ;; energize certain headers
|
|
482 (if (and vm-use-menus (vm-menu-support-possible-p))
|
|
483 (save-restriction
|
|
484 (widen)
|
|
485 (narrow-to-region (vm-headers-of (car vm-message-pointer))
|
|
486 (vm-text-of (car vm-message-pointer)))
|
|
487 (vm-energize-headers)))
|
|
488 ;; display xfaces, if we can
|
|
489 (if (and vm-display-xfaces
|
120
|
490 vm-xemacs-p
|
98
|
491 (vm-multiple-frames-possible-p)
|
|
492 (featurep 'xface))
|
|
493 (save-restriction
|
|
494 (widen)
|
|
495 (narrow-to-region (vm-headers-of (car vm-message-pointer))
|
|
496 (vm-text-of (car vm-message-pointer)))
|
|
497 (vm-display-xface))))
|
|
498
|
|
499 (defun vm-narrow-for-preview ()
|
0
|
500 (widen)
|
|
501 ;; hide as much of the message body as vm-preview-lines specifies
|
|
502 (narrow-to-region
|
|
503 (vm-vheaders-of (car vm-message-pointer))
|
|
504 (cond ((not (eq vm-preview-lines t))
|
|
505 (min
|
|
506 (vm-text-end-of (car vm-message-pointer))
|
|
507 (save-excursion
|
|
508 (goto-char (vm-text-of (car vm-message-pointer)))
|
|
509 (forward-line (if (natnump vm-preview-lines) vm-preview-lines 0))
|
|
510 (point))))
|
98
|
511 (t (vm-text-end-of (car vm-message-pointer))))))
|
|
512
|
|
513 (defun vm-preview-current-message ()
|
|
514 (vm-save-buffer-excursion
|
114
|
515 (setq vm-system-state 'previewing
|
|
516 vm-mime-decoded nil)
|
98
|
517 (if vm-real-buffers
|
|
518 (vm-make-virtual-copy (car vm-message-pointer)))
|
|
519
|
|
520 ;; run the message select hooks.
|
|
521 (save-excursion
|
|
522 (vm-select-folder-buffer)
|
|
523 (vm-run-message-hook (car vm-message-pointer) 'vm-select-message-hook)
|
|
524 (and vm-select-new-message-hook (vm-new-flag (car vm-message-pointer))
|
|
525 (vm-run-message-hook (car vm-message-pointer)
|
|
526 'vm-select-new-message-hook))
|
|
527 (and vm-select-unread-message-hook
|
|
528 (vm-unread-flag (car vm-message-pointer))
|
|
529 (vm-run-message-hook (car vm-message-pointer)
|
|
530 'vm-select-unread-message-hook)))
|
0
|
531
|
98
|
532 (vm-narrow-for-preview)
|
|
533 (if (or vm-mime-display-function
|
|
534 (and vm-display-using-mime
|
|
535 (not (vm-mime-plain-message-p (car vm-message-pointer)))))
|
|
536 (let ((layout (vm-mm-layout (car vm-message-pointer))))
|
|
537 (vm-make-presentation-copy (car vm-message-pointer))
|
|
538 (vm-save-buffer-excursion
|
|
539 (vm-replace-buffer-in-windows (current-buffer)
|
|
540 vm-presentation-buffer))
|
|
541 (set-buffer vm-presentation-buffer)
|
|
542 (setq vm-system-state 'previewing)
|
|
543 (vm-narrow-for-preview))
|
|
544 (setq vm-presentation-buffer nil)
|
|
545 (and vm-presentation-buffer-handle
|
|
546 (vm-replace-buffer-in-windows vm-presentation-buffer-handle
|
|
547 (current-buffer))))
|
20
|
548
|
98
|
549 ;; at this point the current buffer is the presentation buffer
|
|
550 ;; if we're using one for this message.
|
|
551
|
108
|
552 (vm-unbury-buffer (current-buffer))
|
98
|
553 (vm-energize-urls-in-message-region)
|
|
554 (vm-highlight-headers-maybe)
|
|
555 (vm-energize-headers-and-xfaces)
|
0
|
556
|
98
|
557 (if vm-honor-page-delimiters
|
|
558 (vm-narrow-to-page))
|
|
559 (goto-char (vm-text-of (car vm-message-pointer)))
|
|
560 ;; If we have a window, set window start appropriately.
|
|
561 (let ((w (vm-get-visible-buffer-window (current-buffer))))
|
|
562 (if w
|
|
563 (progn (set-window-start w (point-min))
|
|
564 (set-window-point w (vm-text-of (car vm-message-pointer))))))
|
|
565 (if (or (null vm-preview-lines)
|
|
566 (and (not vm-preview-read-messages)
|
|
567 (not (vm-new-flag (car vm-message-pointer)))
|
|
568 (not (vm-unread-flag (car vm-message-pointer)))))
|
|
569 (vm-show-current-message)
|
|
570 (vm-update-summary-and-mode-line))))
|
0
|
571
|
|
572 (defun vm-show-current-message ()
|
98
|
573 (and vm-display-using-mime
|
|
574 vm-auto-decode-mime-messages
|
100
|
575 (if vm-mail-buffer
|
|
576 (not (vm-buffer-variable-value vm-mail-buffer 'vm-mime-decoded))
|
|
577 (not vm-mime-decoded))
|
98
|
578 (not (vm-mime-plain-message-p (car vm-message-pointer)))
|
114
|
579 (condition-case data
|
|
580 (vm-decode-mime-message)
|
|
581 (vm-mime-error (vm-set-mime-layout-of (car vm-message-pointer)
|
|
582 (car (cdr data)))
|
|
583 (message "%s" (car (cdr data))))))
|
98
|
584 (vm-save-buffer-excursion
|
|
585 (save-excursion
|
|
586 (save-excursion
|
|
587 (goto-char (point-min))
|
|
588 (widen)
|
|
589 (narrow-to-region (point) (vm-text-end-of (car vm-message-pointer))))
|
|
590 (if vm-honor-page-delimiters
|
|
591 (progn
|
|
592 (if (looking-at page-delimiter)
|
|
593 (forward-page 1))
|
|
594 (vm-narrow-to-page))))
|
|
595 ;; don't mark the message as read if the user can't see it!
|
|
596 (if (vm-get-visible-buffer-window (current-buffer))
|
|
597 (progn
|
|
598 (save-excursion
|
|
599 (setq vm-system-state 'showing)
|
|
600 (if vm-mail-buffer
|
|
601 (vm-set-buffer-variable vm-mail-buffer 'vm-system-state
|
|
602 'showing))
|
|
603 ;; We could be in the presentation buffer here. Since
|
|
604 ;; the presentation buffer's message pointer and sole
|
|
605 ;; message are a mockup, they will cause trouble if
|
|
606 ;; passed into the undo/update system. So we switch
|
|
607 ;; into the real message buffer to do attribute
|
|
608 ;; updates.
|
|
609 (vm-select-folder-buffer)
|
|
610 (cond ((vm-new-flag (car vm-message-pointer))
|
|
611 (vm-set-new-flag (car vm-message-pointer) nil)))
|
|
612 (cond ((vm-unread-flag (car vm-message-pointer))
|
|
613 (vm-set-unread-flag (car vm-message-pointer) nil))))
|
|
614 (vm-update-summary-and-mode-line)
|
|
615 (vm-howl-if-eom))
|
|
616 (vm-update-summary-and-mode-line))))
|
0
|
617
|
|
618 (defun vm-expose-hidden-headers ()
|
|
619 "Toggle exposing and hiding message headers that are normally not visible."
|
|
620 (interactive)
|
|
621 (vm-follow-summary-cursor)
|
|
622 (vm-select-folder-buffer)
|
|
623 (vm-check-for-killed-summary)
|
98
|
624 (vm-check-for-killed-presentation)
|
0
|
625 (vm-error-if-folder-empty)
|
98
|
626 (and vm-presentation-buffer
|
|
627 (set-buffer vm-presentation-buffer))
|
0
|
628 (vm-display (current-buffer) t '(vm-expose-hidden-headers)
|
|
629 '(vm-expose-hidden-headers reading-message))
|
|
630 (let* ((exposed (= (point-min) (vm-start-of (car vm-message-pointer)))))
|
|
631 (vm-widen-page)
|
|
632 (goto-char (point-max))
|
|
633 (widen)
|
|
634 (if exposed
|
|
635 (narrow-to-region (point) (vm-vheaders-of (car vm-message-pointer)))
|
|
636 (narrow-to-region (point) (vm-start-of (car vm-message-pointer))))
|
|
637 (goto-char (point-min))
|
|
638 (let (w)
|
|
639 (setq w (vm-get-visible-buffer-window (current-buffer)))
|
|
640 (and w (set-window-point w (point-min)))
|
|
641 (and w
|
|
642 (= (window-start w) (vm-vheaders-of (car vm-message-pointer)))
|
|
643 (not exposed)
|
|
644 (set-window-start w (vm-start-of (car vm-message-pointer)))))
|
|
645 (if vm-honor-page-delimiters
|
|
646 (vm-narrow-to-page))))
|
|
647
|
|
648 (defun vm-widen-page ()
|
|
649 (if (or (> (point-min) (vm-text-of (car vm-message-pointer)))
|
|
650 (/= (point-max) (vm-text-end-of (car vm-message-pointer))))
|
|
651 (narrow-to-region (vm-vheaders-of (car vm-message-pointer))
|
|
652 (if (or (vm-new-flag (car vm-message-pointer))
|
|
653 (vm-unread-flag (car vm-message-pointer)))
|
|
654 (vm-text-of (car vm-message-pointer))
|
|
655 (vm-text-end-of (car vm-message-pointer))))))
|
|
656
|
|
657 (defun vm-narrow-to-page ()
|
|
658 (save-excursion
|
|
659 (let (min max (omin (point-min)) (omax (point-max)))
|
|
660 (if (or (bolp) (not (save-excursion
|
|
661 (beginning-of-line)
|
|
662 (looking-at page-delimiter))))
|
|
663 (forward-page -1))
|
|
664 (setq min (point))
|
|
665 (forward-page 1)
|
|
666 (beginning-of-line)
|
|
667 (setq max (point))
|
|
668 (narrow-to-region min max))))
|
|
669
|
|
670 (defun vm-beginning-of-message ()
|
|
671 "Moves to the beginning of the current message."
|
|
672 (interactive)
|
|
673 (vm-follow-summary-cursor)
|
|
674 (vm-select-folder-buffer)
|
|
675 (vm-check-for-killed-summary)
|
98
|
676 (vm-check-for-killed-presentation)
|
0
|
677 (vm-error-if-folder-empty)
|
98
|
678 (and vm-presentation-buffer
|
|
679 (set-buffer vm-presentation-buffer))
|
0
|
680 (vm-widen-page)
|
|
681 (push-mark)
|
|
682 (vm-display (current-buffer) t '(vm-beginning-of-message)
|
|
683 '(vm-beginning-of-message reading-message))
|
|
684 (let ((osw (selected-window)))
|
|
685 (unwind-protect
|
|
686 (progn
|
|
687 (select-window (vm-get-visible-buffer-window (current-buffer)))
|
|
688 (goto-char (point-min)))
|
|
689 (if (not (eq osw (selected-window)))
|
|
690 (select-window osw))))
|
|
691 (if vm-honor-page-delimiters
|
|
692 (vm-narrow-to-page)))
|
|
693
|
|
694 (defun vm-end-of-message ()
|
|
695 "Moves to the end of the current message, exposing and flagging it read
|
|
696 as necessary."
|
|
697 (interactive)
|
|
698 (vm-follow-summary-cursor)
|
|
699 (vm-select-folder-buffer)
|
|
700 (vm-check-for-killed-summary)
|
98
|
701 (vm-check-for-killed-presentation)
|
0
|
702 (vm-error-if-folder-empty)
|
98
|
703 (and vm-presentation-buffer
|
|
704 (set-buffer vm-presentation-buffer))
|
0
|
705 (if (eq vm-system-state 'previewing)
|
|
706 (vm-show-current-message))
|
|
707 (setq vm-system-state 'reading)
|
|
708 (vm-widen-page)
|
|
709 (push-mark)
|
|
710 (vm-display (current-buffer) t '(vm-end-of-message)
|
|
711 '(vm-end-of-message reading-message))
|
|
712 (let ((osw (selected-window)))
|
|
713 (unwind-protect
|
|
714 (progn
|
|
715 (select-window (vm-get-visible-buffer-window (current-buffer)))
|
|
716 (goto-char (point-max)))
|
|
717 (if (not (eq osw (selected-window)))
|
|
718 (select-window osw))))
|
|
719 (if vm-honor-page-delimiters
|
|
720 (vm-narrow-to-page)))
|