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
|
70
|
12 ;; Version: $Revision: 1.1.1.1 $
|
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
|
|
38 (require 'tm-view)
|
70
|
39 (require 'vm)
|
4
|
40
|
|
41 (defconst tm-vm/RCS-ID
|
70
|
42 "$Id: tm-vm.el,v 1.1.1.1 1996/12/18 22:43:38 steve Exp $")
|
4
|
43 (defconst tm-vm/version (get-version-string tm-vm/RCS-ID))
|
|
44
|
|
45 (define-key vm-mode-map "Z" 'tm-vm/view-message)
|
|
46 (define-key vm-mode-map "T" 'tm-vm/decode-message-header)
|
|
47 (define-key vm-mode-map "\et" 'tm-vm/toggle-preview-mode)
|
|
48
|
70
|
49 (defvar tm-vm/use-original-url-button nil
|
|
50 "*If it is t, use original URL button instead of tm's.")
|
4
|
51
|
70
|
52 (defvar tm-vm-load-hook nil
|
|
53 "*List of functions called after tm-vm is loaded.")
|
|
54
|
|
55
|
|
56 ;;; @ for MIME encoded-words
|
|
57 ;;;
|
4
|
58
|
|
59 (defvar tm-vm/use-tm-patch nil
|
|
60 "Does not decode encoded-words in summary buffer if it is t.
|
|
61 If you use tiny-mime patch for VM (by RIKITAKE Kenji
|
|
62 <kenji@reseau.toyonaka.osaka.jp>), please set it t [tm-vm.el]")
|
|
63
|
|
64 (or tm-vm/use-tm-patch
|
|
65 (progn
|
70
|
66 ;;;
|
|
67 (defvar tm-vm/chop-full-name-function 'tm-vm/default-chop-full-name)
|
|
68 (setq vm-chop-full-name-function tm-vm/chop-full-name-function)
|
|
69
|
|
70 (defun tm-vm/default-chop-full-name (address)
|
|
71 (let* ((ret (vm-default-chop-full-name address))
|
|
72 (full-name (car ret))
|
|
73 )
|
|
74 (if (stringp full-name)
|
|
75 (cons (mime-eword/decode-string full-name)
|
|
76 (cdr ret))
|
|
77 ret)))
|
4
|
78
|
70
|
79 (require 'vm-summary)
|
|
80 (or (fboundp 'tm:vm-su-subject)
|
|
81 (fset 'tm:vm-su-subject (symbol-function 'vm-su-subject))
|
|
82 )
|
|
83 (defun vm-su-subject (m)
|
|
84 (mime-eword/decode-string (tm:vm-su-subject m))
|
|
85 )
|
4
|
86
|
70
|
87 (or (fboundp 'tm:vm-su-full-name)
|
|
88 (fset 'tm:vm-su-full-name (symbol-function 'vm-su-full-name))
|
|
89 )
|
|
90 (defun vm-su-full-name (m)
|
|
91 (mime-eword/decode-string (tm:vm-su-full-name m))
|
|
92 )
|
22
|
93
|
70
|
94 (or (fboundp 'tm:vm-su-to-names)
|
|
95 (fset 'tm:vm-su-to-names (symbol-function 'vm-su-to-names))
|
|
96 )
|
|
97 (defun vm-su-to-names (m)
|
|
98 (mime-eword/decode-string (tm:vm-su-to-names m))
|
|
99 )
|
|
100 ;;;
|
4
|
101 ))
|
|
102
|
|
103 (defun tm-vm/decode-message-header (&optional count)
|
|
104 "Decode MIME header of current message.
|
|
105 Numeric prefix argument COUNT means to decode the current message plus
|
|
106 the next COUNT-1 messages. A negative COUNT means decode the current
|
|
107 message and the previous COUNT-1 messages.
|
|
108 When invoked on marked messages (via vm-next-command-uses-marks),
|
|
109 all marked messages are affected, other messages are ignored."
|
|
110 (interactive "p")
|
|
111 (or count (setq count 1))
|
|
112 (vm-follow-summary-cursor)
|
|
113 (vm-select-folder-buffer)
|
|
114 (vm-check-for-killed-summary)
|
|
115 (vm-error-if-folder-empty)
|
|
116 (vm-error-if-folder-read-only)
|
|
117 (let ((mlist (vm-select-marked-or-prefixed-messages count))
|
|
118 (realm nil)
|
|
119 (vlist nil)
|
|
120 (vbufs nil))
|
|
121 (save-excursion
|
|
122 (while mlist
|
|
123 (setq realm (vm-real-message-of (car mlist)))
|
|
124 ;; Go to real folder of this message.
|
|
125 ;; But maybe this message is already real message...
|
|
126 (set-buffer (vm-buffer-of realm))
|
|
127 (let ((buffer-read-only nil))
|
|
128 (vm-save-restriction
|
|
129 (narrow-to-region (vm-headers-of realm) (vm-text-of realm))
|
|
130 (mime/decode-message-header))
|
|
131 (let ((vm-message-pointer (list realm))
|
|
132 (last-command nil))
|
|
133 (vm-discard-cached-data))
|
|
134 ;; Mark each virtual and real message for later summary
|
|
135 ;; update.
|
|
136 (setq vlist (cons realm (vm-virtual-messages-of realm)))
|
|
137 (while vlist
|
|
138 (vm-mark-for-summary-update (car vlist))
|
|
139 ;; Remember virtual and real folders related this message,
|
|
140 ;; for later display update.
|
|
141 (or (memq (vm-buffer-of (car vlist)) vbufs)
|
|
142 (setq vbufs (cons (vm-buffer-of (car vlist)) vbufs)))
|
|
143 (setq vlist (cdr vlist)))
|
|
144 (if (eq vm-flush-interval t)
|
|
145 (vm-stuff-virtual-attributes realm)
|
|
146 (vm-set-modflag-of realm t)))
|
|
147 (setq mlist (cdr mlist)))
|
|
148 ;; Update mail-buffers and summaries.
|
|
149 (while vbufs
|
|
150 (set-buffer (car vbufs))
|
|
151 (vm-preview-current-message)
|
|
152 (setq vbufs (cdr vbufs))))))
|
|
153
|
70
|
154
|
|
155 ;;; @ automatic MIME preview
|
|
156 ;;;
|
|
157
|
|
158 (defvar tm-vm/automatic-mime-preview t
|
|
159 "*If non-nil, automatically process and show MIME messages.")
|
|
160
|
|
161 (defvar tm-vm/strict-mime t
|
|
162 "*If nil, do MIME processing even if there is no MIME-Version field.")
|
|
163
|
|
164 (defvar tm-vm/select-message-hook nil
|
|
165 "*List of functions called every time a message is selected.
|
|
166 tm-vm uses `vm-select-message-hook', use this hook instead.")
|
|
167
|
|
168 (defvar tm-vm/system-state nil)
|
|
169
|
|
170 (setq mime-viewer/content-header-filter-alist
|
|
171 (append '((vm-mode . tm-vm/header-filter)
|
|
172 (vm-virtual-mode . tm-vm/header-filter))
|
|
173 mime-viewer/content-header-filter-alist))
|
|
174
|
4
|
175 (defun tm-vm/header-filter ()
|
70
|
176 "Filter headers in current buffer (assumed to be a message-like buffer)
|
|
177 according to vm-visible-headers and vm-invisible-header-regexp"
|
|
178 (beginning-of-buffer)
|
4
|
179 (let ((visible-headers vm-visible-headers))
|
|
180 (if (or vm-use-lucid-highlighting
|
|
181 vm-display-xfaces)
|
|
182 (setq visible-headers (cons "X-Face:" vm-visible-headers)))
|
|
183 (vm-reorder-message-headers nil
|
|
184 visible-headers
|
|
185 vm-invisible-header-regexp)
|
|
186 (mime/decode-message-header)))
|
|
187
|
|
188 (defun tm-vm/system-state ()
|
|
189 (save-excursion
|
|
190 (if mime::preview/article-buffer
|
|
191 (set-buffer mime::preview/article-buffer)
|
|
192 (vm-select-folder-buffer))
|
|
193 tm-vm/system-state))
|
|
194
|
|
195 (defun tm-vm/sync-preview-buffer ()
|
70
|
196 "Ensure that the MIME preview buffer, if it exists actually corresponds to
|
|
197 the current message. If no MIME Preview buffer is needed, delete it. If no
|
4
|
198 MIME Preview buffer exists nothing is done."
|
|
199 ;; Current buffer should be message buffer when calling this function
|
|
200 (let* ((mbuf (current-buffer))
|
|
201 (pbuf (and mime::article/preview-buffer
|
70
|
202 (get-buffer mime::article/preview-buffer)))
|
|
203 (win (or (and pbuf (vm-get-buffer-window pbuf))
|
|
204 (vm-get-buffer-window mbuf)))
|
|
205 (frame (selected-frame)))
|
4
|
206 (if pbuf
|
70
|
207 ;; Go to the frame where pbuf or mbuf is (frame-per-composition t)
|
|
208 (save-excursion
|
|
209 (if win
|
|
210 (vm-select-frame (vm-window-frame win)))
|
|
211 ;; Rebuild MIME Preview buffer to ensure it corresponds to
|
|
212 ;; current message
|
|
213 (save-window-excursion
|
|
214 (save-selected-window
|
|
215 (save-excursion
|
|
216 (set-buffer mbuf)
|
|
217 (setq mime::article/preview-buffer nil)
|
|
218 (if pbuf (kill-buffer pbuf)))
|
|
219 (tm-vm/view-message)))
|
4
|
220 ;; Return to previous frame
|
70
|
221 (vm-select-frame frame)))))
|
4
|
222
|
|
223 (defun tm-vm/display-preview-buffer ()
|
|
224 (let* ((mbuf (current-buffer))
|
|
225 (mwin (vm-get-visible-buffer-window mbuf))
|
|
226 (pbuf (and mime::article/preview-buffer
|
|
227 (get-buffer mime::article/preview-buffer)))
|
|
228 (pwin (and pbuf (vm-get-visible-buffer-window pbuf))))
|
|
229 (if (and pbuf (tm-vm/system-state))
|
70
|
230 ;; display preview buffer
|
4
|
231 (cond
|
|
232 ((and mwin pwin)
|
|
233 (vm-undisplay-buffer mbuf)
|
70
|
234 (tm-vm/show-current-message))
|
4
|
235 ((and mwin (not pwin))
|
|
236 (set-window-buffer mwin pbuf)
|
70
|
237 (tm-vm/show-current-message))
|
4
|
238 (pwin
|
70
|
239 (tm-vm/show-current-message))
|
4
|
240 (t
|
|
241 ;; don't display if neither mwin nor pwin was displayed before.
|
|
242 ))
|
|
243 ;; display folder buffer
|
|
244 (cond
|
|
245 ((and mwin pwin)
|
|
246 (vm-undisplay-buffer pbuf))
|
|
247 ((and (not mwin) pwin)
|
|
248 (set-window-buffer pwin mbuf))
|
|
249 (mwin
|
|
250 ;; folder buffer is already displayed.
|
|
251 )
|
|
252 (t
|
|
253 ;; don't display if neither mwin nor pwin was displayed before.
|
70
|
254 )))
|
|
255 (set-buffer mbuf)))
|
4
|
256
|
|
257 (defun tm-vm/preview-current-message ()
|
70
|
258 "Preview current message if it has a MIME contents and
|
|
259 tm-vm/automatic-mime-preview is non nil. Installed on
|
|
260 vm-visit-folder-hook and vm-select-message-hook."
|
4
|
261 ;; assumed current buffer is folder buffer.
|
|
262 (setq tm-vm/system-state nil)
|
|
263 (if (get-buffer mime/output-buffer-name)
|
|
264 (vm-undisplay-buffer mime/output-buffer-name))
|
70
|
265 (if (and vm-message-pointer tm-vm/automatic-mime-preview)
|
4
|
266 (if (or (not tm-vm/strict-mime)
|
|
267 (vm-get-header-contents (car vm-message-pointer)
|
|
268 "MIME-Version:"))
|
|
269 ;; do MIME processing.
|
70
|
270 (progn
|
|
271 ;; Consider message as shown => update its flags and store them
|
|
272 ;; in folder buffer before entering MIME viewer
|
|
273 (tm-vm/show-current-message)
|
|
274 (set (make-local-variable 'tm-vm/system-state) 'previewing)
|
|
275 (save-window-excursion
|
|
276 (vm-widen-page)
|
|
277 (goto-char (point-max))
|
|
278 (widen)
|
|
279 (narrow-to-region (point)
|
|
280 (save-excursion
|
|
281 (goto-char
|
|
282 (vm-start-of (car vm-message-pointer))
|
|
283 )
|
|
284 (forward-line)
|
|
285 (point)
|
|
286 ))
|
|
287
|
|
288 (mime/viewer-mode nil nil nil nil nil vm-mode-map)
|
|
289 ;; Highlight message (and display XFace if supported)
|
|
290 (if (or vm-highlighted-header-regexp
|
|
291 (and (vm-xemacs-p) vm-use-lucid-highlighting))
|
|
292 (vm-highlight-headers))
|
|
293 ;; Energize URLs and buttons
|
|
294 (if (and tm-vm/use-original-url-button
|
|
295 vm-use-menus (vm-menu-support-possible-p))
|
|
296 (progn
|
|
297 (vm-energize-urls)
|
|
298 (vm-energize-headers)))
|
|
299 (goto-char (point-min))
|
|
300 (narrow-to-region (point) (search-forward "\n\n" nil t))
|
|
301 ))
|
4
|
302 ;; don't do MIME processing. decode header only.
|
|
303 (let (buffer-read-only)
|
70
|
304 (mime/decode-message-header))
|
4
|
305 )
|
|
306 ;; don't preview; do nothing.
|
70
|
307 )
|
|
308 (tm-vm/display-preview-buffer)
|
|
309 (run-hooks 'tm-vm/select-message-hook))
|
4
|
310
|
70
|
311 (defun tm-vm/show-current-message ()
|
|
312 "Update current message display and summary. Remove 'unread' and 'new' flags. "
|
|
313 (if mime::preview/article-buffer
|
|
314 (set-buffer mime::preview/article-buffer)
|
|
315 (vm-select-folder-buffer))
|
|
316 (if mime::article/preview-buffer
|
|
317 (save-excursion
|
|
318 (set-buffer mime::article/preview-buffer)
|
|
319 (goto-char (point-min))
|
|
320 (widen)))
|
|
321 (if (or (and mime::article/preview-buffer
|
|
322 (vm-get-visible-buffer-window mime::article/preview-buffer))
|
|
323 (vm-get-visible-buffer-window (current-buffer)))
|
|
324 (progn
|
|
325 (setq tm-vm/system-state 'reading)
|
|
326 (if (vm-new-flag (car vm-message-pointer))
|
|
327 (vm-set-new-flag (car vm-message-pointer) nil))
|
|
328 (if (vm-unread-flag (car vm-message-pointer))
|
|
329 (vm-set-unread-flag (car vm-message-pointer) nil))
|
|
330 (vm-update-summary-and-mode-line)
|
|
331 (tm-vm/howl-if-eom))
|
|
332 (vm-update-summary-and-mode-line)))
|
|
333
|
|
334 (defun tm-vm/toggle-preview-mode ()
|
|
335 "Toggle automatic MIME preview on or off. In automatic MIME Preview mode
|
|
336 each newly selected article is MIME processed if it has MIME content without
|
|
337 need for an explicit request from the user. This behaviour is controlled by the
|
|
338 variable tm-vm/automatic-mime-preview."
|
|
339 (interactive)
|
|
340 (if tm-vm/automatic-mime-preview
|
|
341 (progn
|
|
342 (tm-vm/quit-view-message)
|
|
343 (setq tm-vm/automatic-mime-preview nil)
|
|
344 (message "Automatic MIME Preview is now disabled."))
|
|
345 ;; Enable Automatic MIME Preview
|
|
346 (tm-vm/view-message)
|
|
347 (setq tm-vm/automatic-mime-preview t)
|
|
348 (message "Automatic MIME Preview is now enabled.")
|
|
349 ))
|
4
|
350
|
|
351 (add-hook 'vm-select-message-hook 'tm-vm/preview-current-message)
|
|
352 (add-hook 'vm-visit-folder-hook 'tm-vm/preview-current-message)
|
70
|
353
|
|
354 ;;; tm-vm move commands
|
|
355 ;;;
|
4
|
356
|
70
|
357 (defmacro tm-vm/save-window-excursion (&rest forms)
|
|
358 (list 'let '((tm-vm/selected-window (selected-window)))
|
|
359 (list 'unwind-protect
|
|
360 (cons 'progn forms)
|
|
361 '(if (window-live-p tm-vm/selected-window)
|
|
362 (select-window tm-vm/selected-window)))))
|
4
|
363
|
70
|
364 ;;; based on vm-scroll-forward [vm-page.el]
|
|
365 (defun tm-vm/scroll-forward (&optional arg)
|
|
366 (interactive "P")
|
|
367 (let ((this-command 'vm-scroll-forward))
|
|
368 (if (not (tm-vm/system-state))
|
|
369 (progn
|
|
370 (vm-scroll-forward arg)
|
|
371 (tm-vm/display-preview-buffer))
|
|
372 (let* ((mp-changed (vm-follow-summary-cursor))
|
|
373 (mbuf (or (vm-select-folder-buffer) (current-buffer)))
|
|
374 (mwin (vm-get-buffer-window mbuf))
|
|
375 (pbuf (and mime::article/preview-buffer
|
|
376 (get-buffer mime::article/preview-buffer)))
|
|
377 (pwin (and pbuf (vm-get-buffer-window pbuf)))
|
|
378 (was-invisible (and (null mwin) (null pwin)))
|
|
379 )
|
|
380 ;; now current buffer is folder buffer.
|
|
381 (tm-vm/save-window-excursion
|
|
382 (if (or mp-changed was-invisible)
|
|
383 (vm-display mbuf t '(vm-scroll-forward vm-scroll-backward)
|
|
384 (list this-command 'reading-message)))
|
|
385 (tm-vm/display-preview-buffer)
|
|
386 (setq mwin (vm-get-buffer-window mbuf)
|
|
387 pwin (and pbuf (vm-get-buffer-window pbuf)))
|
|
388 (cond
|
|
389 ((or mp-changed was-invisible)
|
|
390 nil
|
|
391 )
|
|
392 ((null pbuf)
|
|
393 ;; preview buffer is killed.
|
|
394 (tm-vm/preview-current-message)
|
|
395 (vm-update-summary-and-mode-line))
|
|
396 ((eq (tm-vm/system-state) 'previewing)
|
|
397 (tm-vm/show-current-message))
|
|
398 (t
|
|
399 (select-window pwin)
|
|
400 (set-buffer pbuf)
|
|
401 (if (pos-visible-in-window-p (point-max) pwin)
|
|
402 (tm-vm/next-message)
|
|
403 ;; not end of message. scroll preview buffer only.
|
|
404 (scroll-up)
|
|
405 (tm-vm/howl-if-eom)
|
|
406 (set-buffer mbuf))
|
|
407 ))))
|
|
408 )))
|
|
409
|
|
410 ;;; based on vm-scroll-backward [vm-page.el]
|
|
411 (defun tm-vm/scroll-backward (&optional arg)
|
|
412 (interactive "P")
|
|
413 (let ((this-command 'vm-scroll-backward))
|
|
414 (if (not (tm-vm/system-state))
|
|
415 (vm-scroll-backward arg)
|
|
416 (let* ((mp-changed (vm-follow-summary-cursor))
|
|
417 (mbuf (or (vm-select-folder-buffer) (current-buffer)))
|
|
418 (mwin (vm-get-buffer-window mbuf))
|
|
419 (pbuf (and mime::article/preview-buffer
|
|
420 (get-buffer mime::article/preview-buffer)))
|
|
421 (pwin (and pbuf (vm-get-buffer-window pbuf)))
|
|
422 (was-invisible (and (null mwin) (null pwin)))
|
|
423 )
|
|
424 ;; now current buffer is folder buffer.
|
|
425 (if (or mp-changed was-invisible)
|
|
426 (vm-display mbuf t '(vm-scroll-forward vm-scroll-backward)
|
|
427 (list this-command 'reading-message)))
|
|
428 (tm-vm/save-window-excursion
|
|
429 (tm-vm/display-preview-buffer)
|
|
430 (setq mwin (vm-get-buffer-window mbuf)
|
|
431 pwin (and pbuf (vm-get-buffer-window pbuf)))
|
|
432 (cond
|
|
433 (was-invisible
|
|
434 nil
|
|
435 )
|
|
436 ((null pbuf)
|
|
437 ;; preview buffer is killed.
|
|
438 (tm-vm/preview-current-message)
|
|
439 (vm-update-summary-and-mode-line))
|
|
440 ((eq (tm-vm/system-state) 'previewing)
|
|
441 (tm-vm/show-current-message))
|
|
442 (t
|
|
443 (select-window pwin)
|
|
444 (set-buffer pbuf)
|
|
445 (if (pos-visible-in-window-p (point-min) pwin)
|
|
446 nil
|
|
447 ;; scroll preview buffer only.
|
|
448 (scroll-down)
|
|
449 (set-buffer mbuf))
|
|
450 ))))
|
|
451 )))
|
|
452
|
|
453 ;;; based on vm-beginning-of-message [vm-page.el]
|
|
454 (defun tm-vm/beginning-of-message ()
|
|
455 "Moves to the beginning of the current message."
|
|
456 (interactive)
|
|
457 (if (not (tm-vm/system-state))
|
|
458 (progn
|
|
459 (setq this-command 'vm-beginning-of-message)
|
|
460 (vm-beginning-of-message))
|
|
461 (vm-follow-summary-cursor)
|
|
462 (vm-select-folder-buffer)
|
|
463 (vm-check-for-killed-summary)
|
|
464 (vm-error-if-folder-empty)
|
|
465 (let ((mbuf (current-buffer))
|
|
466 (pbuf (and mime::article/preview-buffer
|
|
467 (get-buffer mime::article/preview-buffer))))
|
|
468 (if (null pbuf)
|
|
469 (progn
|
|
470 (tm-vm/preview-current-message)
|
|
471 (setq pbuf (get-buffer mime::article/preview-buffer))
|
|
472 ))
|
|
473 (vm-display mbuf t '(vm-beginning-of-message)
|
|
474 '(vm-beginning-of-message reading-message))
|
|
475 (tm-vm/display-preview-buffer)
|
|
476 (set-buffer pbuf)
|
|
477 (tm-vm/save-window-excursion
|
|
478 (select-window (vm-get-buffer-window pbuf))
|
|
479 (push-mark)
|
|
480 (goto-char (point-min))
|
|
481 ))))
|
|
482
|
|
483 ;;; based on vm-end-of-message [vm-page.el]
|
|
484 (defun tm-vm/end-of-message ()
|
|
485 "Moves to the end of the current message."
|
|
486 (interactive)
|
|
487 (if (not (tm-vm/system-state))
|
|
488 (progn
|
|
489 (setq this-command 'vm-end-of-message)
|
|
490 (vm-end-of-message))
|
|
491 (vm-follow-summary-cursor)
|
|
492 (vm-select-folder-buffer)
|
|
493 (vm-check-for-killed-summary)
|
|
494 (vm-error-if-folder-empty)
|
|
495 (let ((mbuf (current-buffer))
|
|
496 (pbuf (and mime::article/preview-buffer
|
|
497 (get-buffer mime::article/preview-buffer))))
|
|
498 (if (null pbuf)
|
|
499 (progn
|
|
500 (tm-vm/preview-current-message)
|
|
501 (setq pbuf (get-buffer mime::article/preview-buffer))
|
|
502 ))
|
|
503 (vm-display mbuf t '(vm-end-of-message)
|
|
504 '(vm-end-of-message reading-message))
|
|
505 (tm-vm/display-preview-buffer)
|
|
506 (set-buffer pbuf)
|
|
507 (tm-vm/save-window-excursion
|
|
508 (select-window (vm-get-buffer-window pbuf))
|
|
509 (push-mark)
|
|
510 (goto-char (point-max))
|
|
511 ))))
|
|
512
|
|
513 ;;; based on vm-howl-if-eom [vm-page.el]
|
|
514 (defun tm-vm/howl-if-eom ()
|
|
515 (let* ((pbuf (or mime::article/preview-buffer (current-buffer)))
|
|
516 (pwin (and (vm-get-visible-buffer-window pbuf))))
|
|
517 (and pwin
|
|
518 (save-excursion
|
|
519 (save-window-excursion
|
|
520 (condition-case ()
|
|
521 (let ((next-screen-context-lines 0))
|
|
522 (select-window pwin)
|
|
523 (save-excursion
|
|
524 (save-window-excursion
|
|
525 (let ((scroll-in-place-replace-original nil))
|
|
526 (scroll-up))))
|
|
527 nil)
|
|
528 (error t))))
|
|
529 (tm-vm/emit-eom-blurb)
|
|
530 )))
|
|
531
|
|
532 ;;; based on vm-emit-eom-blurb [vm-page.el]
|
|
533 (defun tm-vm/emit-eom-blurb ()
|
|
534 (save-excursion
|
|
535 (if mime::preview/article-buffer
|
|
536 (set-buffer mime::preview/article-buffer))
|
|
537 (vm-emit-eom-blurb)))
|
|
538
|
|
539 ;;; based on vm-quit [vm-folder.el]
|
|
540 (defun tm-vm/quit ()
|
|
541 "Quit VM saving the folder buffer and killing the MIME Preview buffer if any"
|
|
542 (interactive)
|
|
543 (save-excursion
|
|
544 (vm-select-folder-buffer)
|
|
545 (if (and mime::article/preview-buffer
|
|
546 (get-buffer mime::article/preview-buffer))
|
|
547 (kill-buffer mime::article/preview-buffer)))
|
|
548 (vm-quit))
|
|
549
|
|
550 (defun tm-vm/quit-no-change ()
|
|
551 "Quit VM without saving the folder buffer but killing the MIME Preview buffer
|
|
552 if any"
|
|
553 (interactive)
|
|
554 (save-excursion
|
|
555 (vm-select-folder-buffer)
|
|
556 (if (and mime::article/preview-buffer
|
|
557 (get-buffer mime::article/preview-buffer))
|
|
558 (kill-buffer mime::article/preview-buffer)))
|
|
559 (vm-quit-no-change))
|
|
560
|
|
561 (substitute-key-definition 'vm-scroll-forward
|
|
562 'tm-vm/scroll-forward vm-mode-map)
|
|
563 (substitute-key-definition 'vm-scroll-backward
|
|
564 'tm-vm/scroll-backward vm-mode-map)
|
|
565 (substitute-key-definition 'vm-beginning-of-message
|
|
566 'tm-vm/beginning-of-message vm-mode-map)
|
|
567 (substitute-key-definition 'vm-end-of-message
|
|
568 'tm-vm/end-of-message vm-mode-map)
|
|
569 (substitute-key-definition 'vm-quit
|
|
570 'tm-vm/quit vm-mode-map)
|
|
571 (substitute-key-definition 'vm-quit-no-change
|
|
572 'tm-vm/quit-no-change vm-mode-map)
|
|
573
|
|
574 ;;; based on vm-next-message [vm-motion.el]
|
|
575 (defun tm-vm/next-message ()
|
|
576 (set-buffer mime::preview/article-buffer)
|
|
577 (let ((this-command 'vm-next-message)
|
|
578 (owin (selected-window))
|
|
579 (vm-preview-lines nil)
|
|
580 )
|
|
581 (vm-next-message 1 nil t)
|
|
582 (if (window-live-p owin)
|
|
583 (select-window owin))))
|
|
584
|
|
585 ;;; based on vm-previous-message [vm-motion.el]
|
|
586 (defun tm-vm/previous-message ()
|
|
587 (set-buffer mime::preview/article-buffer)
|
|
588 (let ((this-command 'vm-previous-message)
|
|
589 (owin (selected-window))
|
|
590 (vm-preview-lines nil)
|
|
591 )
|
|
592 (vm-previous-message 1 nil t)
|
|
593 (if (window-live-p owin)
|
|
594 (select-window owin))))
|
|
595
|
|
596 (set-alist 'mime-viewer/over-to-previous-method-alist
|
|
597 'vm-mode 'tm-vm/previous-message)
|
|
598 (set-alist 'mime-viewer/over-to-next-method-alist
|
|
599 'vm-mode 'tm-vm/next-message)
|
|
600 (set-alist 'mime-viewer/over-to-previous-method-alist
|
|
601 'vm-virtual-mode 'tm-vm/previous-message)
|
|
602 (set-alist 'mime-viewer/over-to-next-method-alist
|
|
603 'vm-virtual-mode 'tm-vm/next-message)
|
|
604
|
|
605 ;;; @@ vm-yank-message
|
|
606 ;;;
|
|
607 ;; 1996/3/28 by Oscar Figueiredo <figueire@lspsun16.epfl.ch>
|
|
608
|
|
609 (require 'vm-reply)
|
|
610
|
|
611 (defvar tm-vm/yank:message-to-restore nil
|
|
612 "For internal use by tm-vm only.")
|
|
613
|
|
614 (defun vm-yank-message (&optional message)
|
|
615 "Yank message number N into the current buffer at point.
|
|
616 When called interactively N is always read from the minibuffer. When
|
|
617 called non-interactively the first argument is expected to be a
|
|
618 message struct.
|
|
619
|
|
620 This function originally provided by vm-reply has been patched for TM
|
|
621 in order to provide better citation of MIME messages : if a MIME
|
|
622 Preview buffer exists for the message then its contents are inserted
|
|
623 instead of the raw message.
|
|
624
|
|
625 This command is meant to be used in VM created Mail mode buffers; the
|
|
626 yanked message comes from the mail buffer containing the message you
|
|
627 are replying to, forwarding, or invoked VM's mail command from.
|
|
628
|
|
629 All message headers are yanked along with the text. Point is
|
|
630 left before the inserted text, the mark after. Any hook
|
|
631 functions bound to mail-citation-hook are run, after inserting
|
|
632 the text and setting point and mark. For backward compatibility,
|
|
633 if mail-citation-hook is set to nil, `mail-yank-hooks' is run
|
|
634 instead.
|
|
635
|
|
636 If mail-citation-hook and mail-yank-hooks are both nil, this
|
|
637 default action is taken: the yanked headers are trimmed as
|
|
638 specified by vm-included-text-headers and
|
|
639 vm-included-text-discard-header-regexp, and the value of
|
|
640 vm-included-text-prefix is prepended to every yanked line."
|
|
641 (interactive
|
|
642 (list
|
|
643 ;; What we really want for the first argument is a message struct,
|
|
644 ;; but if called interactively, we let the user type in a message
|
|
645 ;; number instead.
|
|
646 (let (mp default
|
|
647 (result 0)
|
|
648 prompt
|
|
649 (last-command last-command)
|
|
650 (this-command this-command))
|
|
651 (if (bufferp vm-mail-buffer)
|
|
652 (save-excursion
|
|
653 (vm-select-folder-buffer)
|
|
654 (setq default (and vm-message-pointer
|
|
655 (vm-number-of (car vm-message-pointer)))
|
|
656 prompt (if default
|
|
657 (format "Yank message number: (default %s) "
|
|
658 default)
|
|
659 "Yank message number: "))
|
|
660 (while (zerop result)
|
|
661 (setq result (read-string prompt))
|
|
662 (and (string= result "") default (setq result default))
|
|
663 (setq result (string-to-int result)))
|
|
664 (if (null (setq mp (nthcdr (1- result) vm-message-list)))
|
|
665 (error "No such message."))
|
|
666 (setq tm-vm/yank:message-to-restore (string-to-int default))
|
|
667 (save-selected-window
|
|
668 (vm-goto-message result))
|
|
669 (car mp))
|
|
670 nil))))
|
|
671 (if (null message)
|
|
672 (if mail-reply-buffer
|
|
673 (tm-vm/yank-content)
|
|
674 (error "This is not a VM Mail mode buffer."))
|
|
675 (if (null (buffer-name vm-mail-buffer))
|
|
676 (error "The folder buffer containing message %d has been killed."
|
|
677 (vm-number-of message)))
|
|
678 (vm-display nil nil '(vm-yank-message)
|
|
679 '(vm-yank-message composing-message))
|
|
680 (let ((b (current-buffer)) (start (point)) end)
|
|
681 (save-restriction
|
|
682 (widen)
|
|
683 (save-excursion
|
|
684 (set-buffer (vm-buffer-of message))
|
|
685 (let* ((mbuf (current-buffer))
|
|
686 pbuf)
|
|
687 (tm-vm/sync-preview-buffer)
|
|
688 (setq pbuf (and mime::article/preview-buffer
|
|
689 (get-buffer mime::article/preview-buffer)))
|
|
690 (if pbuf
|
|
691 (if running-xemacs
|
|
692 (let ((tmp (generate-new-buffer "tm-vm/tmp")))
|
|
693 (set-buffer pbuf)
|
|
694 (append-to-buffer tmp (point-min) (point-max))
|
|
695 (set-buffer tmp)
|
|
696 (map-extents
|
|
697 '(lambda (ext maparg)
|
|
698 (set-extent-property ext 'begin-glyph nil)))
|
|
699 (append-to-buffer b (point-min) (point-max))
|
|
700 (setq end (vm-marker
|
|
701 (+ start (length (buffer-string))) b))
|
|
702 (kill-buffer tmp))
|
|
703 (set-buffer pbuf)
|
|
704 (append-to-buffer b (point-min) (point-max))
|
|
705 (setq end (vm-marker
|
|
706 (+ start (length (buffer-string))) b)))
|
|
707 (save-restriction
|
|
708 (setq message (vm-real-message-of message))
|
|
709 (set-buffer (vm-buffer-of message))
|
|
710 (widen)
|
|
711 (append-to-buffer
|
|
712 b (vm-headers-of message) (vm-text-end-of message))
|
|
713 (setq end
|
|
714 (vm-marker (+ start (- (vm-text-end-of message)
|
|
715 (vm-headers-of message))) b))))))
|
|
716 (push-mark end)
|
|
717 (cond (mail-citation-hook (run-hooks 'mail-citation-hook))
|
|
718 (mail-yank-hooks (run-hooks 'mail-yank-hooks))
|
|
719 (t (vm-mail-yank-default message)))
|
|
720 ))
|
|
721 (if tm-vm/yank:message-to-restore
|
|
722 (save-selected-window
|
|
723 (vm-goto-message tm-vm/yank:message-to-restore)
|
|
724 (setq tm-vm/yank:message-to-restore nil)))
|
|
725 ))
|
4
|
726
|
|
727
|
70
|
728 ;;; @ for tm-view
|
|
729 ;;;
|
4
|
730
|
|
731 ;;; based on vm-do-reply [vm-reply.el]
|
|
732 (defun tm-vm/do-reply (buf to-all include-text)
|
|
733 (save-excursion
|
|
734 (set-buffer buf)
|
|
735 (let ((dir default-directory)
|
70
|
736 to cc subject mp in-reply-to references newsgroups)
|
4
|
737 (cond ((setq to
|
|
738 (let ((reply-to (std11-field-body "Reply-To")))
|
|
739 (if (vm-ignored-reply-to reply-to)
|
|
740 nil
|
|
741 reply-to))))
|
|
742 ((setq to (std11-field-body "From")))
|
|
743 ;; (t (error "No From: or Reply-To: header in message"))
|
|
744 )
|
|
745 (if to-all
|
|
746 (setq cc (delq nil (cons cc (std11-field-bodies '("To" "Cc"))))
|
|
747 cc (mapconcat 'identity cc ","))
|
|
748 )
|
|
749 (setq subject (std11-field-body "Subject"))
|
|
750 (and subject vm-reply-subject-prefix
|
|
751 (let ((case-fold-search t))
|
|
752 (not
|
|
753 (equal
|
|
754 (string-match (regexp-quote vm-reply-subject-prefix)
|
|
755 subject)
|
|
756 0)))
|
|
757 (setq subject (concat vm-reply-subject-prefix subject)))
|
|
758 (setq in-reply-to (std11-field-body "Message-Id")
|
|
759 references (nconc
|
|
760 (std11-field-bodies '("References" "In-Reply-To"))
|
|
761 (list in-reply-to))
|
|
762 newsgroups (list (or (and to-all
|
|
763 (std11-field-body "Followup-To"))
|
|
764 (std11-field-body "Newsgroups"))))
|
|
765 (setq to (vm-parse-addresses to)
|
|
766 cc (vm-parse-addresses cc))
|
|
767 (if vm-reply-ignored-addresses
|
|
768 (setq to (vm-strip-ignored-addresses to)
|
|
769 cc (vm-strip-ignored-addresses cc)))
|
|
770 (setq to (vm-delete-duplicates to nil t))
|
|
771 (setq cc (vm-delete-duplicates
|
|
772 (append (vm-delete-duplicates cc nil t)
|
|
773 to (copy-sequence to))
|
|
774 t t))
|
|
775 (and to (setq to (mapconcat 'identity to ",\n ")))
|
|
776 (and cc (setq cc (mapconcat 'identity cc ",\n ")))
|
|
777 (and (null to) (setq to cc cc nil))
|
|
778 (setq references (delq nil references)
|
|
779 references (mapconcat 'identity references " ")
|
|
780 references (vm-parse references "[^<]*\\(<[^>]+>\\)")
|
|
781 references (vm-delete-duplicates references)
|
|
782 references (if references (mapconcat 'identity references "\n\t")))
|
|
783 (setq newsgroups (delq nil newsgroups)
|
|
784 newsgroups (mapconcat 'identity newsgroups ",")
|
|
785 newsgroups (vm-parse newsgroups "[ \t\f\r\n,]*\\([^ \t\f\r\n,]+\\)")
|
|
786 newsgroups (vm-delete-duplicates newsgroups)
|
|
787 newsgroups (if newsgroups (mapconcat 'identity newsgroups ",")))
|
|
788 (vm-mail-internal
|
|
789 (if to
|
|
790 (format "reply to %s%s"
|
|
791 (std11-full-name-string
|
|
792 (car (std11-parse-address-string to)))
|
|
793 (if cc ", ..." "")))
|
|
794 to subject in-reply-to cc references newsgroups)
|
|
795 (setq mail-reply-buffer buf
|
|
796 ;; vm-system-state 'replying
|
|
797 default-directory dir))
|
|
798 (if include-text
|
|
799 (save-excursion
|
|
800 (goto-char (point-min))
|
|
801 (let ((case-fold-search nil))
|
|
802 (re-search-forward
|
|
803 (concat "^" (regexp-quote mail-header-separator) "$") nil 0))
|
|
804 (forward-char 1)
|
|
805 (tm-vm/yank-content)))
|
|
806 (run-hooks 'vm-reply-hook)
|
|
807 (run-hooks 'vm-mail-mode-hook)
|
|
808 ))
|
|
809
|
|
810 (defun tm-vm/following-method (buf)
|
|
811 (tm-vm/do-reply buf 'to-all 'include-text)
|
|
812 )
|
|
813
|
|
814 (defun tm-vm/yank-content ()
|
|
815 (interactive)
|
|
816 (let ((this-command 'vm-yank-message))
|
|
817 (vm-display nil nil '(vm-yank-message)
|
|
818 '(vm-yank-message composing-message))
|
|
819 (save-restriction
|
|
820 (narrow-to-region (point)(point))
|
|
821 (insert-buffer mail-reply-buffer)
|
|
822 (goto-char (point-max))
|
|
823 (push-mark)
|
|
824 (goto-char (point-min)))
|
|
825 (cond (mail-citation-hook (run-hooks 'mail-citation-hook))
|
|
826 (mail-yank-hooks (run-hooks 'mail-yank-hooks))
|
|
827 (t (mail-indent-citation)))
|
|
828 ))
|
|
829
|
|
830 (set-alist 'mime-viewer/following-method-alist
|
|
831 'vm-mode
|
|
832 (function tm-vm/following-method))
|
|
833 (set-alist 'mime-viewer/following-method-alist
|
|
834 'vm-virtual-mode
|
|
835 (function tm-vm/following-method))
|
|
836
|
70
|
837
|
|
838 (defun tm-vm/quit-view-message ()
|
|
839 "Quit MIME-Viewer and go back to normal VM. MIME Preview buffer
|
|
840 is killed. This function is called by `mime-viewer/quit' command
|
|
841 via `mime-viewer/quitting-method-alist'."
|
|
842 (if (get-buffer mime/output-buffer-name)
|
|
843 (vm-undisplay-buffer mime/output-buffer-name))
|
|
844 (vm-select-folder-buffer)
|
|
845 (let* ((mbuf (current-buffer))
|
|
846 (pbuf (and mime::article/preview-buffer
|
|
847 (get-buffer mime::article/preview-buffer)))
|
|
848 (pwin (and pbuf (vm-get-visible-buffer-window pbuf))))
|
|
849 (kill-buffer pbuf)
|
|
850 (and pwin
|
|
851 (select-window pwin)
|
|
852 (switch-to-buffer mbuf)))
|
|
853 (setq tm-vm/system-state nil)
|
|
854 (vm-display (current-buffer) t (list this-command)
|
|
855 (list 'reading-message))
|
|
856 )
|
|
857
|
|
858 (defun tm-vm/view-message ()
|
|
859 "Decode and view a MIME encoded message under VM.
|
|
860 A MIME Preview buffer using mime/viewer-mode is created.
|
|
861 See mime/viewer-mode for more information"
|
|
862 (interactive)
|
|
863 (vm-follow-summary-cursor)
|
|
864 (vm-select-folder-buffer)
|
|
865 (vm-check-for-killed-summary)
|
|
866 (vm-error-if-folder-empty)
|
|
867 (vm-display (current-buffer) t '(tm-vm/view-message
|
|
868 tm-vm/toggle-preview-mode)
|
|
869 '(tm-vm/view-message reading-message))
|
|
870 (let ((tm-vm/automatic-mime-preview t))
|
|
871 (tm-vm/preview-current-message))
|
|
872 )
|
|
873
|
4
|
874 (set-alist 'mime-viewer/quitting-method-alist
|
|
875 'vm-mode
|
|
876 'tm-vm/quit-view-message)
|
70
|
877
|
4
|
878 (set-alist 'mime-viewer/quitting-method-alist
|
|
879 'vm-virtual-mode
|
|
880 'tm-vm/quit-view-message)
|
|
881
|
|
882
|
70
|
883 ;;; @ for tm-partial
|
4
|
884 ;;;
|
|
885
|
|
886 (call-after-loaded
|
|
887 'tm-partial
|
|
888 (function
|
|
889 (lambda ()
|
|
890 (set-atype 'mime/content-decoding-condition
|
|
891 '((type . "message/partial")
|
|
892 (method . mime-article/grab-message/partials)
|
|
893 (major-mode . vm-mode)
|
|
894 (summary-buffer-exp . vm-summary-buffer)
|
|
895 ))
|
|
896 (set-alist 'tm-partial/preview-article-method-alist
|
|
897 'vm-mode
|
|
898 (function
|
|
899 (lambda ()
|
|
900 (tm-vm/view-message)
|
|
901 )))
|
|
902 )))
|
|
903
|
|
904
|
70
|
905 ;;; @ for tm-edit
|
|
906 ;;;
|
|
907
|
|
908 ;;; @@ for multipart/digest
|
4
|
909 ;;;
|
|
910
|
70
|
911 (defvar tm-vm/forward-message-hook nil
|
|
912 "*List of functions called after a Mail mode buffer has been
|
|
913 created to forward a message in message/rfc822 type format.
|
|
914 If `vm-forwarding-digest-type' is \"rfc1521\", tm-vm runs this
|
|
915 hook instead of `vm-forward-message-hook'.")
|
4
|
916
|
70
|
917 (defvar tm-vm/send-digest-hook nil
|
|
918 "*List of functions called after a Mail mode buffer has been
|
|
919 created to send a digest in multipart/digest type format.
|
|
920 If `vm-digest-send-type' is \"rfc1521\", tm-vm runs this hook
|
|
921 instead of `vm-send-digest-hook'.")
|
4
|
922
|
|
923 (defun tm-vm/enclose-messages (mlist &optional preamble)
|
|
924 "Enclose the messages in MLIST as multipart/digest.
|
|
925 The resulting digest is inserted at point in the current buffer.
|
|
926
|
|
927 MLIST should be a list of message structs (real or virtual).
|
|
928 These are the messages that will be enclosed."
|
|
929 (if mlist
|
|
930 (let ((digest (consp (cdr mlist)))
|
|
931 (mp mlist)
|
|
932 m)
|
|
933 (save-restriction
|
|
934 (narrow-to-region (point) (point))
|
|
935 (while mlist
|
|
936 (setq m (vm-real-message-of (car mlist)))
|
|
937 (mime-editor/insert-tag "message" "rfc822")
|
|
938 (tm-mail/insert-message m)
|
|
939 (goto-char (point-max))
|
|
940 (setq mlist (cdr mlist)))
|
|
941 (if preamble
|
|
942 (progn
|
|
943 (goto-char (point-min))
|
|
944 (mime-editor/insert-tag "text" "plain")
|
|
945 (vm-unsaved-message "Building digest preamble...")
|
|
946 (while mp
|
|
947 (let ((vm-summary-uninteresting-senders nil))
|
|
948 (insert
|
|
949 (vm-sprintf 'vm-digest-preamble-format (car mp)) "\n"))
|
|
950 (if vm-digest-center-preamble
|
|
951 (progn
|
|
952 (forward-char -1)
|
|
953 (center-line)
|
|
954 (forward-char 1)))
|
|
955 (setq mp (cdr mp)))))
|
|
956 (if digest
|
|
957 (mime-editor/enclose-digest-region (point-min) (point-max)))
|
|
958 ))))
|
|
959
|
70
|
960 (defun tm-vm/forward-message ()
|
|
961 "Forward the current message to one or more recipients.
|
|
962 You will be placed in a Mail mode buffer as you would with a
|
|
963 reply, but you must fill in the To: header and perhaps the
|
|
964 Subject: header manually."
|
|
965 (interactive)
|
4
|
966 (if (not (equal vm-forwarding-digest-type "rfc1521"))
|
70
|
967 (vm-forward-message)
|
4
|
968 (vm-follow-summary-cursor)
|
|
969 (vm-select-folder-buffer)
|
|
970 (vm-check-for-killed-summary)
|
|
971 (vm-error-if-folder-empty)
|
|
972 (if (eq last-command 'vm-next-command-uses-marks)
|
|
973 (let ((vm-digest-send-type vm-forwarding-digest-type))
|
|
974 (setq this-command 'vm-next-command-uses-marks)
|
|
975 (command-execute 'tm-vm/send-digest))
|
|
976 (let ((dir default-directory)
|
|
977 (mp vm-message-pointer))
|
|
978 (save-restriction
|
|
979 (widen)
|
|
980 (vm-mail-internal
|
|
981 (format "forward of %s's note re: %s"
|
|
982 (vm-su-full-name (car vm-message-pointer))
|
|
983 (vm-su-subject (car vm-message-pointer)))
|
|
984 nil
|
|
985 (and vm-forwarding-subject-format
|
|
986 (let ((vm-summary-uninteresting-senders nil))
|
|
987 (vm-sprintf 'vm-forwarding-subject-format (car mp)))))
|
|
988 (make-local-variable 'vm-forward-list)
|
|
989 (setq vm-system-state 'forwarding
|
|
990 vm-forward-list (list (car mp))
|
|
991 default-directory dir)
|
|
992 (goto-char (point-min))
|
|
993 (re-search-forward
|
|
994 (concat "^" (regexp-quote mail-header-separator) "\n") nil 0)
|
|
995 (tm-vm/enclose-messages vm-forward-list)
|
|
996 (mail-position-on-field "To"))
|
|
997 (run-hooks 'tm-vm/forward-message-hook)
|
|
998 (run-hooks 'vm-mail-mode-hook)))))
|
|
999
|
|
1000 (defun tm-vm/send-digest (&optional arg)
|
|
1001 "Send a digest of all messages in the current folder to recipients.
|
|
1002 The type of the digest is specified by the variable vm-digest-send-type.
|
|
1003 You will be placed in a Mail mode buffer as is usual with replies, but you
|
|
1004 must fill in the To: and Subject: headers manually.
|
|
1005
|
|
1006 If invoked on marked messages (via vm-next-command-uses-marks),
|
|
1007 only marked messages will be put into the digest."
|
|
1008 (interactive "P")
|
|
1009 (if (not (equal vm-digest-send-type "rfc1521"))
|
|
1010 (vm-send-digest arg)
|
|
1011 (vm-select-folder-buffer)
|
|
1012 (vm-check-for-killed-summary)
|
|
1013 (vm-error-if-folder-empty)
|
|
1014 (let ((dir default-directory)
|
|
1015 (vm-forward-list (if (eq last-command 'vm-next-command-uses-marks)
|
|
1016 (vm-select-marked-or-prefixed-messages 0)
|
70
|
1017 vm-message-list))
|
|
1018 start)
|
4
|
1019 (save-restriction
|
|
1020 (widen)
|
|
1021 (vm-mail-internal (format "digest from %s" (buffer-name)))
|
|
1022 (setq vm-system-state 'forwarding
|
|
1023 default-directory dir)
|
|
1024 (goto-char (point-min))
|
|
1025 (re-search-forward (concat "^" (regexp-quote mail-header-separator)
|
|
1026 "\n"))
|
|
1027 (goto-char (match-end 0))
|
|
1028 (vm-unsaved-message "Building %s digest..." vm-digest-send-type)
|
|
1029 (tm-vm/enclose-messages vm-forward-list arg)
|
|
1030 (mail-position-on-field "To")
|
|
1031 (message "Building %s digest... done" vm-digest-send-type)))
|
|
1032 (run-hooks 'tm-vm/send-digest-hook)
|
|
1033 (run-hooks 'vm-mail-mode-hook)))
|
|
1034
|
70
|
1035 (substitute-key-definition 'vm-forward-message
|
|
1036 'tm-vm/forward-message vm-mode-map)
|
4
|
1037 (substitute-key-definition 'vm-send-digest
|
|
1038 'tm-vm/send-digest vm-mode-map)
|
70
|
1039
|
4
|
1040
|
70
|
1041 ;;; @@ setting
|
|
1042 ;;;
|
|
1043
|
|
1044 (defvar tm-vm/use-xemacs-popup-menu t)
|
4
|
1045
|
70
|
1046 ;;; modified by Steven L. Baur <steve@miranova.com>
|
|
1047 ;;; 1995/12/6 (c.f. [tm-en:209])
|
|
1048 (defun mime-editor/attach-to-vm-mode-menu ()
|
|
1049 "Arrange to attach MIME editor's popup menu to VM's"
|
|
1050 (if (boundp 'vm-menu-mail-menu)
|
|
1051 (progn
|
|
1052 (setq vm-menu-mail-menu
|
|
1053 (append vm-menu-mail-menu
|
|
1054 (list "----"
|
|
1055 mime-editor/popup-menu-for-xemacs)))
|
|
1056 (remove-hook 'vm-mail-mode-hook 'mime-editor/attach-to-vm-mode-menu)
|
|
1057 )))
|
4
|
1058
|
|
1059 (call-after-loaded
|
|
1060 'tm-edit
|
|
1061 (function
|
|
1062 (lambda ()
|
|
1063 (autoload 'tm-mail/insert-message "tm-mail")
|
|
1064 (set-alist 'mime-editor/message-inserter-alist
|
|
1065 'mail-mode (function tm-mail/insert-message))
|
|
1066 (set-alist 'mime-editor/split-message-sender-alist
|
|
1067 'mail-mode (function
|
|
1068 (lambda ()
|
|
1069 (interactive)
|
70
|
1070 (sendmail-send-it)
|
4
|
1071 )))
|
70
|
1072 (if (and (string-match "XEmacs\\|Lucid" emacs-version)
|
|
1073 tm-vm/use-xemacs-popup-menu)
|
|
1074 (add-hook 'vm-mail-mode-hook 'mime-editor/attach-to-vm-mode-menu)
|
|
1075 )
|
4
|
1076 )))
|
|
1077
|
70
|
1078 (call-after-loaded
|
|
1079 'mime-setup
|
|
1080 (function
|
|
1081 (lambda ()
|
|
1082 (setq vm-forwarding-digest-type "rfc1521")
|
|
1083 (setq vm-digest-send-type "rfc1521")
|
|
1084 )))
|
20
|
1085
|
|
1086
|
70
|
1087 ;;; @ for BBDB
|
4
|
1088 ;;;
|
|
1089
|
|
1090 (call-after-loaded
|
|
1091 'bbdb
|
|
1092 (function
|
|
1093 (lambda ()
|
|
1094 (require 'bbdb-vm)
|
|
1095 (require 'tm-bbdb)
|
|
1096 (defun tm-bbdb/vm-update-record (&optional offer-to-create)
|
70
|
1097 (vm-select-folder-buffer)
|
|
1098 (if (and (tm-vm/system-state)
|
|
1099 mime::article/preview-buffer
|
|
1100 (get-buffer mime::article/preview-buffer))
|
|
1101 (let ((tm-bbdb/auto-create-p bbdb/mail-auto-create-p))
|
|
1102 (tm-bbdb/update-record offer-to-create))
|
|
1103 (or (bbdb/vm-update-record offer-to-create)
|
|
1104 (delete-windows-on (get-buffer "*BBDB*")))
|
|
1105 ))
|
4
|
1106 (remove-hook 'vm-select-message-hook 'bbdb/vm-update-record)
|
|
1107 (remove-hook 'vm-show-message-hook 'bbdb/vm-update-record)
|
|
1108 (add-hook 'tm-vm/select-message-hook 'tm-bbdb/vm-update-record)
|
|
1109 )))
|
|
1110
|
70
|
1111 ;;; @ for ps-print (Suggestted by Anders Stenman <stenman@isy.liu.se>)
|
4
|
1112 ;;;
|
|
1113
|
70
|
1114 (require 'ps-print)
|
|
1115
|
|
1116 (add-hook 'vm-mode-hook 'tm-vm/ps-print-setup)
|
|
1117 (add-hook 'mime-viewer/define-keymap-hook 'tm-vm/ps-print-setup)
|
|
1118 (fset 'vm-toolbar-print-command 'tm-vm/print-message)
|
4
|
1119
|
|
1120 (defun tm-vm/ps-print-setup ()
|
|
1121 "Set things up for printing MIME messages with ps-print. Set binding to
|
|
1122 the [Print Screen] key."
|
70
|
1123 (local-set-key (ps-prsc) 'tm-vm/print-message)
|
4
|
1124 (setq ps-header-lines 3)
|
|
1125 (setq ps-left-header
|
|
1126 (list 'ps-article-subject 'ps-article-author 'buffer-name)))
|
|
1127
|
|
1128 (defun tm-vm/print-message ()
|
|
1129 "Print current message with ps-print if it's a MIME message.
|
|
1130 Value of tm-vm/strict-mime is also taken into consideration."
|
|
1131 (interactive)
|
|
1132 (vm-follow-summary-cursor)
|
70
|
1133 (let* ((mbuf (or (vm-select-folder-buffer) (current-buffer)))
|
|
1134 pbuf)
|
|
1135 (tm-vm/sync-preview-buffer)
|
|
1136 (setq pbuf (and mime::article/preview-buffer
|
|
1137 (get-buffer mime::article/preview-buffer)))
|
4
|
1138 (if pbuf
|
|
1139 (save-excursion
|
|
1140 (set-buffer pbuf)
|
|
1141 (require 'ps-print)
|
|
1142 (ps-print-buffer-with-faces))
|
|
1143 (vm-print-message))))
|
|
1144
|
|
1145 ;;; @ end
|
70
|
1146 ;;;
|
4
|
1147
|
|
1148 (provide 'tm-vm)
|
70
|
1149
|
4
|
1150 (run-hooks 'tm-vm-load-hook)
|
|
1151
|
|
1152 ;;; tm-vm.el ends here.
|
70
|
1153
|