2 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
3 ;;; Copyright (C) 1994,1995 MORIOKA Tomohiko
5 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;;; modified by KOBAYASHI Shuhei <shuhei@cmpt01.phys.tohoku.ac.jp>
10 ;;; Keywords: mail, MIME, multimedia, multilingual, encoded-word
12 ;;; This file is part of tm (Tools for MIME).
14 ;;; This program is free software; you can redistribute it and/or
15 ;;; modify it under the terms of the GNU General Public License as
16 ;;; published by the Free Software Foundation; either version 2, or
17 ;;; (at your option) any later version.
19 ;;; This program is distributed in the hope that it will be useful,
20 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
21 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 ;;; General Public License for more details.
24 ;;; You should have received a copy of the GNU General Public License
25 ;;; along with This program. If not, write to the Free Software
26 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
34 (autoload 'mime/viewer-mode "tm-view" "View MIME message." t)
35 (autoload 'mime/Content-Type "tm-view" "parse Content-Type field.")
36 (autoload 'mime/decode-message-header "tm-ew-d" "Decode MIME encoded-word." t)
42 (defconst tm-rmail/RCS-ID
43 "$Id: tm-rmail.el,v 7.19 1995/12/07 04:55:49 morioka Exp $")
44 (defconst tm-rmail/version (get-version-string tm-rmail/RCS-ID))
46 (defvar tm-rmail/decode-all nil)
52 (setq rmail-message-filter
55 (let ((mf (buffer-modified-p))
56 (buffer-read-only nil))
57 (mime/decode-message-header)
58 (set-buffer-modified-p mf)
65 (defun tm-rmail/show-all-header-p ()
67 (narrow-to-region (point-min)
68 (and (re-search-forward "^$" nil t)
70 (goto-char (point-min))
71 (re-search-forward rmail-ignored-headers nil t)
74 (defun tm-rmail/preview-message ()
76 (setq tm-rmail/decode-all t)
77 (let ((ret (rmail-widen-to-current-msgbeg
80 (cons (mime/Content-Type)
81 (mime/Content-Transfer-Encoding "7bit")
84 (narrow-to-region (point-min)
86 (goto-char (point-max))
87 (if (and (re-search-backward "^\n")
88 (eq (match-end 0)(point-max)))
92 (mime/viewer-mode nil (car ret)(cdr ret) nil
93 (format "*Preview-%s [%d/%d]*"
95 rmail-current-message rmail-total-messages))
98 (defun tm-rmail/preview-message-if-you-need ()
99 (if tm-rmail/decode-all
100 (tm-rmail/preview-message)
103 (add-hook 'rmail-show-message-hook 'tm-rmail/preview-message-if-you-need)
105 (define-key rmail-mode-map "v" (function tm-rmail/preview-message))
107 (defun tm-rmail/setup ()
108 (local-set-key "v" (function
111 (pop-to-buffer rmail-buffer)
112 (tm-rmail/preview-message)
116 (add-hook 'rmail-summary-mode-hook 'tm-rmail/setup)
119 ;;; @ over-to-* and quitting methods
122 (defun tm-rmail/quitting-method-to-summary ()
123 (mime-viewer/kill-buffer)
125 (delete-other-windows)
128 (defun tm-rmail/quitting-method-to-article ()
129 (setq tm-rmail/decode-all nil)
130 (mime-viewer/kill-buffer)
133 (defalias 'tm-rmail/quitting-method 'tm-rmail/quitting-method-to-article)
136 (defun tm-rmail/over-to-previous-method ()
137 (let (tm-rmail/decode-all)
140 (if (not (eq (rmail-next-undeleted-message -1) t))
141 (tm-rmail/preview-message)
145 (defun tm-rmail/over-to-next-method ()
146 (let (tm-rmail/decode-all)
149 (if (not (eq (rmail-next-undeleted-message 1) t))
150 (tm-rmail/preview-message)
158 (set-alist 'mime-viewer/quitting-method-alist
160 (function tm-rmail/quitting-method))
162 (set-alist 'mime-viewer/over-to-previous-method-alist
164 (function tm-rmail/over-to-previous-method))
166 (set-alist 'mime-viewer/over-to-next-method-alist
168 (function tm-rmail/over-to-next-method))
179 (set-atype 'mime/content-decoding-condition
180 '((type . "message/partial")
181 (method . mime-article/grab-message/partials)
182 (major-mode . rmail-mode)
186 (pop-to-buffer rmail-buffer)
187 rmail-summary-buffer))
189 (set-alist 'tm-partial/preview-article-method-alist
193 (rmail-summary-goto-msg (count-lines 1 (point)))
194 (pop-to-buffer rmail-buffer)
195 (tm-rmail/preview-message)
203 (defun tm-rmail/forward ()
204 "Forward current message in message/rfc822 content-type message
205 from rmail. The message will be appended if being composed."
207 ;;>> this gets set even if we abort. Can't do anything about it, though.
208 (rmail-set-attribute "forwarded" t)
209 (let ((initialized nil)
211 (msgnum rmail-current-message)
212 (rmail-buffer (current-buffer))
214 (mail-strip-quoted-names
215 (mail-fetch-field "From"))
216 ": " (or (mail-fetch-field "Subject") "") "]")))
217 ;; If only one window, use it for the mail buffer.
218 ;; Otherwise, use another window for the mail buffer
219 ;; so that the Rmail buffer remains visible
220 ;; and sending the mail will get back to it.
223 (mail nil nil subject)
224 (mail-other-window nil nil subject)))
226 ;; following two variables are used in 19.29 or later.
227 (make-local-variable 'rmail-send-actions-rmail-buffer)
228 (make-local-variable 'rmail-send-actions-rmail-msg-number)
229 (make-local-variable 'mail-reply-buffer)
230 (setq rmail-send-actions-rmail-buffer rmail-buffer)
231 (setq rmail-send-actions-rmail-msg-number msgnum)
232 (setq mail-reply-buffer rmail-buffer)
233 (goto-char (point-max))
235 (setq beginning (point))
236 (mime-editor/insert-tag "message" "rfc822")
237 ;; (insert-buffer rmail-buffer))
238 ;; (mime-editor/inserted-message-filter))
239 (tm-mail/insert-message))
240 (if (not initialized)
241 (goto-char beginning))
244 (defun gnus-mail-forward-using-mail-mime ()
245 "Forward current article in message/rfc822 content-type message from
246 GNUS. The message will be appended if being composed."
247 (let ((initialized nil)
249 (forwarding-buffer (current-buffer))
251 (concat "[" gnus-newsgroup-name "] "
252 ;;(mail-strip-quoted-names (gnus-fetch-field "From")) ": "
253 (or (gnus-fetch-field "Subject") ""))))
254 ;; If only one window, use it for the mail buffer.
255 ;; Otherwise, use another window for the mail buffer
256 ;; so that the Rmail buffer remains visible
257 ;; and sending the mail will get back to it.
260 (mail nil nil subject)
261 (mail-other-window nil nil subject)))
263 (goto-char (point-max))
264 (setq beginning (point))
265 (mime-editor/insert-tag "message" "rfc822")
266 (insert-buffer forwarding-buffer)
267 ;; You have a chance to arrange the message.
268 (run-hooks 'gnus-mail-forward-hook)
270 (if (not initialized)
271 (goto-char beginning))
278 (substitute-key-definition
279 'rmail-forward 'tm-rmail/forward rmail-mode-map)
281 ;; (setq gnus-mail-forward-method 'gnus-mail-forward-using-mail-mime)
287 (autoload 'tm-mail/insert-message "tm-mail")
288 (set-alist 'mime-editor/message-inserter-alist
289 'mail-mode (function tm-mail/insert-message))
299 (run-hooks 'tm-rmail-load-hook)