Mercurial > hg > xemacs-beta
comparison lisp/tm/tm-vm.el @ 74:54cc21c15cbb r20-0b32
Import from CVS: tag r20-0b32
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:04:33 +0200 |
parents | 131b0175ea99 |
children | 0d2f883870bc |
comparison
equal
deleted
inserted
replaced
73:e2d7a37b7c8d | 74:54cc21c15cbb |
---|---|
7 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp> | 7 ;; MORIOKA Tomohiko <morioka@jaist.ac.jp> |
8 ;; Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp> | 8 ;; Shuhei KOBAYASHI <shuhei-k@jaist.ac.jp> |
9 ;; Oscar Figueiredo <Oscar.Figueiredo@di.epfl.ch> | 9 ;; Oscar Figueiredo <Oscar.Figueiredo@di.epfl.ch> |
10 ;; Maintainer: Oscar Figueiredo <Oscar.Figueiredo@di.epfl.ch> | 10 ;; Maintainer: Oscar Figueiredo <Oscar.Figueiredo@di.epfl.ch> |
11 ;; Created: 1994/10/29 | 11 ;; Created: 1994/10/29 |
12 ;; Version: $Revision: 1.1.1.1 $ | 12 ;; Version: $Revision: 1.1.1.2 $ |
13 ;; Keywords: mail, MIME, multimedia, multilingual, encoded-word | 13 ;; Keywords: mail, MIME, multimedia, multilingual, encoded-word |
14 | 14 |
15 ;; This file is part of tm (Tools for MIME). | 15 ;; This file is part of tm (Tools for MIME). |
16 | 16 |
17 ;; This program is free software; you can redistribute it and/or | 17 ;; This program is free software; you can redistribute it and/or |
33 | 33 |
34 ;; Plese insert `(require 'tm-vm)' in your ~/.vm file. | 34 ;; Plese insert `(require 'tm-vm)' in your ~/.vm file. |
35 | 35 |
36 ;;; Code: | 36 ;;; Code: |
37 | 37 |
38 (eval-when-compile | |
39 (require 'tm-edit) | |
40 (require 'tm-mail) | |
41 (require 'vm) | |
42 (require 'vm-window)) | |
43 | |
38 (require 'tm-view) | 44 (require 'tm-view) |
39 (require 'vm) | |
40 | 45 |
41 (defconst tm-vm/RCS-ID | 46 (defconst tm-vm/RCS-ID |
42 "$Id: tm-vm.el,v 1.1.1.1 1996/12/18 22:43:38 steve Exp $") | 47 "$Id: tm-vm.el,v 1.1.1.2 1996/12/21 20:50:47 steve Exp $") |
43 (defconst tm-vm/version (get-version-string tm-vm/RCS-ID)) | 48 (defconst tm-vm/version (get-version-string tm-vm/RCS-ID)) |
44 | 49 |
45 (define-key vm-mode-map "Z" 'tm-vm/view-message) | 50 (define-key vm-mode-map "Z" 'tm-vm/view-message) |
46 (define-key vm-mode-map "T" 'tm-vm/decode-message-header) | 51 (define-key vm-mode-map "T" 'tm-vm/decode-message-header) |
47 (define-key vm-mode-map "\et" 'tm-vm/toggle-preview-mode) | 52 (define-key vm-mode-map "\et" 'tm-vm/toggle-preview-mode) |
173 mime-viewer/content-header-filter-alist)) | 178 mime-viewer/content-header-filter-alist)) |
174 | 179 |
175 (defun tm-vm/header-filter () | 180 (defun tm-vm/header-filter () |
176 "Filter headers in current buffer (assumed to be a message-like buffer) | 181 "Filter headers in current buffer (assumed to be a message-like buffer) |
177 according to vm-visible-headers and vm-invisible-header-regexp" | 182 according to vm-visible-headers and vm-invisible-header-regexp" |
178 (beginning-of-buffer) | 183 (goto-char (point-min)) |
179 (let ((visible-headers vm-visible-headers)) | 184 (let ((visible-headers vm-visible-headers)) |
180 (if (or vm-use-lucid-highlighting | 185 (if (or vm-use-lucid-highlighting |
181 vm-display-xfaces) | 186 vm-display-xfaces) |
182 (setq visible-headers (cons "X-Face:" vm-visible-headers))) | 187 (setq visible-headers (cons "X-Face:" vm-visible-headers))) |
183 (vm-reorder-message-headers nil | 188 (vm-reorder-message-headers nil |
253 ;; don't display if neither mwin nor pwin was displayed before. | 258 ;; don't display if neither mwin nor pwin was displayed before. |
254 ))) | 259 ))) |
255 (set-buffer mbuf))) | 260 (set-buffer mbuf))) |
256 | 261 |
257 (defun tm-vm/preview-current-message () | 262 (defun tm-vm/preview-current-message () |
258 "Preview current message if it has a MIME contents and | 263 "Preview current message if it has MIME contents and |
259 tm-vm/automatic-mime-preview is non nil. Installed on | 264 tm-vm/automatic-mime-preview is non nil. Installed on |
260 vm-visit-folder-hook and vm-select-message-hook." | 265 vm-visit-folder-hook and vm-select-message-hook." |
261 ;; assumed current buffer is folder buffer. | 266 ;; assumed current buffer is folder buffer. |
262 (setq tm-vm/system-state nil) | 267 (setq tm-vm/system-state nil) |
263 (if (get-buffer mime/output-buffer-name) | 268 (if (get-buffer mime/output-buffer-name) |
311 (defun tm-vm/show-current-message () | 316 (defun tm-vm/show-current-message () |
312 "Update current message display and summary. Remove 'unread' and 'new' flags. " | 317 "Update current message display and summary. Remove 'unread' and 'new' flags. " |
313 (if mime::preview/article-buffer | 318 (if mime::preview/article-buffer |
314 (set-buffer mime::preview/article-buffer) | 319 (set-buffer mime::preview/article-buffer) |
315 (vm-select-folder-buffer)) | 320 (vm-select-folder-buffer)) |
316 (if mime::article/preview-buffer | 321 (if (and mime::article/preview-buffer |
322 (get-buffer mime::article/preview-buffer)) | |
317 (save-excursion | 323 (save-excursion |
318 (set-buffer mime::article/preview-buffer) | 324 (set-buffer mime::article/preview-buffer) |
319 (goto-char (point-min)) | 325 (goto-char (point-min)) |
320 (widen))) | 326 (widen))) |
321 (if (or (and mime::article/preview-buffer | 327 (if (or (and mime::article/preview-buffer |
328 (get-buffer mime::article/preview-buffer) | |
322 (vm-get-visible-buffer-window mime::article/preview-buffer)) | 329 (vm-get-visible-buffer-window mime::article/preview-buffer)) |
323 (vm-get-visible-buffer-window (current-buffer))) | 330 (vm-get-visible-buffer-window (current-buffer))) |
324 (progn | 331 (progn |
325 (setq tm-vm/system-state 'reading) | 332 (setq tm-vm/system-state 'reading) |
326 (if (vm-new-flag (car vm-message-pointer)) | 333 (if (vm-new-flag (car vm-message-pointer)) |
376 (get-buffer mime::article/preview-buffer))) | 383 (get-buffer mime::article/preview-buffer))) |
377 (pwin (and pbuf (vm-get-buffer-window pbuf))) | 384 (pwin (and pbuf (vm-get-buffer-window pbuf))) |
378 (was-invisible (and (null mwin) (null pwin))) | 385 (was-invisible (and (null mwin) (null pwin))) |
379 ) | 386 ) |
380 ;; now current buffer is folder buffer. | 387 ;; now current buffer is folder buffer. |
381 (tm-vm/save-window-excursion | 388 (if (or mp-changed was-invisible) |
382 (if (or mp-changed was-invisible) | 389 (vm-display mbuf t '(vm-scroll-forward vm-scroll-backward) |
383 (vm-display mbuf t '(vm-scroll-forward vm-scroll-backward) | 390 (list this-command 'reading-message))) |
384 (list this-command 'reading-message))) | 391 (tm-vm/display-preview-buffer) |
385 (tm-vm/display-preview-buffer) | 392 (setq mwin (vm-get-buffer-window mbuf) |
386 (setq mwin (vm-get-buffer-window mbuf) | 393 pwin (and pbuf (vm-get-buffer-window pbuf))) |
387 pwin (and pbuf (vm-get-buffer-window pbuf))) | 394 (cond |
388 (cond | 395 ((or mp-changed was-invisible) |
389 ((or mp-changed was-invisible) | 396 nil) |
390 nil | 397 ((null pbuf) |
391 ) | 398 ;; preview buffer is killed. |
392 ((null pbuf) | 399 (tm-vm/preview-current-message) |
393 ;; preview buffer is killed. | 400 (vm-update-summary-and-mode-line)) |
394 (tm-vm/preview-current-message) | 401 ((eq (tm-vm/system-state) 'previewing) |
395 (vm-update-summary-and-mode-line)) | 402 (tm-vm/show-current-message)) |
396 ((eq (tm-vm/system-state) 'previewing) | 403 (t |
397 (tm-vm/show-current-message)) | 404 (tm-vm/save-window-excursion |
398 (t | 405 (select-window pwin) |
399 (select-window pwin) | 406 (set-buffer pbuf) |
400 (set-buffer pbuf) | 407 (if (pos-visible-in-window-p (point-max) pwin) |
401 (if (pos-visible-in-window-p (point-max) pwin) | 408 (tm-vm/next-message) |
402 (tm-vm/next-message) | 409 ;; not end of message. scroll preview buffer only. |
403 ;; not end of message. scroll preview buffer only. | 410 (scroll-up) |
404 (scroll-up) | 411 (tm-vm/howl-if-eom) |
405 (tm-vm/howl-if-eom) | 412 (set-buffer mbuf)) |
406 (set-buffer mbuf)) | 413 )))) |
407 )))) | |
408 ))) | 414 ))) |
409 | 415 |
410 ;;; based on vm-scroll-backward [vm-page.el] | 416 ;;; based on vm-scroll-backward [vm-page.el] |
411 (defun tm-vm/scroll-backward (&optional arg) | 417 (defun tm-vm/scroll-backward (&optional arg) |
412 (interactive "P") | 418 (interactive "P") |
423 ) | 429 ) |
424 ;; now current buffer is folder buffer. | 430 ;; now current buffer is folder buffer. |
425 (if (or mp-changed was-invisible) | 431 (if (or mp-changed was-invisible) |
426 (vm-display mbuf t '(vm-scroll-forward vm-scroll-backward) | 432 (vm-display mbuf t '(vm-scroll-forward vm-scroll-backward) |
427 (list this-command 'reading-message))) | 433 (list this-command 'reading-message))) |
428 (tm-vm/save-window-excursion | 434 (tm-vm/display-preview-buffer) |
429 (tm-vm/display-preview-buffer) | 435 (setq mwin (vm-get-buffer-window mbuf) |
430 (setq mwin (vm-get-buffer-window mbuf) | 436 pwin (and pbuf (vm-get-buffer-window pbuf))) |
431 pwin (and pbuf (vm-get-buffer-window pbuf))) | 437 (cond |
432 (cond | 438 (was-invisible |
433 (was-invisible | 439 nil |
434 nil | 440 ) |
435 ) | 441 ((null pbuf) |
436 ((null pbuf) | 442 ;; preview buffer is killed. |
437 ;; preview buffer is killed. | 443 (tm-vm/preview-current-message) |
438 (tm-vm/preview-current-message) | 444 (vm-update-summary-and-mode-line)) |
439 (vm-update-summary-and-mode-line)) | 445 ((eq (tm-vm/system-state) 'previewing) |
440 ((eq (tm-vm/system-state) 'previewing) | 446 (tm-vm/show-current-message)) |
441 (tm-vm/show-current-message)) | 447 (t |
442 (t | 448 (tm-vm/save-window-excursion |
443 (select-window pwin) | 449 (select-window pwin) |
444 (set-buffer pbuf) | 450 (set-buffer pbuf) |
445 (if (pos-visible-in-window-p (point-min) pwin) | 451 (if (pos-visible-in-window-p (point-min) pwin) |
446 nil | 452 nil |
447 ;; scroll preview buffer only. | 453 ;; scroll preview buffer only. |
448 (scroll-down) | 454 (scroll-down) |
449 (set-buffer mbuf)) | 455 (set-buffer mbuf)) |
450 )))) | 456 )))) |
451 ))) | 457 ))) |
452 | 458 |
453 ;;; based on vm-beginning-of-message [vm-page.el] | 459 ;;; based on vm-beginning-of-message [vm-page.el] |
454 (defun tm-vm/beginning-of-message () | 460 (defun tm-vm/beginning-of-message () |
455 "Moves to the beginning of the current message." | 461 "Moves to the beginning of the current message." |
555 (vm-select-folder-buffer) | 561 (vm-select-folder-buffer) |
556 (if (and mime::article/preview-buffer | 562 (if (and mime::article/preview-buffer |
557 (get-buffer mime::article/preview-buffer)) | 563 (get-buffer mime::article/preview-buffer)) |
558 (kill-buffer mime::article/preview-buffer))) | 564 (kill-buffer mime::article/preview-buffer))) |
559 (vm-quit-no-change)) | 565 (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 | 566 |
574 ;;; based on vm-next-message [vm-motion.el] | 567 ;;; based on vm-next-message [vm-motion.el] |
575 (defun tm-vm/next-message () | 568 (defun tm-vm/next-message () |
576 (set-buffer mime::preview/article-buffer) | 569 (set-buffer mime::preview/article-buffer) |
577 (let ((this-command 'vm-next-message) | 570 (let ((this-command 'vm-next-message) |
685 (let* ((mbuf (current-buffer)) | 678 (let* ((mbuf (current-buffer)) |
686 pbuf) | 679 pbuf) |
687 (tm-vm/sync-preview-buffer) | 680 (tm-vm/sync-preview-buffer) |
688 (setq pbuf (and mime::article/preview-buffer | 681 (setq pbuf (and mime::article/preview-buffer |
689 (get-buffer mime::article/preview-buffer))) | 682 (get-buffer mime::article/preview-buffer))) |
690 (if pbuf | 683 (if (and pbuf |
684 (not (eq this-command 'tm-vm/forward-message))) | |
691 (if running-xemacs | 685 (if running-xemacs |
692 (let ((tmp (generate-new-buffer "tm-vm/tmp"))) | 686 (let ((tmp (generate-new-buffer "tm-vm/tmp"))) |
693 (set-buffer pbuf) | 687 (set-buffer pbuf) |
694 (append-to-buffer tmp (point-min) (point-max)) | 688 (append-to-buffer tmp (point-min) (point-max)) |
695 (set-buffer tmp) | 689 (set-buffer tmp) |
963 reply, but you must fill in the To: header and perhaps the | 957 reply, but you must fill in the To: header and perhaps the |
964 Subject: header manually." | 958 Subject: header manually." |
965 (interactive) | 959 (interactive) |
966 (if (not (equal vm-forwarding-digest-type "rfc1521")) | 960 (if (not (equal vm-forwarding-digest-type "rfc1521")) |
967 (vm-forward-message) | 961 (vm-forward-message) |
962 (if mime::preview/article-buffer | |
963 (set-buffer mime::preview/article-buffer)) | |
968 (vm-follow-summary-cursor) | 964 (vm-follow-summary-cursor) |
969 (vm-select-folder-buffer) | 965 (vm-select-folder-buffer) |
970 (vm-check-for-killed-summary) | 966 (vm-check-for-killed-summary) |
971 (vm-error-if-folder-empty) | 967 (vm-error-if-folder-empty) |
972 (if (eq last-command 'vm-next-command-uses-marks) | 968 (if (eq last-command 'vm-next-command-uses-marks) |
1065 'mail-mode (function tm-mail/insert-message)) | 1061 'mail-mode (function tm-mail/insert-message)) |
1066 (set-alist 'mime-editor/split-message-sender-alist | 1062 (set-alist 'mime-editor/split-message-sender-alist |
1067 'mail-mode (function | 1063 'mail-mode (function |
1068 (lambda () | 1064 (lambda () |
1069 (interactive) | 1065 (interactive) |
1070 (sendmail-send-it) | 1066 (funcall send-mail-function) |
1071 ))) | 1067 ))) |
1072 (if (and (string-match "XEmacs\\|Lucid" emacs-version) | 1068 (if (and (string-match "XEmacs\\|Lucid" emacs-version) |
1073 tm-vm/use-xemacs-popup-menu) | 1069 tm-vm/use-xemacs-popup-menu) |
1074 (add-hook 'vm-mail-mode-hook 'mime-editor/attach-to-vm-mode-menu) | 1070 (add-hook 'vm-mail-mode-hook 'mime-editor/attach-to-vm-mode-menu) |
1075 ) | 1071 ) |
1109 ))) | 1105 ))) |
1110 | 1106 |
1111 ;;; @ for ps-print (Suggestted by Anders Stenman <stenman@isy.liu.se>) | 1107 ;;; @ for ps-print (Suggestted by Anders Stenman <stenman@isy.liu.se>) |
1112 ;;; | 1108 ;;; |
1113 | 1109 |
1114 (require 'ps-print) | 1110 (defvar tm-vm/use-ps-print (not (featurep 'mule)) |
1115 | 1111 "*Use Postscript printing (ps-print) to print MIME messages.") |
1116 (add-hook 'vm-mode-hook 'tm-vm/ps-print-setup) | 1112 |
1117 (add-hook 'mime-viewer/define-keymap-hook 'tm-vm/ps-print-setup) | 1113 (if tm-vm/use-ps-print |
1118 (fset 'vm-toolbar-print-command 'tm-vm/print-message) | 1114 (progn |
1115 (autoload 'ps-print-buffer-with-faces "ps-print" "Postscript Print" t) | |
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))) | |
1119 | 1119 |
1120 (defun tm-vm/ps-print-setup () | 1120 (defun tm-vm/ps-print-setup () |
1121 "Set things up for printing MIME messages with ps-print. Set binding to | 1121 "Set things up for printing MIME messages with ps-print. Set binding to |
1122 the [Print Screen] key." | 1122 the [Print Screen] key." |
1123 (local-set-key (ps-prsc) 'tm-vm/print-message) | 1123 (local-set-key (if running-xemacs |
1124 'f22 | |
1125 [f22]) | |
1126 'tm-vm/print-message) | |
1124 (setq ps-header-lines 3) | 1127 (setq ps-header-lines 3) |
1125 (setq ps-left-header | 1128 (setq ps-left-header |
1126 (list 'ps-article-subject 'ps-article-author 'buffer-name))) | 1129 (list 'ps-article-subject 'ps-article-author 'buffer-name))) |
1127 | 1130 |
1128 (defun tm-vm/print-message () | 1131 (defun tm-vm/print-message () |
1140 (set-buffer pbuf) | 1143 (set-buffer pbuf) |
1141 (require 'ps-print) | 1144 (require 'ps-print) |
1142 (ps-print-buffer-with-faces)) | 1145 (ps-print-buffer-with-faces)) |
1143 (vm-print-message)))) | 1146 (vm-print-message)))) |
1144 | 1147 |
1148 | |
1149 ;;; @ Substitute VM bindings and menus | |
1150 ;;; | |
1151 | |
1152 (substitute-key-definition 'vm-scroll-forward | |
1153 'tm-vm/scroll-forward vm-mode-map) | |
1154 (substitute-key-definition 'vm-scroll-backward | |
1155 'tm-vm/scroll-backward vm-mode-map) | |
1156 (substitute-key-definition 'vm-beginning-of-message | |
1157 'tm-vm/beginning-of-message vm-mode-map) | |
1158 (substitute-key-definition 'vm-end-of-message | |
1159 'tm-vm/end-of-message vm-mode-map) | |
1160 (substitute-key-definition 'vm-forward-message | |
1161 'tm-vm/forward-message vm-mode-map) | |
1162 (substitute-key-definition 'vm-quit | |
1163 'tm-vm/quit vm-mode-map) | |
1164 (substitute-key-definition 'vm-quit-no-change | |
1165 'tm-vm/quit-no-change vm-mode-map) | |
1166 | |
1167 ;; The following function should be modified and called on vm-menu-setup-hook | |
1168 ;; but VM 5.96 does not run that hook on XEmacs | |
1169 (require 'vm-menu) | |
1170 (if running-xemacs | |
1171 (condition-case nil | |
1172 (aset (car (find-menu-item vm-menu-dispose-menu '("Forward"))) | |
1173 1 | |
1174 'tm-vm/forward-message) | |
1175 (t nil))) | |
1176 | |
1145 ;;; @ end | 1177 ;;; @ end |
1146 ;;; | 1178 ;;; |
1147 | 1179 |
1148 (provide 'tm-vm) | 1180 (provide 'tm-vm) |
1149 | 1181 |