2 ;;; tm-gnus5.el --- tm-gnus module for Gnus 5.*
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1995 MORIOKA Tomohiko
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; Keywords: news, MIME, multimedia, multilingual, encoded-word
10 ;;; This file is part of tm (Tools for MIME).
19 (autoload 'mime/viewer-mode "tm-view" "View MIME message." t)
20 (autoload 'mime/decode-message-header
21 "tm-ew-d" "Decode MIME encoded-words in message header." t)
22 (autoload 'mime-eword/decode-string
23 "tm-ew-d" "Decode MIME encoded-words in string." t)
29 (defconst tm-gnus/RCS-ID
30 "$Id: tm-gnus5.el,v 7.4 1995/10/22 12:13:50 morioka Exp $")
32 (defconst tm-gnus/version
33 (concat (get-version-string tm-gnus/RCS-ID) " for GNUS 5"))
35 (defconst tm-gnus/automatic-MIME-preview-support
36 (cond ((boundp 'gnus-clean-article-buffer)
37 (defconst gnus-version (concat gnus-version " with tm patch"))
40 (defvar gnus-clean-article-buffer gnus-article-buffer)
44 (defvar tm-gnus/preview-buffer
45 (if tm-gnus/automatic-MIME-preview-support
46 (concat "*Preview-" gnus-clean-article-buffer "*"))
53 (defvar tm-gnus/original-article-display-hook gnus-article-display-hook)
55 (defvar tm-gnus/decode-all tm-gnus/automatic-MIME-preview-support
57 tm-gnus/automatic-MIME-preview-support is non-nil,
58 article is automatic MIME decoded.")
61 ;;; @ command functions
64 (defun tm-gnus/view-message (arg)
65 "MIME decode and play this message."
67 (let ((gnus-break-pages nil))
68 (gnus-summary-select-article t t)
70 (pop-to-buffer gnus-clean-article-buffer t)
71 (let (buffer-read-only)
72 (if (text-property-any (point-min) (point-max) 'invisible t)
73 (remove-text-properties (point-min) (point-max)
74 gnus-hidden-properties)
79 (defun tm-gnus/summary-scroll-down ()
80 "Scroll down one line current article."
82 (gnus-summary-scroll-up -1)
85 (define-key gnus-summary-mode-map "v" (function tm-gnus/view-message))
86 (define-key gnus-summary-mode-map
87 "\e\r" (function tm-gnus/summary-scroll-down))
93 (defun mime-viewer/quitting-method-for-gnus5 ()
94 (mime-viewer/kill-buffer)
95 (delete-other-windows)
96 (gnus-article-show-summary)
97 (gnus-summary-display-article (gnus-summary-article-number))
103 (set-alist 'mime-viewer/quitting-method-alist
105 (function mime-viewer/quitting-method-for-gnus5))
116 (set-atype 'mime/content-decoding-condition
117 '((type . "message/partial")
118 (method . mime-article/grab-message/partials)
119 (major-mode . gnus-article-mode)
120 (summary-buffer-exp . gnus-summary-buffer)
123 (set-alist 'tm-partial/preview-article-method-alist
127 (tm-gnus/view-message (gnus-summary-article-number))
135 (defun tm-gnus/decode-summary-from-and-subjects ()
136 (mapcar (lambda (header)
137 (let ((from (mail-header-from header))
138 (subj (mail-header-subject header))
140 (mail-header-set-from
143 (mime-eword/decode-string from)
145 (mail-header-set-subject
148 (mime-eword/decode-string subj)
151 gnus-newsgroup-headers)
154 (add-hook 'gnus-select-group-hook
155 (function tm-gnus/decode-summary-from-and-subjects))
161 (setq gnus-show-mime-method (function mime/decode-message-header))
164 ;;; @ automatic MIME preview support
167 (defun tm-gnus/summary-toggle-header (&optional arg)
169 (if tm-gnus/decode-all
170 (let ((mime-viewer/ignored-field-list
171 (if (save-window-excursion
172 (switch-to-buffer tm-gnus/preview-buffer)
175 (rfc822/get-field-body field)
177 mime-viewer/ignored-field-list))
178 mime-viewer/ignored-field-list)))
179 (gnus-summary-select-article t t)
181 (gnus-summary-toggle-header arg)
184 (defun tm-gnus/set-mime-method (mode)
187 (setq gnus-show-mime nil)
188 (setq gnus-article-display-hook
189 (list (function (lambda ()
191 (gnus-set-mode-line 'article)
193 (set-alist 'gnus-window-to-buffer 'article tm-gnus/preview-buffer)
194 (setq gnus-article-buffer tm-gnus/preview-buffer)
196 (setq gnus-show-mime t)
197 (setq gnus-article-display-hook tm-gnus/original-article-display-hook)
198 (set-alist 'gnus-window-to-buffer 'article gnus-clean-article-buffer)
199 (setq gnus-article-buffer gnus-clean-article-buffer)
202 (defun tm-gnus/toggle-mime (arg)
203 "Toggle MIME processing mode.
204 With arg, turn MIME processing on if arg is positive."
206 (setq tm-gnus/decode-all
208 (not tm-gnus/decode-all)
210 (gnus-set-global-variables)
211 (tm-gnus/set-mime-method tm-gnus/decode-all)
212 (gnus-summary-select-article gnus-show-all-headers 'force)
215 (if tm-gnus/automatic-MIME-preview-support
217 (define-key gnus-summary-mode-map
218 "t" (function tm-gnus/summary-toggle-header))
219 (define-key gnus-summary-mode-map "\et" (function tm-gnus/toggle-mime))
221 (tm-gnus/set-mime-method tm-gnus/decode-all)
223 (add-hook 'gnus-exit-gnus-hook
225 (let ((buf (get-buffer tm-gnus/preview-buffer)))
230 (setq gnus-article-display-hook tm-gnus/original-article-display-hook)
231 (setq gnus-show-mime t)
242 (set-alist 'mime/message-sender-alist
244 (function gnus-inews-news))
251 ;;; by OKABE Yasuo <okabe@kudpc.kyoto-u.ac.jp>
253 ;;; Please use following setting:
254 ;;; (setq gnus-mail-forward-method
255 ;;; (function gnus-mail-forward-using-mhe-mime))
257 (defun gnus-mail-forward-using-mhe-mime (&optional buffer)
258 "Forward the current message to another user using mh-e with mime-mode."
259 ;; First of all, prepare mhe mail buffer.
260 (let* ((to (read-string "To: "))
261 (cc (read-string "Cc: "))
262 (buffer (or buffer gnus-clean-article-buffer))
263 (config (current-window-configuration));; need to add this - erik
264 (subject (gnus-forward-make-subject buffer)))
265 (setq mh-show-buffer buffer)
267 (mh-send-sub to (or cc "") (or subject "(None)") config);; Erik Selberg 1/23/94
268 (let ((draft (current-buffer))
269 (gnus-mail-buffer (current-buffer))
271 (gnus-configure-windows 'reply-yank)
272 (setq mail-buf (eval (cdr (assq 'mail gnus-window-to-buffer))))
273 (pop-to-buffer mail-buf);; always in the display, so won't have window probs
274 (switch-to-buffer draft)
277 (goto-char (point-max))
278 (insert (concat (mime-make-tag "message" "rfc822" nil "7bit") "\n"))
279 (insert-buffer buffer)
280 (setq mh-sent-from-folder buffer)
281 (setq mh-sent-from-msg 1)
282 (setq mh-previous-window-config config)
283 (run-hooks 'gnus-mail-hook)