4
|
1 ;;; tm-vm.el --- tm-MUA (MIME Extension module) for VM
|
|
2
|
|
3 ;; Copyright (C) 1994,1995,1996 Free Software Foundation, Inc.
|
|
4
|
|
5 ;; Author: MASUTANI Yasuhiro <masutani@me.es.osaka-u.ac.jp>
|
|
6 ;; Kenji Wakamiya <wkenji@flab.fujitsu.co.jp>
|
|
7 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp>
|
|
8 ;; Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp>
|
|
9 ;; Oscar Figueiredo <Oscar.Figueiredo@di.epfl.ch>
|
|
10 ;; Maintainer: Oscar Figueiredo <Oscar.Figueiredo@di.epfl.ch>
|
|
11 ;; Created: 1994/10/29
|
98
|
12 ;; Version: $Revision: 1.2 $
|
4
|
13 ;; Keywords: mail, MIME, multimedia, multilingual, encoded-word
|
|
14
|
|
15 ;; This file is part of tm (Tools for MIME).
|
|
16
|
|
17 ;; This program is free software; you can redistribute it and/or
|
|
18 ;; modify it under the terms of the GNU General Public License as
|
|
19 ;; published by the Free Software Foundation; either version 2, or (at
|
|
20 ;; your option) any later version.
|
|
21
|
|
22 ;; This program is distributed in the hope that it will be useful, but
|
|
23 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
24 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
25 ;; General Public License for more details.
|
|
26
|
|
27 ;; You should have received a copy of the GNU General Public License
|
|
28 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
29 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
30 ;; Boston, MA 02111-1307, USA.
|
|
31
|
|
32 ;;; Commentary:
|
|
33
|
|
34 ;; Plese insert `(require 'tm-vm)' in your ~/.vm file.
|
|
35
|
|
36 ;;; Code:
|
|
37
|
74
|
38 (eval-when-compile
|
|
39 (require 'tm-mail)
|
|
40 (require 'vm)
|
|
41 (require 'vm-window))
|
|
42
|
98
|
43 (require 'tm-edit)
|
4
|
44 (require 'tm-view)
|
98
|
45 (require 'vm-reply)
|
|
46 (require 'vm-summary)
|
|
47 (require 'vm-menu)
|
|
48 (require 'vm-toolbar)
|
|
49
|
|
50
|
|
51 ;;; @ Variables
|
|
52
|
|
53 ;;; @@ User customization variables
|
|
54
|
|
55 (defvar tm-vm/use-vm-bindings t
|
|
56 "*If t, use VM compatible keybindings in MIME Preview buffers.
|
|
57 Otherwise TM generic bindings for content extraction/playing are
|
|
58 made available.")
|
|
59
|
|
60 (defvar tm-vm/attach-to-popup-menus t
|
|
61 "*If t append MIME specific commands to VM's popup menus.")
|
|
62
|
|
63 (defvar tm-vm/use-original-url-button nil
|
|
64 "*If it is t, use original URL button instead of tm's.")
|
|
65
|
|
66 (defvar tm-vm/automatic-mime-preview (or (and (boundp 'vm-display-using-mime)
|
|
67 vm-display-using-mime)
|
|
68 t)
|
|
69 "*If non-nil, automatically process and show MIME messages.")
|
|
70
|
|
71 (defvar tm-vm/strict-mime t
|
|
72 "*If nil, do MIME processing even if there is no MIME-Version field.")
|
|
73
|
|
74 (defvar tm-vm/use-ps-print (not (featurep 'mule))
|
|
75 "*Use Postscript printing (ps-print) to print MIME messages.")
|
|
76
|
|
77 (defvar tm-vm-load-hook nil
|
|
78 "*List of functions called after tm-vm is loaded.")
|
|
79
|
|
80 (defvar tm-vm/select-message-hook nil
|
|
81 "*List of functions called every time a message is selected.
|
|
82 tm-vm uses `vm-select-message-hook', use tm-vm/select-message-hook instead.
|
|
83 When the hooks are run current buffer is either VM folder buffer with
|
|
84 the current message delimited by (point-min) and (point-max) or the MIME
|
|
85 Preview buffer.")
|
|
86
|
|
87 (defvar tm-vm/forward-message-hook vm-forward-message-hook
|
|
88 "*List of functions called after a Mail mode buffer has been
|
|
89 created to forward a message in message/rfc822 type format.
|
|
90 If `vm-forwarding-digest-type' is \"rfc1521\", tm-vm runs this
|
|
91 hook instead of `vm-forward-message-hook'.")
|
|
92
|
|
93 (defvar tm-vm/send-digest-hook nil
|
|
94 "*List of functions called after a Mail mode buffer has been
|
|
95 created to send a digest in multipart/digest type format.
|
|
96 If `vm-digest-send-type' is \"rfc1521\", tm-vm runs this hook
|
|
97 instead of `vm-send-digest-hook'.")
|
|
98
|
|
99 (defvar tm-vm/build-mime-preview-buffer-hook nil
|
|
100 "*List of functions called each time a MIME Preview buffer is built.
|
|
101 These hooks are run in the MIME-Preview buffer.")
|
|
102
|
|
103 ;;; @@ System/Information variables
|
4
|
104
|
|
105 (defconst tm-vm/RCS-ID
|
98
|
106 "$Id: tm-vm.el,v 1.2 1997/02/15 22:21:30 steve Exp $")
|
4
|
107 (defconst tm-vm/version (get-version-string tm-vm/RCS-ID))
|
|
108
|
98
|
109 ; Ensure vm-menu-mail-menu gets properly defined *before* tm-vm/vm-emulation-map
|
|
110 ; since it contains a call to vm-menu-initialize-vm-mode-menu-map
|
|
111 (setq vm-menu-mail-menu
|
|
112 (let ((title (if (vm-menu-fsfemacs-menus-p)
|
|
113 (list "Mail Commands"
|
|
114 "Mail Commands"
|
|
115 "---"
|
|
116 "---")
|
|
117 (list "Mail Commands"))))
|
|
118 (append
|
|
119 title
|
|
120 (list ["Send and Exit" vm-mail-send-and-exit (vm-menu-can-send-mail-p)]
|
|
121 ["Send, Keep Composing" vm-mail-send (vm-menu-can-send-mail-p)]
|
|
122 ["Cancel" kill-buffer t]
|
|
123 "----"
|
|
124 "Go to Field:"
|
|
125 "----"
|
|
126 [" To:" mail-to t]
|
|
127 [" Subject:" mail-subject t]
|
|
128 [" CC:" mail-cc t]
|
|
129 [" BCC:" mail-bcc t]
|
|
130 [" Reply-To:" mail-replyto t]
|
|
131 [" Text" mail-text t]
|
|
132 "----"
|
|
133 ["Yank Original" vm-menu-yank-original vm-reply-list]
|
|
134 ["Fill Yanked Message" mail-fill-yanked-message t]
|
|
135 ["Insert Signature" mail-signature t]
|
|
136 ["Insert File..." insert-file t]
|
|
137 ["Insert Buffer..." insert-buffer t])
|
|
138 (if tm-vm/attach-to-popup-menus
|
|
139 (list "----"
|
|
140 (cons "MIME Commands"
|
|
141 (mapcar (function (lambda (item)
|
|
142 (vector (nth 1 item)
|
|
143 (nth 2 item)
|
|
144 t)))
|
|
145 mime-editor/menu-list))))
|
|
146 )))
|
|
147
|
|
148 (defvar tm-vm/vm-emulation-map
|
|
149 (let ((map (make-sparse-keymap)))
|
|
150 (define-key map "h" 'vm-summarize)
|
|
151 ;(define-key map "\M-n" 'vm-next-unread-message)
|
|
152 ;(define-key map "\M-p" 'vm-previous-unread-message)
|
|
153 (define-key map "n" 'vm-next-message)
|
|
154 (define-key map "p" 'vm-previous-message)
|
|
155 (define-key map "N" 'vm-next-message-no-skip)
|
|
156 (define-key map "P" 'vm-previous-message-no-skip)
|
|
157 ;(define-key map "\C-\M-n" 'vm-move-message-forward)
|
|
158 ;(define-key map "\C-\M-p" 'vm-move-message-backward)
|
|
159 ;(define-key map "\t" 'vm-goto-message-last-seen)
|
|
160 ;(define-key map "\r" 'vm-goto-message)
|
|
161 (define-key map "^" 'vm-goto-parent-message)
|
|
162 (define-key map "t" 'vm-expose-hidden-headers)
|
|
163 (define-key map " " 'vm-scroll-forward)
|
|
164 (define-key map "b" 'vm-scroll-backward)
|
|
165 (define-key map "\C-?" 'vm-scroll-backward)
|
|
166 (define-key map "d" 'vm-delete-message)
|
|
167 (define-key map "\C-d" 'vm-delete-message-backward)
|
|
168 (define-key map "u" 'vm-undelete-message)
|
|
169 (define-key map "U" 'vm-unread-message)
|
|
170 (define-key map "e" 'vm-edit-message)
|
|
171 ;(define-key map "a" 'vm-set-message-attributes)
|
|
172 ;(define-key map "j" 'vm-discard-cached-data)
|
|
173 ;(define-key map "k" 'vm-kill-subject)
|
|
174 (define-key map "f" 'vm-followup)
|
|
175 (define-key map "F" 'vm-followup-include-text)
|
|
176 (define-key map "r" 'vm-reply)
|
|
177 (define-key map "R" 'vm-reply-include-text)
|
|
178 (define-key map "\M-r" 'vm-resend-bounced-message)
|
|
179 (define-key map "B" 'vm-resend-message)
|
|
180 (define-key map "z" 'vm-forward-message)
|
|
181 ;(define-key map "c" 'vm-continue-composing-message)
|
|
182 (define-key map "@" 'vm-send-digest)
|
|
183 ;(define-key map "*" 'vm-burst-digest)
|
|
184 (define-key map "m" 'vm-mail)
|
|
185 (define-key map "g" 'vm-get-new-mail)
|
|
186 ;(define-key map "G" 'vm-sort-messages)
|
|
187 (define-key map "v" 'vm-visit-folder)
|
|
188 (define-key map "s" 'vm-save-message)
|
|
189 ;(define-key map "w" 'vm-save-message-sans-headers)
|
|
190 ;(define-key map "A" 'vm-auto-archive-messages)
|
|
191 (define-key map "S" 'vm-save-folder)
|
|
192 ;(define-key map "|" 'vm-pipe-message-to-command)
|
|
193 (define-key map "#" 'vm-expunge-folder)
|
|
194 (define-key map "q" 'vm-quit)
|
|
195 (define-key map "x" 'vm-quit-no-change)
|
|
196 (define-key map "i" 'vm-iconify-frame)
|
|
197 (define-key map "?" 'vm-help)
|
|
198 (define-key map "\C-_" 'vm-undo)
|
|
199 (define-key map "\C-xu" 'vm-undo)
|
|
200 (define-key map "!" 'shell-command)
|
|
201 (define-key map "<" 'vm-beginning-of-message)
|
|
202 (define-key map ">" 'vm-end-of-message)
|
|
203 ;(define-key map "\M-s" 'vm-isearch-forward)
|
|
204 (define-key map "=" 'vm-summarize)
|
|
205 (define-key map "L" 'vm-load-init-file)
|
|
206 ;(define-key map "l" (make-sparse-keymap))
|
|
207 ;(define-key map "la" 'vm-add-message-labels)
|
|
208 ;(define-key map "ld" 'vm-delete-message-labels)
|
|
209 ;(define-key map "V" (make-sparse-keymap))
|
|
210 ;(define-key map "VV" 'vm-visit-virtual-folder)
|
|
211 ;(define-key map "VC" 'vm-create-virtual-folder)
|
|
212 ;(define-key map "VA" 'vm-apply-virtual-folder)
|
|
213 ;(define-key map "VM" 'vm-toggle-virtual-mirror)
|
|
214 ;(define-key map "V?" 'vm-virtual-help)
|
|
215 ;(define-key map "M" (make-sparse-keymap))
|
|
216 ;(define-key map "MN" 'vm-next-command-uses-marks)
|
|
217 ;(define-key map "Mn" 'vm-next-command-uses-marks)
|
|
218 ;(define-key map "MM" 'vm-mark-message)
|
|
219 ;(define-key map "MU" 'vm-unmark-message)
|
|
220 ;(define-key map "Mm" 'vm-mark-all-messages)
|
|
221 ;(define-key map "Mu" 'vm-clear-all-marks)
|
|
222 ;(define-key map "MC" 'vm-mark-matching-messages)
|
|
223 ;(define-key map "Mc" 'vm-unmark-matching-messages)
|
|
224 ;(define-key map "MT" 'vm-mark-thread-subtree)
|
|
225 ;(define-key map "Mt" 'vm-unmark-thread-subtree)
|
|
226 ;(define-key map "MS" 'vm-mark-messages-same-subject)
|
|
227 ;(define-key map "Ms" 'vm-unmark-messages-same-subject)
|
|
228 ;(define-key map "MA" 'vm-mark-messages-same-author)
|
|
229 ;(define-key map "Ma" 'vm-unmark-messages-same-author)
|
|
230 ;(define-key map "M?" 'vm-mark-help)
|
|
231 ;(define-key map "W" (make-sparse-keymap))
|
|
232 ;(define-key map "WW" 'vm-apply-window-configuration)
|
|
233 ;(define-key map "WS" 'vm-save-window-configuration)
|
|
234 ;(define-key map "WD" 'vm-delete-window-configuration)
|
|
235 ;(define-key map "W?" 'vm-window-help)
|
|
236 (define-key map "\C-t" 'vm-toggle-threads-display)
|
|
237 (define-key map "\C-x\C-s" 'vm-save-buffer)
|
|
238 (define-key map "\C-x\C-w" 'vm-write-file)
|
|
239 (define-key map "\C-x\C-q" 'vm-toggle-read-only)
|
|
240 ;(define-key map "%" 'vm-change-folder-type)
|
|
241 (define-key map "\M-C" 'vm-show-copying-restrictions)
|
|
242 (define-key map "\M-W" 'vm-show-no-warranty)
|
|
243 ;; suppress-keymap provides these, but now that we don't use
|
|
244 ;; suppress-keymap anymore...
|
|
245 (define-key map "0" 'digit-argument)
|
|
246 (define-key map "1" 'digit-argument)
|
|
247 (define-key map "2" 'digit-argument)
|
|
248 (define-key map "3" 'digit-argument)
|
|
249 (define-key map "4" 'digit-argument)
|
|
250 (define-key map "5" 'digit-argument)
|
|
251 (define-key map "6" 'digit-argument)
|
|
252 (define-key map "7" 'digit-argument)
|
|
253 (define-key map "8" 'digit-argument)
|
|
254 (define-key map "9" 'digit-argument)
|
|
255 (define-key map "-" 'negative-argument)
|
|
256 (if mouse-button-2
|
|
257 (define-key map mouse-button-2 (function tm:button-dispatcher)))
|
|
258 (if (vm-menu-fsfemacs-menus-p)
|
|
259 (progn
|
|
260 (vm-menu-initialize-vm-mode-menu-map)
|
|
261 (define-key map [menu-bar]
|
|
262 (lookup-key vm-mode-menu-map [rootmenu vm]))))
|
|
263 map)
|
|
264 "VM emulation keymap for MIME-Preview buffers.")
|
|
265
|
|
266 (defvar tm-vm/popup-menu
|
|
267 (let (fsfmenu
|
|
268 (dummy (make-sparse-keymap))
|
|
269 (menu (append vm-menu-dispose-menu
|
|
270 (list "----"
|
|
271 (cons mime-viewer/menu-title
|
|
272 (mapcar (function
|
|
273 (lambda (item)
|
|
274 (vector (nth 1 item)(nth 2 item) t)))
|
|
275 mime-viewer/menu-list))))))
|
|
276 (if running-xemacs
|
|
277 menu
|
|
278 (vm-easy-menu-define fsfmenu (list dummy) nil menu)
|
|
279 fsfmenu))
|
|
280 "VM's popup menu + MIME specific commands")
|
|
281
|
|
282
|
|
283
|
4
|
284 (define-key vm-mode-map "Z" 'tm-vm/view-message)
|
|
285 (define-key vm-mode-map "T" 'tm-vm/decode-message-header)
|
|
286 (define-key vm-mode-map "\et" 'tm-vm/toggle-preview-mode)
|
|
287
|
98
|
288 ; Disable VM 6 built-in MIME handling
|
|
289 (setq vm-display-using-mime nil)
|
|
290 (setq vm-send-using-mime nil)
|
4
|
291
|
98
|
292 ;;; @ MIME encoded-words
|
4
|
293
|
|
294 (defvar tm-vm/use-tm-patch nil
|
|
295 "Does not decode encoded-words in summary buffer if it is t.
|
|
296 If you use tiny-mime patch for VM (by RIKITAKE Kenji
|
|
297 <kenji@reseau.toyonaka.osaka.jp>), please set it t [tm-vm.el]")
|
|
298
|
|
299 (or tm-vm/use-tm-patch
|
|
300 (progn
|
70
|
301 ;;;
|
|
302 (defvar tm-vm/chop-full-name-function 'tm-vm/default-chop-full-name)
|
|
303 (setq vm-chop-full-name-function tm-vm/chop-full-name-function)
|
|
304
|
|
305 (defun tm-vm/default-chop-full-name (address)
|
|
306 (let* ((ret (vm-default-chop-full-name address))
|
|
307 (full-name (car ret))
|
|
308 )
|
|
309 (if (stringp full-name)
|
|
310 (cons (mime-eword/decode-string full-name)
|
|
311 (cdr ret))
|
|
312 ret)))
|
4
|
313
|
98
|
314 (defadvice vm-su-subject (after tm activate)
|
|
315 "MIME decoding support through TM added."
|
|
316 (setq ad-return-value (mime-eword/decode-string ad-return-value)))
|
4
|
317
|
98
|
318 (defadvice vm-su-full-name (after tm activate)
|
|
319 "MIME decoding support through TM added."
|
|
320 (setq ad-return-value (mime-eword/decode-string ad-return-value)))
|
22
|
321
|
98
|
322 (defadvice vm-su-to-names (after tm activate)
|
|
323 "MIME decoding support through TM added."
|
|
324 (setq ad-return-value (mime-eword/decode-string ad-return-value)))
|
|
325
|
4
|
326 ))
|
|
327
|
|
328 (defun tm-vm/decode-message-header (&optional count)
|
|
329 "Decode MIME header of current message.
|
|
330 Numeric prefix argument COUNT means to decode the current message plus
|
|
331 the next COUNT-1 messages. A negative COUNT means decode the current
|
|
332 message and the previous COUNT-1 messages.
|
|
333 When invoked on marked messages (via vm-next-command-uses-marks),
|
|
334 all marked messages are affected, other messages are ignored."
|
|
335 (interactive "p")
|
|
336 (or count (setq count 1))
|
|
337 (vm-follow-summary-cursor)
|
|
338 (vm-select-folder-buffer)
|
|
339 (vm-check-for-killed-summary)
|
|
340 (vm-error-if-folder-empty)
|
|
341 (vm-error-if-folder-read-only)
|
|
342 (let ((mlist (vm-select-marked-or-prefixed-messages count))
|
|
343 (realm nil)
|
|
344 (vlist nil)
|
|
345 (vbufs nil))
|
|
346 (save-excursion
|
|
347 (while mlist
|
|
348 (setq realm (vm-real-message-of (car mlist)))
|
|
349 ;; Go to real folder of this message.
|
|
350 ;; But maybe this message is already real message...
|
|
351 (set-buffer (vm-buffer-of realm))
|
|
352 (let ((buffer-read-only nil))
|
|
353 (vm-save-restriction
|
|
354 (narrow-to-region (vm-headers-of realm) (vm-text-of realm))
|
|
355 (mime/decode-message-header))
|
|
356 (let ((vm-message-pointer (list realm))
|
|
357 (last-command nil))
|
|
358 (vm-discard-cached-data))
|
|
359 ;; Mark each virtual and real message for later summary
|
|
360 ;; update.
|
|
361 (setq vlist (cons realm (vm-virtual-messages-of realm)))
|
|
362 (while vlist
|
|
363 (vm-mark-for-summary-update (car vlist))
|
|
364 ;; Remember virtual and real folders related this message,
|
|
365 ;; for later display update.
|
|
366 (or (memq (vm-buffer-of (car vlist)) vbufs)
|
|
367 (setq vbufs (cons (vm-buffer-of (car vlist)) vbufs)))
|
|
368 (setq vlist (cdr vlist)))
|
|
369 (if (eq vm-flush-interval t)
|
|
370 (vm-stuff-virtual-attributes realm)
|
|
371 (vm-set-modflag-of realm t)))
|
|
372 (setq mlist (cdr mlist)))
|
|
373 ;; Update mail-buffers and summaries.
|
|
374 (while vbufs
|
|
375 (set-buffer (car vbufs))
|
|
376 (vm-preview-current-message)
|
|
377 (setq vbufs (cdr vbufs))))))
|
|
378
|
|
379 (defun tm-vm/header-filter ()
|
98
|
380 "Filter headers in current buffer according to vm-visible-headers and vm-invisible-header-regexp.
|
|
381 Current buffer is assumed to have a message-like structure."
|
74
|
382 (goto-char (point-min))
|
4
|
383 (let ((visible-headers vm-visible-headers))
|
|
384 (if (or vm-use-lucid-highlighting
|
|
385 vm-display-xfaces)
|
|
386 (setq visible-headers (cons "X-Face:" vm-visible-headers)))
|
|
387 (vm-reorder-message-headers nil
|
|
388 visible-headers
|
|
389 vm-invisible-header-regexp)
|
|
390 (mime/decode-message-header)))
|
|
391
|
98
|
392 (setq mime-viewer/content-header-filter-alist
|
|
393 (append '((vm-mode . tm-vm/header-filter)
|
|
394 (vm-virtual-mode . tm-vm/header-filter))
|
|
395 mime-viewer/content-header-filter-alist))
|
|
396
|
|
397
|
|
398
|
|
399 ;;; @ MIME Viewer
|
|
400
|
|
401 ;;; @@ MIME-Preview buffer management
|
|
402
|
|
403 (defvar tm-vm/system-state nil)
|
|
404
|
4
|
405 (defun tm-vm/system-state ()
|
|
406 (save-excursion
|
|
407 (if mime::preview/article-buffer
|
|
408 (set-buffer mime::preview/article-buffer)
|
|
409 (vm-select-folder-buffer))
|
|
410 tm-vm/system-state))
|
|
411
|
98
|
412 (defun tm-vm/build-preview-buffer ()
|
|
413 "Build the MIME Preview buffer for the current VM message.
|
|
414 Current buffer should be VM's folder buffer."
|
|
415
|
|
416 (set (make-local-variable 'tm-vm/system-state) 'mime-viewing)
|
|
417 (setq vm-system-state 'reading)
|
|
418
|
|
419 ;; Update message flags and store them in folder buffer before
|
|
420 ;; entering MIME viewer
|
|
421 (tm-vm/update-message-status)
|
|
422
|
|
423 ;; We need to save window configuration because we may be working
|
|
424 ;; in summary window
|
|
425 (save-window-excursion
|
|
426 (save-restriction
|
|
427 (save-excursion
|
|
428 (widen)
|
|
429 (goto-char (vm-start-of (car vm-message-pointer)))
|
|
430 (forward-line)
|
|
431 (narrow-to-region (point)
|
|
432 (vm-end-of (car vm-message-pointer)))
|
|
433
|
|
434 (let ((ml vm-message-list))
|
|
435 (mime/viewer-mode nil nil nil nil nil nil)
|
|
436 (setq vm-mail-buffer mime::preview/article-buffer)
|
|
437 (setq vm-message-list ml))
|
|
438 ;; Install VM toolbar for MIME-Preview buffer if not installed
|
|
439 (tm-vm/check-for-toolbar)
|
|
440 (if tm-vm/use-vm-bindings
|
|
441 (progn
|
|
442 (define-key tm-vm/vm-emulation-map "\C-c" (current-local-map))
|
|
443 (use-local-map tm-vm/vm-emulation-map)
|
|
444 (vm-menu-install-menubar)
|
|
445 (if (and vm-use-menus
|
|
446 (vm-menu-support-possible-p))
|
|
447 (setq mode-popup-menu tm-vm/popup-menu))))
|
|
448
|
|
449 ;; Highlight message (and display XFace if supported)
|
|
450 (if (or vm-highlighted-header-regexp
|
|
451 (and (vm-xemacs-p) vm-use-lucid-highlighting))
|
|
452 (vm-highlight-headers))
|
|
453 ;; Energize URLs and buttons
|
|
454 (if (and tm-vm/use-original-url-button
|
|
455 vm-use-menus (vm-menu-support-possible-p))
|
|
456 (progn
|
|
457 (vm-energize-urls)
|
|
458 (vm-energize-headers)))
|
|
459 (run-hooks 'tm-vm/build-mime-preview-buffer-hook)
|
|
460 ))))
|
|
461
|
4
|
462 (defun tm-vm/sync-preview-buffer ()
|
98
|
463 "Ensure that the MIME preview buffer, if it exists, actually corresponds to the current message.
|
|
464 If no MIME Preview buffer is needed then kill it. If no
|
4
|
465 MIME Preview buffer exists nothing is done."
|
|
466 ;; Current buffer should be message buffer when calling this function
|
|
467 (let* ((mbuf (current-buffer))
|
|
468 (pbuf (and mime::article/preview-buffer
|
98
|
469 (get-buffer mime::article/preview-buffer))))
|
4
|
470 (if pbuf
|
98
|
471 ;; A MIME Preview buffer exists then it may need to be synch'ed
|
|
472 (save-excursion
|
|
473 (set-buffer mbuf)
|
|
474 (if (and tm-vm/strict-mime
|
|
475 (not (vm-get-header-contents (car vm-message-pointer)
|
|
476 "MIME-Version:")))
|
|
477 (progn
|
|
478 (setq mime::article/preview-buffer nil
|
|
479 tm-vm/system-state nil)
|
|
480 (if pbuf (kill-buffer pbuf)))
|
|
481 (tm-vm/build-preview-buffer)))
|
4
|
482 ;; Return to previous frame
|
98
|
483 )))
|
|
484
|
|
485 (defun tm-vm/toggle-preview-mode ()
|
|
486 "Toggle automatic MIME preview on or off.
|
|
487 In automatic MIME Preview mode each newly selected article is MIME processed if
|
|
488 it has MIME content without need for an explicit request from the user. This
|
|
489 behaviour is controlled by the variable tm-vm/automatic-mime-preview."
|
|
490
|
|
491 (interactive)
|
|
492 (if tm-vm/automatic-mime-preview
|
|
493 (progn
|
|
494 (tm-vm/quit-view-message)
|
|
495 (setq tm-vm/automatic-mime-preview nil)
|
|
496 (message "Automatic MIME Preview is now disabled."))
|
|
497 ;; Enable Automatic MIME Preview
|
|
498 (tm-vm/view-message)
|
|
499 (setq tm-vm/automatic-mime-preview t)
|
|
500 (message "Automatic MIME Preview is now enabled.")
|
|
501 ))
|
|
502
|
|
503 ;;; @@ Display functions
|
|
504
|
|
505 (defun tm-vm/update-message-status ()
|
|
506 "Update current message display and summary.
|
|
507 Remove 'unread' and 'new' flags. The MIME Preview buffer is not displayed,
|
|
508 tm-vm/display-preview-buffer should be called for that. This function is
|
|
509 display-configuration safe."
|
|
510 (if mime::preview/article-buffer
|
|
511 (set-buffer mime::preview/article-buffer)
|
|
512 (vm-select-folder-buffer))
|
|
513 (if (or (and mime::article/preview-buffer
|
|
514 (get-buffer mime::article/preview-buffer)
|
|
515 (vm-get-visible-buffer-window mime::article/preview-buffer))
|
|
516 (vm-get-visible-buffer-window (current-buffer)))
|
|
517 (progn
|
|
518 (if (vm-new-flag (car vm-message-pointer))
|
|
519 (vm-set-new-flag (car vm-message-pointer) nil))
|
|
520 (if (vm-unread-flag (car vm-message-pointer))
|
|
521 (vm-set-unread-flag (car vm-message-pointer) nil))
|
|
522 (vm-update-summary-and-mode-line)
|
|
523 (tm-vm/howl-if-eom))
|
|
524 (vm-update-summary-and-mode-line)))
|
4
|
525
|
|
526 (defun tm-vm/display-preview-buffer ()
|
98
|
527 "Replace the VM message buffer with the MIME-Preview buffer if the VM message buffer is currently displayed or undisplay it if tm-vm/system-state is nil."
|
4
|
528 (let* ((mbuf (current-buffer))
|
|
529 (mwin (vm-get-visible-buffer-window mbuf))
|
|
530 (pbuf (and mime::article/preview-buffer
|
|
531 (get-buffer mime::article/preview-buffer)))
|
|
532 (pwin (and pbuf (vm-get-visible-buffer-window pbuf))))
|
|
533 (if (and pbuf (tm-vm/system-state))
|
98
|
534 ;; display preview buffer if preview-buffer exists
|
4
|
535 (cond
|
|
536 ((and mwin pwin)
|
|
537 (vm-undisplay-buffer mbuf)
|
98
|
538 (tm-vm/update-message-status))
|
4
|
539 ((and mwin (not pwin))
|
|
540 (set-window-buffer mwin pbuf)
|
98
|
541 (tm-vm/update-message-status))
|
4
|
542 (pwin
|
98
|
543 (tm-vm/update-message-status))
|
4
|
544 (t
|
|
545 ;; don't display if neither mwin nor pwin was displayed before.
|
|
546 ))
|
|
547 ;; display folder buffer
|
|
548 (cond
|
|
549 ((and mwin pwin)
|
|
550 (vm-undisplay-buffer pbuf))
|
|
551 ((and (not mwin) pwin)
|
|
552 (set-window-buffer pwin mbuf))
|
|
553 (mwin
|
|
554 ;; folder buffer is already displayed.
|
|
555 )
|
|
556 (t
|
|
557 ;; don't display if neither mwin nor pwin was displayed before.
|
98
|
558 )))))
|
4
|
559
|
|
560 (defun tm-vm/preview-current-message ()
|
98
|
561 "Either preview message (view first lines only) or MIME-Preview it.
|
|
562 The message is previewed if message previewing is enabled see vm-preview-lines.
|
|
563 If not, MIME-Preview current message (ie. parse MIME
|
|
564 contents and display appropriately) if it has MIME contents and
|
|
565 tm-vm/automatic-mime-preview is non nil. Installed on vm-visit-folder-hook and
|
|
566 vm-select-message-hook."
|
4
|
567 ;; assumed current buffer is folder buffer.
|
|
568 (setq tm-vm/system-state nil)
|
|
569 (if (get-buffer mime/output-buffer-name)
|
|
570 (vm-undisplay-buffer mime/output-buffer-name))
|
98
|
571 (if (and vm-message-pointer
|
|
572 tm-vm/automatic-mime-preview
|
|
573 (or (null vm-preview-lines)
|
|
574 (not (eq vm-system-state 'previewing))
|
|
575 (and (not vm-preview-read-messages)
|
|
576 (not (vm-new-flag (car vm-message-pointer)))
|
|
577 (not (vm-unread-flag (car vm-message-pointer))))))
|
4
|
578 (if (or (not tm-vm/strict-mime)
|
|
579 (vm-get-header-contents (car vm-message-pointer)
|
|
580 "MIME-Version:"))
|
|
581 ;; do MIME processing.
|
98
|
582 (progn
|
|
583 (tm-vm/build-preview-buffer)
|
|
584 (save-excursion
|
|
585 (set-buffer mime::article/preview-buffer)
|
|
586 (run-hooks 'tm-vm/select-message-hook)))
|
4
|
587 ;; don't do MIME processing. decode header only.
|
|
588 (let (buffer-read-only)
|
98
|
589 (mime/decode-message-header)
|
|
590 (run-hooks 'tm-vm/select-message-hook))
|
4
|
591 )
|
|
592 ;; don't preview; do nothing.
|
98
|
593 (run-hooks 'tm-vm/select-message-hook))
|
|
594 (tm-vm/display-preview-buffer))
|
|
595
|
|
596 (defun tm-vm/view-message ()
|
|
597 "Decode and view the current VM message as a MIME encoded message.
|
|
598 A MIME Preview buffer using mime/viewer-mode is created.
|
|
599 See mime/viewer-mode for more information"
|
|
600 (interactive)
|
|
601 (vm-follow-summary-cursor)
|
|
602 (vm-select-folder-buffer)
|
|
603 (vm-check-for-killed-summary)
|
|
604 (vm-error-if-folder-empty)
|
|
605 (vm-display (current-buffer) t '(tm-vm/view-message
|
|
606 tm-vm/toggle-preview-mode)
|
|
607 '(tm-vm/view-message reading-message))
|
|
608 (let ((tm-vm/automatic-mime-preview t))
|
|
609 (tm-vm/preview-current-message))
|
|
610 )
|
4
|
611
|
98
|
612 (defun tm-vm/quit-view-message ()
|
|
613 "Quit MIME-Viewer and go back to normal VM.
|
|
614 MIME Preview buffer is killed. This function is called by `mime-viewer/quit'
|
|
615 command via `mime-viewer/quitting-method-alist'."
|
|
616 (if (get-buffer mime/output-buffer-name)
|
|
617 (vm-undisplay-buffer mime/output-buffer-name))
|
|
618 (vm-select-folder-buffer)
|
|
619 (let* ((mbuf (current-buffer))
|
|
620 (pbuf (and mime::article/preview-buffer
|
|
621 (get-buffer mime::article/preview-buffer)))
|
|
622 (pwin (and pbuf (vm-get-visible-buffer-window pbuf))))
|
|
623 (if pbuf (kill-buffer pbuf))
|
|
624 (and pwin
|
|
625 (select-window pwin)
|
|
626 (switch-to-buffer mbuf)))
|
|
627 (setq tm-vm/system-state nil)
|
|
628 (vm-display (current-buffer) t (list this-command)
|
|
629 (list 'reading-message)))
|
4
|
630
|
|
631 (add-hook 'vm-select-message-hook 'tm-vm/preview-current-message)
|
|
632 (add-hook 'vm-visit-folder-hook 'tm-vm/preview-current-message)
|
70
|
633
|
|
634
|
4
|
635
|
|
636
|
98
|
637
|
|
638 ;;; @@ for tm-view
|
4
|
639
|
|
640 ;;; based on vm-do-reply [vm-reply.el]
|
|
641 (defun tm-vm/do-reply (buf to-all include-text)
|
|
642 (save-excursion
|
|
643 (set-buffer buf)
|
|
644 (let ((dir default-directory)
|
98
|
645 to cc subject in-reply-to references newsgroups)
|
4
|
646 (cond ((setq to
|
|
647 (let ((reply-to (std11-field-body "Reply-To")))
|
|
648 (if (vm-ignored-reply-to reply-to)
|
|
649 nil
|
|
650 reply-to))))
|
|
651 ((setq to (std11-field-body "From")))
|
|
652 ;; (t (error "No From: or Reply-To: header in message"))
|
|
653 )
|
|
654 (if to-all
|
|
655 (setq cc (delq nil (cons cc (std11-field-bodies '("To" "Cc"))))
|
|
656 cc (mapconcat 'identity cc ","))
|
|
657 )
|
|
658 (setq subject (std11-field-body "Subject"))
|
|
659 (and subject vm-reply-subject-prefix
|
|
660 (let ((case-fold-search t))
|
|
661 (not
|
|
662 (equal
|
|
663 (string-match (regexp-quote vm-reply-subject-prefix)
|
|
664 subject)
|
|
665 0)))
|
|
666 (setq subject (concat vm-reply-subject-prefix subject)))
|
|
667 (setq in-reply-to (std11-field-body "Message-Id")
|
|
668 references (nconc
|
|
669 (std11-field-bodies '("References" "In-Reply-To"))
|
|
670 (list in-reply-to))
|
|
671 newsgroups (list (or (and to-all
|
|
672 (std11-field-body "Followup-To"))
|
|
673 (std11-field-body "Newsgroups"))))
|
|
674 (setq to (vm-parse-addresses to)
|
|
675 cc (vm-parse-addresses cc))
|
|
676 (if vm-reply-ignored-addresses
|
|
677 (setq to (vm-strip-ignored-addresses to)
|
|
678 cc (vm-strip-ignored-addresses cc)))
|
|
679 (setq to (vm-delete-duplicates to nil t))
|
|
680 (setq cc (vm-delete-duplicates
|
|
681 (append (vm-delete-duplicates cc nil t)
|
|
682 to (copy-sequence to))
|
|
683 t t))
|
|
684 (and to (setq to (mapconcat 'identity to ",\n ")))
|
|
685 (and cc (setq cc (mapconcat 'identity cc ",\n ")))
|
|
686 (and (null to) (setq to cc cc nil))
|
|
687 (setq references (delq nil references)
|
|
688 references (mapconcat 'identity references " ")
|
|
689 references (vm-parse references "[^<]*\\(<[^>]+>\\)")
|
|
690 references (vm-delete-duplicates references)
|
|
691 references (if references (mapconcat 'identity references "\n\t")))
|
|
692 (setq newsgroups (delq nil newsgroups)
|
|
693 newsgroups (mapconcat 'identity newsgroups ",")
|
|
694 newsgroups (vm-parse newsgroups "[ \t\f\r\n,]*\\([^ \t\f\r\n,]+\\)")
|
|
695 newsgroups (vm-delete-duplicates newsgroups)
|
|
696 newsgroups (if newsgroups (mapconcat 'identity newsgroups ",")))
|
|
697 (vm-mail-internal
|
|
698 (if to
|
|
699 (format "reply to %s%s"
|
|
700 (std11-full-name-string
|
|
701 (car (std11-parse-address-string to)))
|
|
702 (if cc ", ..." "")))
|
|
703 to subject in-reply-to cc references newsgroups)
|
|
704 (setq mail-reply-buffer buf
|
|
705 ;; vm-system-state 'replying
|
|
706 default-directory dir))
|
|
707 (if include-text
|
|
708 (save-excursion
|
|
709 (goto-char (point-min))
|
|
710 (let ((case-fold-search nil))
|
|
711 (re-search-forward
|
|
712 (concat "^" (regexp-quote mail-header-separator) "$") nil 0))
|
|
713 (forward-char 1)
|
|
714 (tm-vm/yank-content)))
|
|
715 (run-hooks 'vm-reply-hook)
|
|
716 (run-hooks 'vm-mail-mode-hook)
|
|
717 ))
|
|
718
|
|
719 (defun tm-vm/following-method (buf)
|
|
720 (tm-vm/do-reply buf 'to-all 'include-text)
|
|
721 )
|
|
722
|
|
723 (defun tm-vm/yank-content ()
|
|
724 (interactive)
|
|
725 (let ((this-command 'vm-yank-message))
|
|
726 (vm-display nil nil '(vm-yank-message)
|
|
727 '(vm-yank-message composing-message))
|
|
728 (save-restriction
|
|
729 (narrow-to-region (point)(point))
|
|
730 (insert-buffer mail-reply-buffer)
|
|
731 (goto-char (point-max))
|
|
732 (push-mark)
|
|
733 (goto-char (point-min)))
|
|
734 (cond (mail-citation-hook (run-hooks 'mail-citation-hook))
|
|
735 (mail-yank-hooks (run-hooks 'mail-yank-hooks))
|
|
736 (t (mail-indent-citation)))
|
|
737 ))
|
|
738
|
|
739 (set-alist 'mime-viewer/following-method-alist
|
|
740 'vm-mode
|
|
741 (function tm-vm/following-method))
|
|
742 (set-alist 'mime-viewer/following-method-alist
|
|
743 'vm-virtual-mode
|
|
744 (function tm-vm/following-method))
|
|
745
|
70
|
746
|
4
|
747 (set-alist 'mime-viewer/quitting-method-alist
|
|
748 'vm-mode
|
|
749 'tm-vm/quit-view-message)
|
70
|
750
|
4
|
751 (set-alist 'mime-viewer/quitting-method-alist
|
|
752 'vm-virtual-mode
|
|
753 'tm-vm/quit-view-message)
|
|
754
|
98
|
755 ;;; @@ Motion commands
|
4
|
756
|
98
|
757 (defmacro tm-vm/save-window-excursion (&rest forms)
|
|
758 (list 'let '((tm-vm/selected-window (selected-window)))
|
|
759 (list 'unwind-protect
|
|
760 (cons 'progn forms)
|
|
761 '(if (window-live-p tm-vm/selected-window)
|
|
762 (select-window tm-vm/selected-window)))))
|
|
763
|
|
764 (defmacro tm-vm/save-frame-excursion (&rest forms)
|
|
765 (list 'let '((tm-vm/selected-frame (vm-selected-frame)))
|
|
766 (list 'unwind-protect
|
|
767 (cons 'progn forms)
|
|
768 '(if (frame-live-p tm-vm/selected-frame)
|
|
769 (vm-select-frame tm-vm/selected-frame)))))
|
|
770
|
|
771 (defadvice vm-scroll-forward (around tm-aware activate)
|
|
772 "Made TM-aware (handles the MIME-Preview buffer)."
|
|
773 (if (and
|
|
774 (not (save-excursion
|
|
775 (if mime::preview/article-buffer
|
|
776 (set-buffer mime::preview/article-buffer))
|
|
777 (vm-select-folder-buffer)
|
|
778 (eq vm-system-state 'previewing)))
|
|
779 (not (tm-vm/system-state)))
|
|
780 (progn
|
|
781 ad-do-it
|
|
782 (tm-vm/display-preview-buffer))
|
|
783 (let* ((mp-changed (vm-follow-summary-cursor))
|
|
784 (mbuf (or (vm-select-folder-buffer) (current-buffer)))
|
|
785 (mwin (vm-get-buffer-window mbuf))
|
|
786 (pbuf (and mime::article/preview-buffer
|
|
787 (get-buffer mime::article/preview-buffer)))
|
|
788 (pwin (and pbuf (vm-get-buffer-window pbuf)))
|
|
789 )
|
|
790 (vm-check-for-killed-summary)
|
|
791 (vm-error-if-folder-empty)
|
|
792 (cond
|
|
793 ; A new message was selected
|
|
794 ; => leave it to tm-vm/preview-current-message
|
|
795 (mp-changed
|
|
796 nil)
|
|
797 ((eq vm-system-state 'previewing)
|
|
798 (vm-display (current-buffer) t (list this-command) '(reading-message))
|
|
799 (vm-show-current-message)
|
|
800 (tm-vm/preview-current-message))
|
|
801 ; Preview buffer was killed
|
|
802 ((null pbuf)
|
|
803 (tm-vm/preview-current-message))
|
|
804 ; Preview buffer was undisplayed
|
|
805 ((null pwin)
|
|
806 (if (null mwin)
|
|
807 (vm-display mbuf t '(vm-scroll-forward vm-scroll-backward)
|
|
808 (list this-command 'reading-message)))
|
|
809 (tm-vm/display-preview-buffer))
|
|
810 ; Preview buffer is displayed => scroll
|
|
811 (t
|
|
812 (tm-vm/save-window-excursion
|
|
813 (select-window pwin)
|
|
814 (set-buffer pbuf)
|
|
815 (if (pos-visible-in-window-p (point-max) pwin)
|
|
816 (if vm-auto-next-message
|
|
817 (vm-next-message))
|
|
818 ;; not at the end of message. scroll preview buffer only.
|
|
819 (scroll-up)
|
|
820 (tm-vm/howl-if-eom))
|
|
821 ))))
|
|
822 )
|
|
823 )
|
|
824
|
|
825 (defadvice vm-scroll-backward (around tm-aware activate)
|
|
826 "Made TM-aware (handles the MIME-Preview buffer)."
|
|
827 (if (and
|
|
828 (not (save-excursion
|
|
829 (if mime::preview/article-buffer
|
|
830 (set-buffer mime::preview/article-buffer))
|
|
831 (vm-select-folder-buffer)
|
|
832 (eq vm-system-state 'previewing)))
|
|
833 (not (tm-vm/system-state)))
|
|
834 ad-do-it
|
|
835 (let* ((mp-changed (vm-follow-summary-cursor))
|
|
836 (mbuf (or (vm-select-folder-buffer) (current-buffer)))
|
|
837 (mwin (vm-get-buffer-window mbuf))
|
|
838 (pbuf (and mime::article/preview-buffer
|
|
839 (get-buffer mime::article/preview-buffer)))
|
|
840 (pwin (and pbuf (vm-get-buffer-window pbuf)))
|
|
841 )
|
|
842 (vm-check-for-killed-summary)
|
|
843 (vm-error-if-folder-empty)
|
|
844 (cond
|
|
845 ; A new message was selected
|
|
846 ; => leave it to tm-vm/preview-current-message
|
|
847 (mp-changed
|
|
848 nil)
|
|
849 ((eq vm-system-state 'previewing)
|
|
850 (tm-vm/update-message-status)
|
|
851 (setq vm-system-state 'reading)
|
|
852 (tm-vm/preview-current-message))
|
|
853 ; Preview buffer was killed
|
|
854 ((null pbuf)
|
|
855 (tm-vm/preview-current-message))
|
|
856 ; Preview buffer was undisplayed
|
|
857 ((null pwin)
|
|
858 (if (null mwin)
|
|
859 (vm-display mbuf t '(vm-scroll-forward vm-scroll-backward)
|
|
860 (list this-command 'reading-message)))
|
|
861 (tm-vm/display-preview-buffer))
|
|
862 ; Preview buffer is displayed => scroll
|
|
863 (t
|
|
864 (tm-vm/save-window-excursion
|
|
865 (select-window pwin)
|
|
866 (if (pos-visible-in-window-p (point-min) pwin)
|
|
867 nil
|
|
868 ;; not at the end of message. scroll preview buffer only.
|
|
869 (scroll-down))
|
|
870 ))))
|
|
871 ))
|
|
872
|
|
873 (defadvice vm-beginning-of-message (around tm-aware activate)
|
|
874 "Made TM-aware, works properly in MIME-Preview buffers."
|
|
875 (if (not (tm-vm/system-state))
|
|
876 ad-do-it
|
|
877 (vm-follow-summary-cursor)
|
|
878 (vm-select-folder-buffer)
|
|
879 (vm-check-for-killed-summary)
|
|
880 (vm-error-if-folder-empty)
|
|
881 (let ((pbuf (and mime::article/preview-buffer
|
|
882 (get-buffer mime::article/preview-buffer))))
|
|
883 (if (null pbuf)
|
|
884 (progn
|
|
885 (tm-vm/preview-current-message)
|
|
886 (setq pbuf (get-buffer mime::article/preview-buffer))
|
|
887 ))
|
|
888 (vm-display (current-buffer) t '(vm-beginning-of-message)
|
|
889 '(vm-beginning-of-message reading-message))
|
|
890 (tm-vm/display-preview-buffer)
|
|
891 (tm-vm/save-window-excursion
|
|
892 (select-window (vm-get-visible-buffer-window pbuf))
|
|
893 (push-mark)
|
|
894 (goto-char (point-min))
|
|
895 (vm-display (current-buffer) t '(vm-beginning-of-message)
|
|
896 '(vm-beginning-of-message reading-message))
|
|
897 ))))
|
|
898
|
|
899 (defadvice vm-end-of-message (around tm-aware activate)
|
|
900 "Made TM-aware, works properly in MIME-Preview buffers."
|
|
901 (interactive)
|
|
902 (if (not (tm-vm/system-state))
|
|
903 ad-do-it
|
|
904 (vm-follow-summary-cursor)
|
|
905 (vm-select-folder-buffer)
|
|
906 (vm-check-for-killed-summary)
|
|
907 (vm-error-if-folder-empty)
|
|
908 (let ((pbuf (and mime::article/preview-buffer
|
|
909 (get-buffer mime::article/preview-buffer))))
|
|
910 (if (null pbuf)
|
|
911 (progn
|
|
912 (tm-vm/preview-current-message)
|
|
913 (setq pbuf (get-buffer mime::article/preview-buffer))
|
|
914 ))
|
|
915 (vm-display (current-buffer) t '(vm-end-of-message)
|
|
916 '(vm-end-of-message reading-message))
|
|
917 (tm-vm/display-preview-buffer)
|
|
918 (tm-vm/save-window-excursion
|
|
919 (select-window (vm-get-buffer-window pbuf))
|
|
920 (push-mark)
|
|
921 (goto-char (point-max))
|
|
922 (vm-display (current-buffer) t '(vm-end-of-message)
|
|
923 '(vm-end-of-message reading-message))
|
|
924 ))))
|
|
925
|
|
926 ;;; based on vm-howl-if-eom [vm-page.el]
|
|
927 (defun tm-vm/howl-if-eom ()
|
|
928 (let* ((pbuf (or mime::article/preview-buffer (current-buffer)))
|
|
929 (pwin (and (vm-get-visible-buffer-window pbuf))))
|
|
930 (and pwin
|
|
931 (save-excursion
|
|
932 (save-window-excursion
|
|
933 (condition-case ()
|
|
934 (let ((next-screen-context-lines 0))
|
|
935 (tm-vm/save-frame-excursion
|
|
936 (vm-select-frame (vm-window-frame pwin))
|
|
937 (save-selected-window
|
|
938 (select-window pwin)
|
|
939 (save-excursion
|
|
940 (let ((scroll-in-place-replace-original nil))
|
|
941 (scroll-up)))))
|
|
942 nil)
|
|
943 (error t))))
|
|
944 (vm-emit-eom-blurb)
|
|
945 )))
|
|
946
|
|
947 (defadvice vm-emit-eom-blurb (around tm-aware activate)
|
|
948 "Made TM-aware, works properly in MIME-Preview buffers."
|
|
949 (save-excursion
|
|
950 (if mime::preview/article-buffer
|
|
951 (set-buffer mime::preview/article-buffer))
|
|
952 ad-do-it))
|
|
953
|
|
954 (defadvice vm-next-message (around tm-aware activate)
|
|
955 "Made TM-aware, works properly in MIME-Preview buffers."
|
|
956 (if mime::preview/article-buffer
|
|
957 (set-buffer mime::preview/article-buffer))
|
|
958 (tm-vm/save-window-excursion
|
|
959 ad-do-it))
|
|
960
|
|
961 (defadvice vm-previous-message (around tm-aware activate)
|
|
962 "Made TM-aware, works properly in MIME-Preview buffers."
|
|
963 (if mime::preview/article-buffer
|
|
964 (set-buffer mime::preview/article-buffer))
|
|
965 (tm-vm/save-window-excursion
|
|
966 ad-do-it))
|
|
967
|
|
968 (defadvice vm-next-message-no-skip (around tm-aware activate)
|
|
969 "Made TM-aware, works properly in MIME-Preview buffers."
|
|
970 (if mime::preview/article-buffer
|
|
971 (set-buffer mime::preview/article-buffer))
|
|
972 (tm-vm/save-window-excursion
|
|
973 ad-do-it))
|
|
974
|
|
975 (defadvice vm-previous-message-no-skip (around tm-aware activate)
|
|
976 "TM wrapper for vm-previous-message-no-skip (which see)."
|
|
977 (if mime::preview/article-buffer
|
|
978 (set-buffer mime::preview/article-buffer))
|
|
979 (tm-vm/save-window-excursion
|
|
980 ad-do-it))
|
|
981
|
|
982 (defadvice vm-next-unread-message (around tm-aware activate)
|
|
983 "Made TM-aware, works properly in MIME-Preview buffers."
|
|
984 (if mime::preview/article-buffer
|
|
985 (set-buffer mime::preview/article-buffer))
|
|
986 (tm-vm/save-window-excursion
|
|
987 ad-do-it))
|
|
988
|
|
989 (defadvice vm-previous-unread-message (around tm-aware activate)
|
|
990 "Made TM-aware, works properly in MIME-Preview buffers."
|
|
991 (if mime::preview/article-buffer
|
|
992 (set-buffer mime::preview/article-buffer))
|
|
993 (tm-vm/save-window-excursion
|
|
994 ad-do-it))
|
|
995
|
|
996
|
|
997 (set-alist 'mime-viewer/over-to-previous-method-alist
|
|
998 'vm-mode 'vm-previous-message)
|
|
999 (set-alist 'mime-viewer/over-to-next-method-alist
|
|
1000 'vm-mode 'vm-next-message)
|
|
1001 (set-alist 'mime-viewer/over-to-previous-method-alist
|
|
1002 'vm-virtual-mode 'vm-previous-message)
|
|
1003 (set-alist 'mime-viewer/over-to-next-method-alist
|
|
1004 'vm-virtual-mode 'vm-next-message)
|
|
1005
|
|
1006
|
|
1007
|
|
1008
|
|
1009
|
|
1010
|
|
1011 ;;; @ MIME Editor
|
|
1012
|
|
1013 ;;; @@ vm-yank-message
|
|
1014
|
|
1015
|
|
1016 (defvar tm-vm/yank:message-to-restore nil
|
|
1017 "For internal use by tm-vm only.")
|
|
1018
|
|
1019 (defun vm-yank-message (&optional message)
|
|
1020 "Yank message number N into the current buffer at point.
|
|
1021 When called interactively N is always read from the minibuffer. When
|
|
1022 called non-interactively the first argument is expected to be a
|
|
1023 message struct.
|
|
1024
|
|
1025 This function originally provided by vm-reply has been patched for TM
|
|
1026 in order to provide better citation of MIME messages : if a MIME
|
|
1027 Preview buffer exists for the message then its contents are inserted
|
|
1028 instead of the raw message.
|
|
1029
|
|
1030 This command is meant to be used in VM created Mail mode buffers; the
|
|
1031 yanked message comes from the mail buffer containing the message you
|
|
1032 are replying to, forwarding, or invoked VM's mail command from.
|
|
1033
|
|
1034 All message headers are yanked along with the text. Point is
|
|
1035 left before the inserted text, the mark after. Any hook
|
|
1036 functions bound to mail-citation-hook are run, after inserting
|
|
1037 the text and setting point and mark. For backward compatibility,
|
|
1038 if mail-citation-hook is set to nil, `mail-yank-hooks' is run
|
|
1039 instead.
|
|
1040
|
|
1041 If mail-citation-hook and mail-yank-hooks are both nil, this
|
|
1042 default action is taken: the yanked headers are trimmed as
|
|
1043 specified by vm-included-text-headers and
|
|
1044 vm-included-text-discard-header-regexp, and the value of
|
|
1045 vm-included-text-prefix is prepended to every yanked line."
|
|
1046 (interactive
|
|
1047 (list
|
|
1048 ;; What we really want for the first argument is a message struct,
|
|
1049 ;; but if called interactively, we let the user type in a message
|
|
1050 ;; number instead.
|
|
1051 (let (mp default
|
|
1052 (result 0)
|
|
1053 prompt
|
|
1054 (last-command last-command)
|
|
1055 (this-command this-command))
|
|
1056 (if (bufferp vm-mail-buffer)
|
|
1057 (save-excursion
|
|
1058 (vm-select-folder-buffer)
|
|
1059 (setq default (and vm-message-pointer
|
|
1060 (vm-number-of (car vm-message-pointer)))
|
|
1061 prompt (if default
|
|
1062 (format "Yank message number: (default %s) "
|
|
1063 default)
|
|
1064 "Yank message number: "))
|
|
1065 (while (zerop result)
|
|
1066 (setq result (read-string prompt))
|
|
1067 (and (string= result "") default (setq result default))
|
|
1068 (setq result (string-to-int result)))
|
|
1069 (if (null (setq mp (nthcdr (1- result) vm-message-list)))
|
|
1070 (error "No such message."))
|
|
1071 (setq tm-vm/yank:message-to-restore (string-to-int default))
|
|
1072 (save-selected-window
|
|
1073 (vm-goto-message result))
|
|
1074 (car mp))
|
|
1075 nil))))
|
|
1076 (if (null message)
|
|
1077 (if mail-reply-buffer
|
|
1078 (tm-vm/yank-content)
|
|
1079 (error "This is not a VM Mail mode buffer."))
|
|
1080 (if (null (buffer-name vm-mail-buffer))
|
|
1081 (error "The folder buffer containing message %d has been killed."
|
|
1082 (vm-number-of message)))
|
|
1083 (vm-display nil nil '(vm-yank-message)
|
|
1084 '(vm-yank-message composing-message))
|
|
1085 (let ((b (current-buffer)) (start (point)) end)
|
|
1086 (save-restriction
|
|
1087 (widen)
|
|
1088 (save-excursion
|
|
1089 (set-buffer (vm-buffer-of message))
|
|
1090 (let (pbuf)
|
|
1091 (tm-vm/sync-preview-buffer)
|
|
1092 (setq pbuf (and mime::article/preview-buffer
|
|
1093 (get-buffer mime::article/preview-buffer)))
|
|
1094 (if (and pbuf
|
|
1095 (not (eq this-command 'vm-forward-message)))
|
|
1096 ;; Yank contents of MIME Preview buffer
|
|
1097 (if running-xemacs
|
|
1098 (let ((tmp (generate-new-buffer "tm-vm/tmp")))
|
|
1099 (set-buffer pbuf)
|
|
1100 (append-to-buffer tmp (point-min) (point-max))
|
|
1101 (set-buffer tmp)
|
|
1102 (map-extents
|
|
1103 '(lambda (ext maparg)
|
|
1104 (set-extent-property ext 'begin-glyph nil)))
|
|
1105 (append-to-buffer b (point-min) (point-max))
|
|
1106 (setq end (vm-marker
|
|
1107 (+ start (length (buffer-string))) b))
|
|
1108 (kill-buffer tmp))
|
|
1109 (set-buffer pbuf)
|
|
1110 (append-to-buffer b (point-min) (point-max))
|
|
1111 (setq end (vm-marker
|
|
1112 (+ start (length (buffer-string))) b)))
|
|
1113 ;; Yank contents of raw VM message
|
|
1114 (save-restriction
|
|
1115 (setq message (vm-real-message-of message))
|
|
1116 (set-buffer (vm-buffer-of message))
|
|
1117 (widen)
|
|
1118 (append-to-buffer
|
|
1119 b (vm-headers-of message) (vm-text-end-of message))
|
|
1120 (setq end
|
|
1121 (vm-marker (+ start (- (vm-text-end-of message)
|
|
1122 (vm-headers-of message))) b))))))
|
|
1123 (push-mark end)
|
|
1124 (cond (mail-citation-hook (run-hooks 'mail-citation-hook))
|
|
1125 (mail-yank-hooks (run-hooks 'mail-yank-hooks))
|
|
1126 (t (vm-mail-yank-default message)))
|
|
1127 ))
|
|
1128 (if tm-vm/yank:message-to-restore
|
|
1129 (save-selected-window
|
|
1130 (vm-goto-message tm-vm/yank:message-to-restore)
|
|
1131 (setq tm-vm/yank:message-to-restore nil)))
|
|
1132 ))
|
|
1133
|
|
1134 ;;; @@ for tm-partial
|
4
|
1135 ;;;
|
|
1136
|
|
1137 (call-after-loaded
|
|
1138 'tm-partial
|
|
1139 (function
|
|
1140 (lambda ()
|
|
1141 (set-atype 'mime/content-decoding-condition
|
|
1142 '((type . "message/partial")
|
|
1143 (method . mime-article/grab-message/partials)
|
|
1144 (major-mode . vm-mode)
|
|
1145 (summary-buffer-exp . vm-summary-buffer)
|
|
1146 ))
|
|
1147 (set-alist 'tm-partial/preview-article-method-alist
|
|
1148 'vm-mode
|
|
1149 (function
|
|
1150 (lambda ()
|
|
1151 (tm-vm/view-message)
|
|
1152 )))
|
|
1153 )))
|
|
1154
|
|
1155
|
98
|
1156 ;;; @@ for tm-edit
|
4
|
1157 ;;;
|
|
1158
|
98
|
1159 (call-after-loaded
|
|
1160 'mime-setup
|
|
1161 (function
|
|
1162 (lambda ()
|
|
1163 (setq vm-forwarding-digest-type "rfc1521")
|
|
1164 (setq vm-digest-send-type "rfc1521")
|
|
1165 )))
|
4
|
1166
|
98
|
1167 ;;; @@@ multipart/digest
|
4
|
1168
|
|
1169 (defun tm-vm/enclose-messages (mlist &optional preamble)
|
|
1170 "Enclose the messages in MLIST as multipart/digest.
|
|
1171 The resulting digest is inserted at point in the current buffer.
|
|
1172
|
|
1173 MLIST should be a list of message structs (real or virtual).
|
|
1174 These are the messages that will be enclosed."
|
|
1175 (if mlist
|
|
1176 (let ((digest (consp (cdr mlist)))
|
|
1177 (mp mlist)
|
|
1178 m)
|
|
1179 (save-restriction
|
|
1180 (narrow-to-region (point) (point))
|
|
1181 (while mlist
|
|
1182 (setq m (vm-real-message-of (car mlist)))
|
|
1183 (mime-editor/insert-tag "message" "rfc822")
|
|
1184 (tm-mail/insert-message m)
|
|
1185 (goto-char (point-max))
|
|
1186 (setq mlist (cdr mlist)))
|
|
1187 (if preamble
|
|
1188 (progn
|
|
1189 (goto-char (point-min))
|
|
1190 (mime-editor/insert-tag "text" "plain")
|
|
1191 (vm-unsaved-message "Building digest preamble...")
|
|
1192 (while mp
|
|
1193 (let ((vm-summary-uninteresting-senders nil))
|
|
1194 (insert
|
|
1195 (vm-sprintf 'vm-digest-preamble-format (car mp)) "\n"))
|
|
1196 (if vm-digest-center-preamble
|
|
1197 (progn
|
|
1198 (forward-char -1)
|
|
1199 (center-line)
|
|
1200 (forward-char 1)))
|
|
1201 (setq mp (cdr mp)))))
|
|
1202 (if digest
|
|
1203 (mime-editor/enclose-digest-region (point-min) (point-max)))
|
|
1204 ))))
|
|
1205
|
98
|
1206 (defadvice vm-forward-message (around tm-aware activate)
|
|
1207 "Extended to support rfc1521 multipart digests and to work properly in MIME-Preview buffers."
|
4
|
1208 (if (not (equal vm-forwarding-digest-type "rfc1521"))
|
98
|
1209 ad-do-it
|
74
|
1210 (if mime::preview/article-buffer
|
|
1211 (set-buffer mime::preview/article-buffer))
|
4
|
1212 (vm-follow-summary-cursor)
|
|
1213 (vm-select-folder-buffer)
|
|
1214 (vm-check-for-killed-summary)
|
|
1215 (vm-error-if-folder-empty)
|
|
1216 (if (eq last-command 'vm-next-command-uses-marks)
|
|
1217 (let ((vm-digest-send-type vm-forwarding-digest-type))
|
|
1218 (setq this-command 'vm-next-command-uses-marks)
|
|
1219 (command-execute 'tm-vm/send-digest))
|
|
1220 (let ((dir default-directory)
|
|
1221 (mp vm-message-pointer))
|
|
1222 (save-restriction
|
|
1223 (widen)
|
|
1224 (vm-mail-internal
|
|
1225 (format "forward of %s's note re: %s"
|
|
1226 (vm-su-full-name (car vm-message-pointer))
|
|
1227 (vm-su-subject (car vm-message-pointer)))
|
|
1228 nil
|
|
1229 (and vm-forwarding-subject-format
|
|
1230 (let ((vm-summary-uninteresting-senders nil))
|
|
1231 (vm-sprintf 'vm-forwarding-subject-format (car mp)))))
|
|
1232 (make-local-variable 'vm-forward-list)
|
|
1233 (setq vm-system-state 'forwarding
|
|
1234 vm-forward-list (list (car mp))
|
|
1235 default-directory dir)
|
|
1236 (goto-char (point-min))
|
|
1237 (re-search-forward
|
|
1238 (concat "^" (regexp-quote mail-header-separator) "\n") nil 0)
|
|
1239 (tm-vm/enclose-messages vm-forward-list)
|
|
1240 (mail-position-on-field "To"))
|
|
1241 (run-hooks 'tm-vm/forward-message-hook)
|
|
1242 (run-hooks 'vm-mail-mode-hook)))))
|
|
1243
|
|
1244 (defun tm-vm/send-digest (&optional arg)
|
|
1245 "Send a digest of all messages in the current folder to recipients.
|
|
1246 The type of the digest is specified by the variable vm-digest-send-type.
|
|
1247 You will be placed in a Mail mode buffer as is usual with replies, but you
|
|
1248 must fill in the To: and Subject: headers manually.
|
|
1249
|
|
1250 If invoked on marked messages (via vm-next-command-uses-marks),
|
|
1251 only marked messages will be put into the digest."
|
|
1252 (interactive "P")
|
|
1253 (if (not (equal vm-digest-send-type "rfc1521"))
|
|
1254 (vm-send-digest arg)
|
|
1255 (vm-select-folder-buffer)
|
|
1256 (vm-check-for-killed-summary)
|
|
1257 (vm-error-if-folder-empty)
|
|
1258 (let ((dir default-directory)
|
|
1259 (vm-forward-list (if (eq last-command 'vm-next-command-uses-marks)
|
|
1260 (vm-select-marked-or-prefixed-messages 0)
|
98
|
1261 vm-message-list)))
|
4
|
1262 (save-restriction
|
|
1263 (widen)
|
|
1264 (vm-mail-internal (format "digest from %s" (buffer-name)))
|
|
1265 (setq vm-system-state 'forwarding
|
|
1266 default-directory dir)
|
|
1267 (goto-char (point-min))
|
|
1268 (re-search-forward (concat "^" (regexp-quote mail-header-separator)
|
|
1269 "\n"))
|
|
1270 (goto-char (match-end 0))
|
|
1271 (vm-unsaved-message "Building %s digest..." vm-digest-send-type)
|
|
1272 (tm-vm/enclose-messages vm-forward-list arg)
|
|
1273 (mail-position-on-field "To")
|
|
1274 (message "Building %s digest... done" vm-digest-send-type)))
|
|
1275 (run-hooks 'tm-vm/send-digest-hook)
|
|
1276 (run-hooks 'vm-mail-mode-hook)))
|
|
1277
|
|
1278 (substitute-key-definition 'vm-send-digest
|
|
1279 'tm-vm/send-digest vm-mode-map)
|
|
1280
|
98
|
1281 ;;; @@@ Menus
|
|
1282
|
4
|
1283
|
|
1284 (call-after-loaded
|
|
1285 'tm-edit
|
|
1286 (function
|
|
1287 (lambda ()
|
|
1288 (autoload 'tm-mail/insert-message "tm-mail")
|
|
1289 (set-alist 'mime-editor/message-inserter-alist
|
|
1290 'mail-mode (function tm-mail/insert-message))
|
|
1291 (set-alist 'mime-editor/split-message-sender-alist
|
|
1292 'mail-mode (function
|
|
1293 (lambda ()
|
|
1294 (interactive)
|
74
|
1295 (funcall send-mail-function)
|
4
|
1296 )))
|
|
1297 )))
|
|
1298
|
98
|
1299
|
|
1300
|
|
1301 ;;; @ VM Integration
|
|
1302
|
|
1303 (add-hook 'vm-quit-hook 'tm-vm/quit-view-message)
|
|
1304
|
|
1305 ;;; @@ Wrappers for miscellaneous VM functions
|
|
1306
|
|
1307 (defadvice vm-summarize (around tm-aware activate)
|
|
1308 "Made TM aware. Callable from the MIME Preview buffer."
|
|
1309 (if mime::preview/article-buffer
|
|
1310 (set-buffer mime::preview/article-buffer))
|
|
1311 ad-do-it
|
|
1312 (save-excursion
|
|
1313 (set-buffer vm-summary-buffer)
|
|
1314 (tm-vm/check-for-toolbar))
|
|
1315 (tm-vm/preview-current-message))
|
|
1316
|
|
1317 (defadvice vm-expose-hidden-headers (around tm-aware activate)
|
|
1318 "Made TM aware. Callable from the MIME Preview buffer."
|
|
1319 (if mime::preview/article-buffer
|
|
1320 (set-buffer mime::preview/article-buffer))
|
|
1321 (let ((visible-headers vm-visible-headers))
|
|
1322 (tm-vm/quit-view-message)
|
|
1323 ad-do-it
|
|
1324 (let ((vm-visible-headers visible-headers))
|
|
1325 (if (= (point-min) (vm-start-of (car vm-message-pointer)))
|
|
1326 (setq vm-visible-headers '(".*")))
|
|
1327 (tm-vm/preview-current-message))))
|
|
1328
|
|
1329 (if (vm-mouse-fsfemacs-mouse-p)
|
|
1330 (progn
|
|
1331 (define-key tm-vm/vm-emulation-map [mouse-3] 'ignore)
|
|
1332 (define-key tm-vm/vm-emulation-map [down-mouse-3] 'vm-mouse-button-3)
|
|
1333 (defadvice vm-mouse-button-3 (after tm-aware activate)
|
|
1334 "Made TM aware. Works in MIME-Preview buffers."
|
|
1335 (if (and
|
|
1336 vm-use-menus
|
|
1337 (eq major-mode 'mime/viewer-mode))
|
|
1338 (vm-menu-popup-mode-menu event))))
|
|
1339 )
|
|
1340
|
|
1341 (defadvice vm-save-message (around tm-aware activate)
|
|
1342 "Made TM aware. Callable from the MIME Preview buffer."
|
|
1343 (if mime::preview/article-buffer
|
|
1344 (save-excursion
|
|
1345 (set-buffer mime::preview/article-buffer)
|
|
1346 ad-do-it)
|
|
1347 ad-do-it))
|
|
1348
|
|
1349 (defadvice vm-expunge-folder (around tm-aware activate)
|
|
1350 "Made TM aware. Callable from the MIME Preview buffer."
|
|
1351 (if mime::preview/article-buffer
|
|
1352 (save-excursion
|
|
1353 (set-buffer mime::preview/article-buffer)
|
|
1354 ad-do-it)
|
|
1355 ad-do-it))
|
|
1356
|
|
1357 (defadvice vm-save-folder (around tm-aware activate)
|
|
1358 "Made TM aware. Callable from the MIME Preview buffer."
|
|
1359 (if mime::preview/article-buffer
|
|
1360 (save-excursion
|
|
1361 (set-buffer mime::preview/article-buffer)
|
|
1362 ad-do-it)
|
|
1363 ad-do-it))
|
|
1364
|
|
1365 (defadvice vm-goto-parent-message (around tm-aware activate)
|
|
1366 "Made TM aware. Callable from the MIME Preview buffer."
|
|
1367 (if mime::preview/article-buffer
|
|
1368 (save-excursion
|
|
1369 (set-buffer mime::preview/article-buffer)
|
|
1370 ad-do-it)
|
|
1371 ad-do-it))
|
|
1372
|
|
1373 (defadvice vm-delete-message (around tm-aware activate)
|
|
1374 "Made TM aware. Callable from the MIME Preview buffer."
|
|
1375 (interactive "p")
|
|
1376 (if (interactive-p)
|
|
1377 (vm-follow-summary-cursor))
|
|
1378 (if mime::preview/article-buffer
|
|
1379 (save-excursion
|
|
1380 (set-buffer mime::preview/article-buffer)
|
|
1381 ad-do-it)
|
|
1382 ad-do-it))
|
|
1383
|
|
1384 (defadvice vm-delete-message-backward (around tm-aware activate)
|
|
1385 "Made TM aware. Callable from the MIME Preview buffer."
|
|
1386 (interactive "p")
|
|
1387 (if (interactive-p)
|
|
1388 (vm-follow-summary-cursor))
|
|
1389 (if mime::preview/article-buffer
|
|
1390 (save-excursion
|
|
1391 (set-buffer mime::preview/article-buffer)
|
|
1392 ad-do-it)
|
|
1393 ad-do-it))
|
|
1394
|
|
1395 (defadvice vm-undelete-message (around tm-aware activate)
|
|
1396 "Made TM aware. Callable from the MIME Preview buffer."
|
|
1397 (interactive "p")
|
|
1398 (if (interactive-p)
|
|
1399 (vm-follow-summary-cursor))
|
|
1400 (if mime::preview/article-buffer
|
|
1401 (save-excursion
|
|
1402 (set-buffer mime::preview/article-buffer)
|
|
1403 ad-do-it)
|
|
1404 ad-do-it))
|
|
1405
|
|
1406 (defadvice vm-unread-message (around tm-aware activate)
|
|
1407 "Made TM aware. Callable from the MIME Preview buffer."
|
|
1408 (if mime::preview/article-buffer
|
|
1409 (save-excursion
|
|
1410 (set-buffer mime::preview/article-buffer)
|
|
1411 ad-do-it)
|
|
1412 ad-do-it))
|
|
1413
|
|
1414 (defadvice vm-edit-message (around tm-aware activate)
|
|
1415 "Made TM aware. Callable from the MIME Preview buffer."
|
|
1416 (if mime::preview/article-buffer
|
|
1417 (save-excursion
|
|
1418 (set-buffer mime::preview/article-buffer)
|
|
1419 ad-do-it)
|
|
1420 ad-do-it))
|
20
|
1421
|
|
1422
|
98
|
1423
|
|
1424 ;;; @@ VM Toolbar Integration
|
|
1425
|
|
1426 ;;; based on vm-toolbar-any-messages-p [vm-toolbar.el]
|
|
1427 (defun tm-vm/check-for-toolbar ()
|
|
1428 "Install VM toolbar if necessary."
|
|
1429 (if (and running-xemacs
|
|
1430 vm-toolbar-specifier)
|
|
1431 (progn
|
|
1432 (if (null (specifier-instance vm-toolbar-specifier))
|
|
1433 (vm-toolbar-install-toolbar))
|
|
1434 (vm-toolbar-update-toolbar))))
|
|
1435
|
|
1436 (defun vm-toolbar-any-messages-p ()
|
|
1437 (save-excursion
|
|
1438 (if mime::preview/article-buffer
|
|
1439 (set-buffer mime::preview/article-buffer))
|
|
1440 (vm-check-for-killed-folder)
|
|
1441 (vm-select-folder-buffer)
|
|
1442 vm-message-list))
|
|
1443
|
|
1444
|
|
1445 ;;; @ BBDB Integration
|
4
|
1446 ;;;
|
|
1447
|
|
1448 (call-after-loaded
|
|
1449 'bbdb
|
|
1450 (function
|
|
1451 (lambda ()
|
|
1452 (require 'bbdb-vm)
|
|
1453 (require 'tm-bbdb)
|
|
1454 (defun tm-bbdb/vm-update-record (&optional offer-to-create)
|
98
|
1455 (save-excursion
|
|
1456 (vm-select-folder-buffer)
|
|
1457 (if (and (tm-vm/system-state)
|
|
1458 mime::article/preview-buffer
|
|
1459 (get-buffer mime::article/preview-buffer))
|
|
1460 (let ((tm-bbdb/auto-create-p bbdb/mail-auto-create-p))
|
|
1461 (tm-bbdb/update-record offer-to-create))
|
|
1462 (or (bbdb/vm-update-record offer-to-create)
|
|
1463 (delete-windows-on (get-buffer "*BBDB*")))
|
|
1464 )))
|
4
|
1465 (remove-hook 'vm-select-message-hook 'bbdb/vm-update-record)
|
|
1466 (remove-hook 'vm-show-message-hook 'bbdb/vm-update-record)
|
|
1467 (add-hook 'tm-vm/select-message-hook 'tm-bbdb/vm-update-record)
|
|
1468 )))
|
|
1469
|
98
|
1470 ;;; @ ps-print (Suggested by Anders Stenman <stenman@isy.liu.se>)
|
4
|
1471 ;;;
|
|
1472
|
74
|
1473 (if tm-vm/use-ps-print
|
|
1474 (progn
|
|
1475 (autoload 'ps-print-buffer-with-faces "ps-print" "Postscript Print" t)
|
|
1476 (add-hook 'vm-mode-hook 'tm-vm/ps-print-setup)
|
|
1477 (add-hook 'mime-viewer/define-keymap-hook 'tm-vm/ps-print-setup)
|
|
1478 (fset 'vm-toolbar-print-command 'tm-vm/print-message)))
|
4
|
1479
|
|
1480 (defun tm-vm/ps-print-setup ()
|
|
1481 "Set things up for printing MIME messages with ps-print. Set binding to
|
|
1482 the [Print Screen] key."
|
74
|
1483 (local-set-key (if running-xemacs
|
|
1484 'f22
|
|
1485 [f22])
|
|
1486 'tm-vm/print-message)
|
98
|
1487 (make-local-variable 'ps-header-lines)
|
|
1488 (make-local-variable 'ps-left-header)
|
4
|
1489 (setq ps-header-lines 3)
|
|
1490 (setq ps-left-header
|
|
1491 (list 'ps-article-subject 'ps-article-author 'buffer-name)))
|
|
1492
|
|
1493 (defun tm-vm/print-message ()
|
|
1494 "Print current message with ps-print if it's a MIME message.
|
|
1495 Value of tm-vm/strict-mime is also taken into consideration."
|
|
1496 (interactive)
|
|
1497 (vm-follow-summary-cursor)
|
98
|
1498 (vm-select-folder-buffer)
|
|
1499 (tm-vm/sync-preview-buffer)
|
|
1500 (let ((pbuf (and mime::article/preview-buffer
|
|
1501 (get-buffer mime::article/preview-buffer))))
|
4
|
1502 (if pbuf
|
|
1503 (save-excursion
|
|
1504 (set-buffer pbuf)
|
|
1505 (require 'ps-print)
|
|
1506 (ps-print-buffer-with-faces))
|
|
1507 (vm-print-message))))
|
|
1508
|
74
|
1509
|
4
|
1510 ;;; @ end
|
|
1511
|
|
1512 (provide 'tm-vm)
|
|
1513 (run-hooks 'tm-vm-load-hook)
|
|
1514
|
|
1515 ;;; tm-vm.el ends here.
|