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.15 1995/11/12 15:15:15 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 (mime/Content-Transfer-Encoding "7bit")
63 (narrow-to-region (point-min)
65 (goto-char (point-max))
66 (if (and (re-search-backward "^\n")
67 (eq (match-end 0)(point-max)))
71 (mime/viewer-mode nil (car ret)(cdr ret) nil
72 (format "*Preview-%s [%d/%d]*"
74 rmail-current-message rmail-total-messages))
77 (defun tm-rmail/preview-message-if-you-need ()
78 (if tm-rmail/decode-all
79 (tm-rmail/preview-message)
82 (add-hook 'rmail-show-message-hook 'tm-rmail/preview-message-if-you-need)
84 (define-key rmail-mode-map "v" (function tm-rmail/preview-message))
86 (defun tm-rmail/setup ()
87 (local-set-key "v" (function
90 (pop-to-buffer rmail-buffer)
91 (tm-rmail/preview-message)
95 (add-hook 'rmail-summary-mode-hook 'tm-rmail/setup)
98 ;;; @ over-to-* and quitting methods
101 (defun tm-rmail/quitting-method-to-summary ()
102 (mime-viewer/kill-buffer)
104 (delete-other-windows)
107 (defun tm-rmail/quitting-method-to-article ()
108 (setq tm-rmail/decode-all nil)
109 (mime-viewer/kill-buffer)
112 (defalias 'tm-rmail/quitting-method 'tm-rmail/quitting-method-to-article)
115 (defun tm-rmail/over-to-previous-method ()
116 (let (tm-rmail/decode-all)
119 (if (not (eq (rmail-next-undeleted-message -1) t))
120 (tm-rmail/preview-message)
124 (defun tm-rmail/over-to-next-method ()
125 (let (tm-rmail/decode-all)
128 (if (not (eq (rmail-next-undeleted-message 1) t))
129 (tm-rmail/preview-message)
137 (set-alist 'mime-viewer/quitting-method-alist
139 (function tm-rmail/quitting-method))
141 (set-alist 'mime-viewer/over-to-previous-method-alist
143 (function tm-rmail/over-to-previous-method))
145 (set-alist 'mime-viewer/over-to-next-method-alist
147 (function tm-rmail/over-to-next-method))
158 (set-atype 'mime/content-decoding-condition
159 '((type . "message/partial")
160 (method . mime-article/grab-message/partials)
161 (major-mode . rmail-mode)
165 (pop-to-buffer rmail-buffer)
166 rmail-summary-buffer))
168 (set-alist 'tm-partial/preview-article-method-alist
172 (rmail-summary-goto-msg (count-lines 1 (point)))
173 (pop-to-buffer rmail-buffer)
174 (tm-rmail/preview-message)
187 (defun tm-rmail/forward ()
189 Forward current message in message/rfc822 content-type message
190 from rmail. The message will be appended if being composed."
192 ;;>> this gets set even if we abort. Can't do anything about it, though.
193 (rmail-set-attribute "forwarded" t)
194 (let ((initialized nil)
196 (forwarding-buffer (current-buffer))
198 (mail-strip-quoted-names
199 (mail-fetch-field "From"))
200 ": " (or (mail-fetch-field "Subject") "") "]")))
201 ;; If only one window, use it for the mail buffer.
202 ;; Otherwise, use another window for the mail buffer
203 ;; so that the Rmail buffer remains visible
204 ;; and sending the mail will get back to it.
207 (mail nil nil subject)
208 (mail-other-window nil nil subject)))
210 (goto-char (point-max))
212 (setq beginning (point))
213 (mime-editor/insert-tag "message" "rfc822")
214 (insert-buffer forwarding-buffer))
215 (if (not initialized)
216 (goto-char beginning))
219 (substitute-key-definition 'rmail-forward
223 (defun gnus-mail-forward-using-mail-mime ()
225 Forward current article in message/rfc822 content-type message from
226 GNUS. The message will be appended if being composed."
227 (let ((initialized nil)
229 (forwarding-buffer (current-buffer))
231 (concat "[" gnus-newsgroup-name "] "
232 ;;(mail-strip-quoted-names (gnus-fetch-field "From")) ": "
233 (or (gnus-fetch-field "Subject") ""))))
234 ;; If only one window, use it for the mail buffer.
235 ;; Otherwise, use another window for the mail buffer
236 ;; so that the Rmail buffer remains visible
237 ;; and sending the mail will get back to it.
240 (mail nil nil subject)
241 (mail-other-window nil nil subject)))
243 (goto-char (point-max))
244 (setq beginning (point))
245 (mime-editor/insert-tag "message" "rfc822")
246 (insert-buffer forwarding-buffer)
247 ;; You have a chance to arrange the message.
248 (run-hooks 'gnus-mail-forward-hook)
250 (if (not initialized)
251 (goto-char beginning))
254 ;; (setq gnus-mail-forward-method 'mime-forward-from-gnus-using-mail)
264 (run-hooks 'tm-rmail-load-hook)