2 ;;; tm-gnus5.el --- tm-gnus module for GNUS 5.*
13 (defconst tm-gnus/RCS-ID
14 "$Id: tm-gnus5.el,v 6.18 1995/08/31 20:19:42 morioka Exp $")
16 (defconst tm-gnus/version
17 (concat (get-version-string tm-gnus/RCS-ID) " for GNUS 5"))
19 (defconst tm-gnus/automatic-MIME-preview-support
20 (cond ((boundp 'gnus-clean-article-buffer)
21 (defconst gnus-version (concat gnus-version " with tm patch"))
24 (defvar gnus-clean-article-buffer gnus-article-buffer)
28 (defvar tm-gnus/preview-buffer
29 (if tm-gnus/automatic-MIME-preview-support
30 (concat "*Preview-" gnus-clean-article-buffer "*"))
37 (autoload 'mime/viewer-mode "tm-view" "View MIME message." t)
38 (autoload 'mime/decode-message-header
39 "tiny-mime" "Decode MIME encoded-word." t)
40 (autoload 'mime/decode-string "tiny-mime" "Decode MIME encoded-word." t)
46 (defvar tm-gnus/original-article-display-hook gnus-article-display-hook)
48 (defvar tm-gnus/decode-all tm-gnus/automatic-MIME-preview-support
50 tm-gnus/automatic-MIME-preview-support is non-nil,
51 article is automatic MIME decoded.")
54 ;;; @ command functions
57 (defun tm-gnus/view-message (arg)
58 "MIME decode and play this message."
60 (let ((gnus-break-pages nil))
61 (gnus-summary-select-article t t)
63 (pop-to-buffer gnus-clean-article-buffer t)
64 (let (buffer-read-only)
65 (if (text-property-any (point-min) (point-max) 'invisible t)
66 (remove-text-properties (point-min) (point-max)
67 gnus-hidden-properties)
72 (defun tm-gnus/summary-scroll-down ()
73 "Scroll down one line current article."
75 (gnus-summary-scroll-up -1)
78 (define-key gnus-summary-mode-map "v" (function tm-gnus/view-message))
79 (define-key gnus-summary-mode-map
80 "\e\r" (function tm-gnus/summary-scroll-down))
86 (defun tm-gnus/decode-summary-from-and-subjects ()
91 (mime/decode-string (or (mail-header-from header) ""))
93 (mail-header-set-subject
95 (mime/decode-string (or (mail-header-subject header) ""))
98 gnus-newsgroup-headers)
101 (add-hook 'gnus-select-group-hook
102 (function tm-gnus/decode-summary-from-and-subjects))
108 (setq gnus-show-mime-method
111 (let (buffer-read-only)
112 (mime/decode-message-header)
116 ;;; @ automatic MIME preview support
119 (defun tm-gnus/summary-toggle-header (&optional arg)
121 (if tm-gnus/decode-all
122 (let ((mime-viewer/ignored-field-list
123 (if (save-window-excursion
124 (switch-to-buffer tm-gnus/preview-buffer)
125 (goto-char (point-min))
126 (message/get-field-body
127 (car mime-viewer/ignored-field-list)
129 mime-viewer/ignored-field-list)
131 (gnus-summary-select-article t t)
133 (gnus-summary-toggle-header arg)
136 (defun tm-gnus/set-mime-method (mode)
139 (setq gnus-show-mime nil)
140 (setq gnus-article-display-hook
141 (list (function (lambda ()
143 (gnus-set-mode-line 'article)
145 (set-alist 'gnus-window-to-buffer 'article tm-gnus/preview-buffer)
146 (setq gnus-article-buffer tm-gnus/preview-buffer)
148 (setq gnus-show-mime t)
149 (setq gnus-article-display-hook tm-gnus/original-article-display-hook)
150 (set-alist 'gnus-window-to-buffer 'article gnus-clean-article-buffer)
151 (setq gnus-article-buffer gnus-clean-article-buffer)
154 (defun tm-gnus/toggle-mime (arg)
155 "Toggle MIME processing mode.
156 With arg, turn MIME processing on if arg is positive."
158 (setq tm-gnus/decode-all
160 (not tm-gnus/decode-all)
162 (gnus-set-global-variables)
163 (tm-gnus/set-mime-method tm-gnus/decode-all)
164 (gnus-summary-select-article gnus-show-all-headers 'force)
167 (if tm-gnus/automatic-MIME-preview-support
169 (define-key gnus-summary-mode-map
170 "t" (function tm-gnus/summary-toggle-header))
171 (define-key gnus-summary-mode-map "\et" (function tm-gnus/toggle-mime))
173 (tm-gnus/set-mime-method tm-gnus/decode-all)
175 (add-hook 'gnus-exit-gnus-hook
178 (let ((buf (get-buffer tm-gnus/preview-buffer)))
183 (setq gnus-article-display-hook tm-gnus/original-article-display-hook)
184 (setq gnus-show-mime t)
195 (set-alist 'mime/message-sender-alist
197 (function gnus-inews-news))