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).
18 (autoload 'mime/viewer-mode "tm-view" "View MIME message." t)
19 (autoload 'mime/decode-message-header
20 "tm-ew-d" "Decode MIME encoded-word." t)
21 (autoload 'mime/decode-encoded-words-string
22 "tm-ew-d" "Decode MIME encoded-word." t)
28 (defconst tm-gnus/RCS-ID
29 "$Id: tm-gnus5.el,v 7.0 1995/10/03 05:07:54 morioka Exp $")
31 (defconst tm-gnus/version
32 (concat (get-version-string tm-gnus/RCS-ID) " for GNUS 5"))
34 (defconst tm-gnus/automatic-MIME-preview-support
35 (cond ((boundp 'gnus-clean-article-buffer)
36 (defconst gnus-version (concat gnus-version " with tm patch"))
39 (defvar gnus-clean-article-buffer gnus-article-buffer)
43 (defvar tm-gnus/preview-buffer
44 (if tm-gnus/automatic-MIME-preview-support
45 (concat "*Preview-" gnus-clean-article-buffer "*"))
52 (defvar tm-gnus/original-article-display-hook gnus-article-display-hook)
54 (defvar tm-gnus/decode-all tm-gnus/automatic-MIME-preview-support
56 tm-gnus/automatic-MIME-preview-support is non-nil,
57 article is automatic MIME decoded.")
60 ;;; @ command functions
63 (defun tm-gnus/view-message (arg)
64 "MIME decode and play this message."
66 (let ((gnus-break-pages nil))
67 (gnus-summary-select-article t t)
69 (pop-to-buffer gnus-clean-article-buffer t)
70 (let (buffer-read-only)
71 (if (text-property-any (point-min) (point-max) 'invisible t)
72 (remove-text-properties (point-min) (point-max)
73 gnus-hidden-properties)
78 (defun tm-gnus/summary-scroll-down ()
79 "Scroll down one line current article."
81 (gnus-summary-scroll-up -1)
84 (define-key gnus-summary-mode-map "v" (function tm-gnus/view-message))
85 (define-key gnus-summary-mode-map
86 "\e\r" (function tm-gnus/summary-scroll-down))
92 (defun mime-viewer/quitting-method-for-gnus5 ()
93 (mime-viewer/kill-buffer)
94 (delete-other-windows)
95 (gnus-article-show-summary)
96 (gnus-summary-display-article (gnus-summary-article-number))
103 (set-alist 'mime-viewer/quitting-method-alist
105 (function mime-viewer/quitting-method-for-gnus5))
112 (defun tm-gnus/decode-summary-from-and-subjects ()
113 (mapcar (lambda (header)
114 (let ((from (mail-header-from header))
115 (subj (mail-header-subject header))
117 (mail-header-set-from
120 (mime/decode-encoded-words-string from)
122 (mail-header-set-subject
125 (mime/decode-encoded-words-string subj)
128 gnus-newsgroup-headers)
131 (add-hook 'gnus-select-group-hook
132 (function tm-gnus/decode-summary-from-and-subjects))
138 (setq gnus-show-mime-method (function mime/decode-message-header))
141 ;;; @ automatic MIME preview support
144 (defun tm-gnus/summary-toggle-header (&optional arg)
146 (if tm-gnus/decode-all
147 (let ((mime-viewer/ignored-field-list
148 (if (save-window-excursion
149 (switch-to-buffer tm-gnus/preview-buffer)
153 (message/get-field-body field)
155 mime-viewer/ignored-field-list))
156 mime-viewer/ignored-field-list)))
157 (gnus-summary-select-article t t)
159 (gnus-summary-toggle-header arg)
162 (defun tm-gnus/set-mime-method (mode)
165 (setq gnus-show-mime nil)
166 (setq gnus-article-display-hook
167 (list (function (lambda ()
169 (gnus-set-mode-line 'article)
171 (set-alist 'gnus-window-to-buffer 'article tm-gnus/preview-buffer)
172 (setq gnus-article-buffer tm-gnus/preview-buffer)
174 (setq gnus-show-mime t)
175 (setq gnus-article-display-hook tm-gnus/original-article-display-hook)
176 (set-alist 'gnus-window-to-buffer 'article gnus-clean-article-buffer)
177 (setq gnus-article-buffer gnus-clean-article-buffer)
180 (defun tm-gnus/toggle-mime (arg)
181 "Toggle MIME processing mode.
182 With arg, turn MIME processing on if arg is positive."
184 (setq tm-gnus/decode-all
186 (not tm-gnus/decode-all)
188 (gnus-set-global-variables)
189 (tm-gnus/set-mime-method tm-gnus/decode-all)
190 (gnus-summary-select-article gnus-show-all-headers 'force)
193 (if tm-gnus/automatic-MIME-preview-support
195 (define-key gnus-summary-mode-map
196 "t" (function tm-gnus/summary-toggle-header))
197 (define-key gnus-summary-mode-map "\et" (function tm-gnus/toggle-mime))
199 (tm-gnus/set-mime-method tm-gnus/decode-all)
201 (add-hook 'gnus-exit-gnus-hook
204 (let ((buf (get-buffer tm-gnus/preview-buffer)))
209 (setq gnus-article-display-hook tm-gnus/original-article-display-hook)
210 (setq gnus-show-mime t)
221 (set-alist 'mime/message-sender-alist
223 (function gnus-inews-news))