2 ;;; tm-gnus5.el --- tm-gnus module for GNUS 5.*
13 (defconst tm-gnus/RCS-ID
14 "$Id: tm-gnus5.el,v 6.20 1995/09/04 10:53:07 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 (function mime/decode-message-header))
111 ;;; @ automatic MIME preview support
114 (defun tm-gnus/summary-toggle-header (&optional arg)
116 (if tm-gnus/decode-all
117 (let ((mime-viewer/ignored-field-list
118 (if (save-window-excursion
119 (switch-to-buffer tm-gnus/preview-buffer)
123 (message/get-field-body field)
125 mime-viewer/ignored-field-list))
126 mime-viewer/ignored-field-list)))
127 (gnus-summary-select-article t t)
129 (gnus-summary-toggle-header arg)
132 (defun tm-gnus/set-mime-method (mode)
135 (setq gnus-show-mime nil)
136 (setq gnus-article-display-hook
137 (list (function (lambda ()
139 (gnus-set-mode-line 'article)
141 (set-alist 'gnus-window-to-buffer 'article tm-gnus/preview-buffer)
142 (setq gnus-article-buffer tm-gnus/preview-buffer)
144 (setq gnus-show-mime t)
145 (setq gnus-article-display-hook tm-gnus/original-article-display-hook)
146 (set-alist 'gnus-window-to-buffer 'article gnus-clean-article-buffer)
147 (setq gnus-article-buffer gnus-clean-article-buffer)
150 (defun tm-gnus/toggle-mime (arg)
151 "Toggle MIME processing mode.
152 With arg, turn MIME processing on if arg is positive."
154 (setq tm-gnus/decode-all
156 (not tm-gnus/decode-all)
158 (gnus-set-global-variables)
159 (tm-gnus/set-mime-method tm-gnus/decode-all)
160 (gnus-summary-select-article gnus-show-all-headers 'force)
163 (if tm-gnus/automatic-MIME-preview-support
165 (define-key gnus-summary-mode-map
166 "t" (function tm-gnus/summary-toggle-header))
167 (define-key gnus-summary-mode-map "\et" (function tm-gnus/toggle-mime))
169 (tm-gnus/set-mime-method tm-gnus/decode-all)
171 (add-hook 'gnus-exit-gnus-hook
174 (let ((buf (get-buffer tm-gnus/preview-buffer)))
179 (setq gnus-article-display-hook tm-gnus/original-article-display-hook)
180 (setq gnus-show-mime t)
191 (set-alist 'mime/message-sender-alist
193 (function gnus-inews-news))