2 ;;; tm-dgnus.el --- tm-gnus module for (ding) GNUS
12 (defconst tm-gnus/RCS-ID
13 "$Id: tm-dgnus.el,v 6.9 1995/07/03 07:50:58 morioka Exp $")
15 (defconst tm-gnus/version
16 (concat (get-version-string tm-gnus/RCS-ID) " (ding)"))
22 (autoload 'mime/viewer-mode "tm-view" "View MIME message." t)
23 (autoload 'mime/decode-message-header
24 "tiny-mime" "Decode MIME encoded-word." t)
25 (autoload 'mime/decode-string "tiny-mime" "Decode MIME encoded-word." t)
31 (defvar tm-gnus/original-article-display-hook gnus-article-display-hook)
33 (defvar tm-gnus/decode-all t)
35 (defvar tm-gnus/preview-buffer (concat "*Preview-" gnus-article-buffer "*"))
38 ;;; @ command functions
41 (defun tm-gnus/view-message (arg)
42 "MIME decode and play this message."
44 (let ((gnus-break-pages nil))
45 (gnus-summary-select-article t t)
47 (pop-to-buffer gnus-article-buffer t)
48 (let (buffer-read-only)
49 (if (text-property-any (point-min) (point-max) 'invisible t)
50 (remove-text-properties (point-min) (point-max)
51 gnus-hidden-properties)
56 (defun tm-gnus/summary-scroll-down ()
57 "Scroll down one line current article."
59 (gnus-summary-scroll-up -1)
62 (define-key gnus-summary-mode-map "v" (function tm-gnus/view-message))
63 (define-key gnus-summary-mode-map
64 "\e\r" (function tm-gnus/summary-scroll-down))
65 (define-key gnus-summary-mode-map "\et" (function tm-gnus/toggle-mime))
67 (defmacro gnus-get-article-buffer ()
68 (` (cdr (assq 'article gnus-window-to-buffer))))
70 ;; Set article window start at LINE, where LINE is the number of lines
71 ;; from the head of the article.
72 (defun gnus-article-set-window-start (&optional line)
73 (let ((article-buffer (gnus-get-article-buffer)))
75 (get-buffer-window article-buffer)
77 (set-buffer article-buffer)
78 (goto-char (point-min))
81 (gnus-message 6 "Moved to bookmark")
82 (search-forward "\n\n" nil t)
86 (defun gnus-summary-next-page (lines)
87 "Show next page of selected article.
88 If end of article, select next article.
89 Argument LINES specifies lines to be scrolled up."
91 (let ((article (gnus-summary-article-number))
93 (if (or (null gnus-current-article)
94 (/= article gnus-current-article))
95 ;; Selected subject is different from current article's.
96 (gnus-summary-display-article article)
97 (gnus-configure-windows 'article)
98 (pop-to-buffer gnus-summary-buffer)
99 (gnus-eval-in-buffer-window
100 (gnus-get-article-buffer)
101 (setq endp (gnus-article-next-page lines)))
102 (cond ((and endp lines)
103 (message "End of message"))
104 ((and endp (null lines))
105 (gnus-summary-next-unread-article)))
108 (defun gnus-summary-prev-page (lines)
109 "Show previous page of selected article.
110 Argument LINES specifies lines to be scrolled down."
112 (gnus-set-global-variables)
113 (let ((article (gnus-summary-article-number)))
114 (gnus-configure-windows 'article)
115 (if (or (null gnus-current-article)
116 (null gnus-article-current)
117 (/= article (cdr gnus-article-current))
118 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
119 ;; Selected subject is different from current article's.
120 (gnus-summary-display-article article)
121 (gnus-summary-recenter)
122 (gnus-eval-in-buffer-window
123 (gnus-get-article-buffer)
124 (gnus-article-prev-page lines))))
125 (gnus-summary-position-cursor))
127 (defun gnus-summary-scroll-up (lines)
128 "Scroll up (or down) one line current article.
129 Argument LINES specifies lines to be scrolled up (or down if negative)."
131 (gnus-set-global-variables)
132 (gnus-configure-windows 'article)
133 (or (gnus-summary-select-article nil nil 'pseudo)
134 (gnus-eval-in-buffer-window
135 (gnus-get-article-buffer)
137 (if (gnus-article-next-page lines)
138 (gnus-message 3 "End of message")))
140 (gnus-article-prev-page (- lines))))))
141 (gnus-summary-recenter)
142 (gnus-summary-position-cursor))
144 (defun gnus-summary-toggle-header (arg)
145 "Show the headers if they are hidden, or hide them if they are shown.
146 If ARG is a positive number, show the entire header.
147 If ARG is a negative number, hide the unwanted header lines."
149 (gnus-set-global-variables)
151 (set-buffer (gnus-get-article-buffer))
152 (let ((buffer-read-only nil))
154 (if (> arg 0) (remove-text-properties (point-min) (point-max)
155 gnus-hidden-properties)
156 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
157 (if (text-property-any (point-min) (point-max) 'invisible t)
158 (if tm-gnus/decode-all
159 (let (mime-viewer/ignored-field-list)
160 (run-hooks 'gnus-article-display-hook)
162 (remove-text-properties (point-min) (point-max)
163 gnus-hidden-properties)
165 (let (gnus-have-all-headers)
166 (run-hooks 'gnus-article-display-hook)
169 (pop-to-buffer gnus-summary-buffer)
170 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
176 (defun tm-gnus/decode-summary-from-and-subjects ()
181 (mime/decode-string (or (header-from header) ""))
185 (mime/decode-string (or (header-subject header) ""))
188 gnus-newsgroup-headers)
191 (add-hook 'gnus-select-group-hook
192 (function tm-gnus/decode-summary-from-and-subjects))
198 (setq gnus-show-mime-method
201 (let (buffer-read-only)
202 (mime/decode-message-header)
205 (defun tm-gnus/set-mime-method (mode)
208 (setq gnus-show-mime nil)
209 (setq gnus-article-display-hook
210 (list (function (lambda ()
212 (gnus-set-mode-line 'article)
213 (set-buffer-modified-p nil)
214 (pop-to-buffer mime::preview/article-buffer)
216 (set-alist 'gnus-window-to-buffer 'article tm-gnus/preview-buffer)
218 (setq gnus-show-mime t)
219 (setq gnus-article-display-hook tm-gnus/original-article-display-hook)
220 (set-alist 'gnus-window-to-buffer 'article gnus-article-buffer)
223 (tm-gnus/set-mime-method tm-gnus/decode-all)
225 (defun tm-gnus/toggle-mime (arg)
226 "Toggle MIME processing mode.
227 With arg, turn MIME processing on if arg is positive."
229 (setq tm-gnus/decode-all
231 (not tm-gnus/decode-all)
233 (gnus-set-global-variables)
234 (tm-gnus/set-mime-method tm-gnus/decode-all)
235 (gnus-summary-select-article gnus-show-all-headers 'force)
242 (add-hook 'gnus-exit-gnus-hook
245 (let ((buf (get-buffer tm-gnus/preview-buffer)))