2 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
3 ;;; Copyright (C) 1994,1995 MORIOKA Tomohiko
5 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
7 ;;; $Id: tm-rmail.el,v 7.8 1995/10/30 05:52:36 morioka Exp $
8 ;;; Keywords: mail, MIME, multimedia, multilingual, encoded-word
10 ;;; This file is part of tm (Tools for MIME).
17 (autoload 'mime/viewer-mode "tm-view" "View MIME message." t)
18 (autoload 'mime/Content-Type "tm-view" "parse Content-Type field.")
19 (autoload 'mime/decode-message-header "tm-ew-d" "Decode MIME encoded-word." t)
25 (defvar tm-rmail/decode-all nil)
31 (setq rmail-message-filter
34 (let ((mf (buffer-modified-p))
35 (buffer-read-only nil))
36 (mime/decode-message-header)
37 (set-buffer-modified-p mf)
44 (defun tm-rmail/show-all-header-p ()
46 (narrow-to-region (point-min)
47 (and (re-search-forward "^$" nil t)
49 (goto-char (point-min))
50 (re-search-forward rmail-ignored-headers nil t)
53 (defun tm-rmail/preview-message ()
55 (setq tm-rmail/decode-all t)
56 (let ((ret (rmail-widen-to-current-msgbeg
59 (cons (mime/Content-Type)
60 (mail-fetch-field "Content-Transfer-Encoding"))
62 (mime/viewer-mode nil (car ret)(cdr ret) nil
63 (format "*Preview-%s [%d/%d]*"
65 rmail-current-message rmail-total-messages))
68 (defun tm-rmail/preview-message-if-you-need ()
69 (if tm-rmail/decode-all
70 (tm-rmail/preview-message)
73 (add-hook 'rmail-show-message-hook 'tm-rmail/preview-message-if-you-need)
75 (define-key rmail-mode-map "v" (function tm-rmail/preview-message))
77 (defun tm-rmail/setup ()
78 (local-set-key "v" (function
81 (pop-to-buffer rmail-buffer)
82 (tm-rmail/preview-message)
86 (add-hook 'rmail-summary-mode-hook 'tm-rmail/setup)
89 ;;; @ over-to-* and quitting methods
92 (defun tm-rmail/quitting-method-to-summary ()
93 (mime-viewer/kill-buffer)
95 (delete-other-windows)
98 (defun tm-rmail/quitting-method-to-article ()
99 (setq tm-rmail/decode-all nil)
100 (mime-viewer/kill-buffer)
103 (defalias 'tm-rmail/quitting-method 'tm-rmail/quitting-method-to-article)
106 (defun tm-rmail/over-to-previous-method ()
107 (let (tm-rmail/decode-all)
110 (if (not (eq (rmail-next-undeleted-message -1) t))
111 (tm-rmail/preview-message)
115 (defun tm-rmail/over-to-next-method ()
116 (let (tm-rmail/decode-all)
119 (if (not (eq (rmail-next-undeleted-message 1) t))
120 (tm-rmail/preview-message)
128 (set-alist 'mime-viewer/quitting-method-alist
130 (function tm-rmail/quitting-method))
132 (set-alist 'mime-viewer/over-to-previous-method-alist
134 (function tm-rmail/over-to-previous-method))
136 (set-alist 'mime-viewer/over-to-next-method-alist
138 (function tm-rmail/over-to-next-method))
149 (set-atype 'mime/content-decoding-condition
150 '((type . "message/partial")
151 (method . mime-article/grab-message/partials)
152 (major-mode . rmail-mode)
156 (pop-to-buffer rmail-buffer)
157 rmail-summary-buffer))
159 (set-alist 'tm-partial/preview-article-method-alist
163 (rmail-summary-goto-msg (count-lines 1 (point)))
164 (pop-to-buffer rmail-buffer)
165 (tm-rmail/view-message)
178 (defun tm-rmail/forward ()
180 Forward current message in message/rfc822 content-type message
181 from rmail. The message will be appended if being composed."
183 ;;>> this gets set even if we abort. Can't do anything about it, though.
184 (rmail-set-attribute "forwarded" t)
185 (let ((initialized nil)
187 (forwarding-buffer (current-buffer))
189 (mail-strip-quoted-names
190 (mail-fetch-field "From"))
191 ": " (or (mail-fetch-field "Subject") "") "]")))
192 ;; If only one window, use it for the mail buffer.
193 ;; Otherwise, use another window for the mail buffer
194 ;; so that the Rmail buffer remains visible
195 ;; and sending the mail will get back to it.
198 (mail nil nil subject)
199 (mail-other-window nil nil subject)))
201 (goto-char (point-max))
203 (setq beginning (point))
204 (tm-edit/insert-tag "message" "rfc822")
205 (insert-buffer forwarding-buffer))
206 (if (not initialized)
207 (goto-char beginning))
210 (substitute-key-definition 'rmail-forward
214 (defun tm-rmail/forward-from-gnus ()
216 Forward current article in message/rfc822 content-type message from
217 GNUS. The message will be appended if being composed."
218 (let ((initialized nil)
220 (forwarding-buffer (current-buffer))
222 (concat "[" gnus-newsgroup-name "] "
223 ;;(mail-strip-quoted-names (gnus-fetch-field "From")) ": "
224 (or (gnus-fetch-field "Subject") ""))))
225 ;; If only one window, use it for the mail buffer.
226 ;; Otherwise, use another window for the mail buffer
227 ;; so that the Rmail buffer remains visible
228 ;; and sending the mail will get back to it.
231 (mail nil nil subject)
232 (mail-other-window nil nil subject)))
234 (goto-char (point-max))
235 (setq beginning (point))
236 (mime-editor/insert-tag "message" "rfc822")
237 (insert-buffer forwarding-buffer)
238 ;; You have a chance to arrange the message.
239 (run-hooks 'gnus-mail-forward-hook)
241 (if (not initialized)
242 (goto-char beginning))
245 ;; (setq gnus-mail-forward-method 'mime-forward-from-gnus-using-mail)
255 (run-hooks 'tm-rmail-load-hook)