2 ;;; tm-dgnus.el --- tm-gnus module for (ding) GNUS
12 (defconst tm-gnus/RCS-ID
13 "$Id: tm-dgnus.el,v 6.16 1995/08/30 02:44:11 morioka Exp $")
15 (defconst tm-gnus/version
16 (concat (get-version-string tm-gnus/RCS-ID) " (ding)"))
18 (defconst tm-gnus/automatic-MIME-preview-support
19 (cond ((boundp 'gnus-clean-article-buffer)
20 (defconst gnus-version (concat gnus-version " with tm patch"))
23 (defvar gnus-clean-article-buffer gnus-article-buffer)
27 (defvar tm-gnus/preview-buffer
28 (if tm-gnus/automatic-MIME-preview-support
29 (concat "*Preview-" gnus-clean-article-buffer "*"))
36 (autoload 'mime/viewer-mode "tm-view" "View MIME message." t)
37 (autoload 'mime/decode-message-header
38 "tiny-mime" "Decode MIME encoded-word." t)
39 (autoload 'mime/decode-string "tiny-mime" "Decode MIME encoded-word." t)
45 (defvar tm-gnus/original-article-display-hook gnus-article-display-hook)
47 (defvar tm-gnus/decode-all tm-gnus/automatic-MIME-preview-support
49 tm-gnus/automatic-MIME-preview-support is non-nil,
50 article is automatic MIME decoded.")
53 ;;; @ command functions
56 (defun tm-gnus/view-message (arg)
57 "MIME decode and play this message."
59 (let ((gnus-break-pages nil))
60 (gnus-summary-select-article t t)
62 (pop-to-buffer gnus-clean-article-buffer t)
63 (let (buffer-read-only)
64 (if (text-property-any (point-min) (point-max) 'invisible t)
65 (remove-text-properties (point-min) (point-max)
66 gnus-hidden-properties)
71 (defun tm-gnus/summary-scroll-down ()
72 "Scroll down one line current article."
74 (gnus-summary-scroll-up -1)
77 (define-key gnus-summary-mode-map "v" (function tm-gnus/view-message))
78 (define-key gnus-summary-mode-map
79 "\e\r" (function tm-gnus/summary-scroll-down))
85 (defun tm-gnus/decode-summary-from-and-subjects ()
90 (mime/decode-string (or (header-from header) ""))
94 (mime/decode-string (or (header-subject header) ""))
97 gnus-newsgroup-headers)
100 (add-hook 'gnus-select-group-hook
101 (function tm-gnus/decode-summary-from-and-subjects))
107 (setq gnus-show-mime-method
110 (let (buffer-read-only)
111 (mime/decode-message-header)
115 ;;; @ automatic MIME preview support
118 (defun tm-gnus/summary-toggle-header (&optional arg)
120 (if tm-gnus/decode-all
121 (let ((mime-viewer/ignored-field-list
122 (if (save-window-excursion
123 (switch-to-buffer tm-gnus/preview-buffer)
124 (goto-char (point-min))
125 (message/get-field-body
126 (car mime-viewer/ignored-field-list)
128 mime-viewer/ignored-field-list)
130 (gnus-summary-select-article t t)
132 (gnus-summary-toggle-header arg)
135 (defun tm-gnus/set-mime-method (mode)
138 (setq gnus-show-mime nil)
139 (setq gnus-article-display-hook
140 (list (function (lambda ()
142 (gnus-set-mode-line 'article)
144 (set-alist 'gnus-window-to-buffer 'article tm-gnus/preview-buffer)
145 (setq gnus-article-buffer tm-gnus/preview-buffer)
147 (setq gnus-show-mime t)
148 (setq gnus-article-display-hook tm-gnus/original-article-display-hook)
149 (set-alist 'gnus-window-to-buffer 'article gnus-clean-article-buffer)
150 (setq gnus-article-buffer gnus-clean-article-buffer)
153 (defun tm-gnus/toggle-mime (arg)
154 "Toggle MIME processing mode.
155 With arg, turn MIME processing on if arg is positive."
157 (setq tm-gnus/decode-all
159 (not tm-gnus/decode-all)
161 (gnus-set-global-variables)
162 (tm-gnus/set-mime-method tm-gnus/decode-all)
163 (gnus-summary-select-article gnus-show-all-headers 'force)
166 (if tm-gnus/automatic-MIME-preview-support
168 (define-key gnus-summary-mode-map
169 "t" (function tm-gnus/summary-toggle-header))
170 (define-key gnus-summary-mode-map "\et" (function tm-gnus/toggle-mime))
172 (tm-gnus/set-mime-method tm-gnus/decode-all)
174 (add-hook 'gnus-exit-gnus-hook
177 (let ((buf (get-buffer tm-gnus/preview-buffer)))
182 (setq gnus-article-display-hook tm-gnus/original-article-display-hook)
183 (setq gnus-show-mime t)
194 (set-alist 'mime/message-sender-alist
196 (function gnus-inews-news))