2 ;;; tm-gnus5.el --- tm-gnus module for GNUS 5.*
13 (defconst tm-gnus/RCS-ID
14 "$Id: tm-gnus5.el,v 6.21 1995/09/07 17:07:41 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 mime-viewer/quitting-method-for-gnus5 ()
87 (mime-viewer/kill-buffer)
88 (delete-other-windows)
89 (gnus-article-show-summary)
90 (gnus-summary-display-article (gnus-summary-article-number))
97 (set-alist 'mime-viewer/quitting-method-alist
99 (function mime-viewer/quitting-method-for-gnus5))
106 (defun tm-gnus/decode-summary-from-and-subjects ()
109 (mail-header-set-from
111 (mime/decode-string (or (mail-header-from header) ""))
113 (mail-header-set-subject
115 (mime/decode-string (or (mail-header-subject header) ""))
118 gnus-newsgroup-headers)
121 (add-hook 'gnus-select-group-hook
122 (function tm-gnus/decode-summary-from-and-subjects))
128 (setq gnus-show-mime-method (function mime/decode-message-header))
131 ;;; @ automatic MIME preview support
134 (defun tm-gnus/summary-toggle-header (&optional arg)
136 (if tm-gnus/decode-all
137 (let ((mime-viewer/ignored-field-list
138 (if (save-window-excursion
139 (switch-to-buffer tm-gnus/preview-buffer)
143 (message/get-field-body field)
145 mime-viewer/ignored-field-list))
146 mime-viewer/ignored-field-list)))
147 (gnus-summary-select-article t t)
149 (gnus-summary-toggle-header arg)
152 (defun tm-gnus/set-mime-method (mode)
155 (setq gnus-show-mime nil)
156 (setq gnus-article-display-hook
157 (list (function (lambda ()
159 (gnus-set-mode-line 'article)
161 (set-alist 'gnus-window-to-buffer 'article tm-gnus/preview-buffer)
162 (setq gnus-article-buffer tm-gnus/preview-buffer)
164 (setq gnus-show-mime t)
165 (setq gnus-article-display-hook tm-gnus/original-article-display-hook)
166 (set-alist 'gnus-window-to-buffer 'article gnus-clean-article-buffer)
167 (setq gnus-article-buffer gnus-clean-article-buffer)
170 (defun tm-gnus/toggle-mime (arg)
171 "Toggle MIME processing mode.
172 With arg, turn MIME processing on if arg is positive."
174 (setq tm-gnus/decode-all
176 (not tm-gnus/decode-all)
178 (gnus-set-global-variables)
179 (tm-gnus/set-mime-method tm-gnus/decode-all)
180 (gnus-summary-select-article gnus-show-all-headers 'force)
183 (if tm-gnus/automatic-MIME-preview-support
185 (define-key gnus-summary-mode-map
186 "t" (function tm-gnus/summary-toggle-header))
187 (define-key gnus-summary-mode-map "\et" (function tm-gnus/toggle-mime))
189 (tm-gnus/set-mime-method tm-gnus/decode-all)
191 (add-hook 'gnus-exit-gnus-hook
194 (let ((buf (get-buffer tm-gnus/preview-buffer)))
199 (setq gnus-article-display-hook tm-gnus/original-article-display-hook)
200 (setq gnus-show-mime t)
211 (set-alist 'mime/message-sender-alist
213 (function gnus-inews-news))