2 ;;; tm-dgnus.el --- tm-gnus module for (ding) GNUS
7 (defconst tm-gnus/RCS-ID
8 "$Id: tm-dgnus.el,v 6.5 1995/06/22 05:34:56 morioka Exp $")
10 (defconst tm-gnus/version
11 (concat (get-version-string tm-gnus/RCS-ID) " (ding)"))
17 (autoload 'mime/viewer-mode "tm-view" "View MIME message." t)
18 (autoload 'mime/decode-message-header
19 "tiny-mime" "Decode MIME encoded-word." t)
20 (autoload 'mime/decode-string "tiny-mime" "Decode MIME encoded-word." t)
26 (defvar tm-gnus/original-article-display-hook gnus-article-display-hook)
28 (defvar tm-gnus/decode-all t)
30 (defvar tm-gnus/preview-buffer (concat "*Preview-" gnus-article-buffer "*"))
33 ;;; @ command functions
36 (defun tm-gnus/view-message (arg)
37 "MIME decode and play this message."
39 (let ((gnus-break-pages nil))
40 (gnus-summary-select-article t t)
42 (pop-to-buffer gnus-article-buffer t)
46 (defun tm-gnus/summary-scroll-down ()
47 "Scroll down one line current article."
49 (gnus-summary-scroll-up -1)
52 (define-key gnus-summary-mode-map "v" (function tm-gnus/view-message))
53 (define-key gnus-summary-mode-map
54 "\e\r" (function tm-gnus/summary-scroll-down))
55 (define-key gnus-summary-mode-map "\et" (function tm-gnus/toggle-mime))
58 (defun gnus-summary-next-page (lines)
59 "Show next page of selected article.
60 If end of article, select next article.
61 Argument LINES specifies lines to be scrolled up."
63 (let ((article (gnus-summary-article-number))
65 (if (or (null gnus-current-article)
66 (/= article gnus-current-article))
67 ;; Selected subject is different from current article's.
68 (gnus-summary-display-article article)
69 (gnus-configure-windows 'article)
70 (pop-to-buffer gnus-summary-buffer)
71 (gnus-eval-in-buffer-window (cdr (assq 'article gnus-window-to-buffer))
72 (setq endp (gnus-article-next-page lines)))
73 (cond ((and endp lines)
74 (message "End of message"))
75 ((and endp (null lines))
76 (gnus-summary-next-unread-article)))
79 (defun gnus-summary-scroll-up (lines)
80 "Scroll up (or down) one line current article.
81 Argument LINES specifies lines to be scrolled up (or down if negative)."
83 (gnus-set-global-variables)
84 (gnus-configure-windows 'article)
85 (or (gnus-summary-select-article nil nil 'pseudo)
86 (gnus-eval-in-buffer-window
87 (cdr (assq 'article gnus-window-to-buffer))
89 (if (gnus-article-next-page lines)
90 (gnus-message 3 "End of message")))
92 (gnus-article-prev-page (- lines))))))
93 (gnus-summary-recenter)
94 (gnus-summary-position-cursor))
96 (defun gnus-summary-prev-page (lines)
97 "Show previous page of selected article.
98 Argument LINES specifies lines to be scrolled down."
100 (gnus-set-global-variables)
101 (let ((article (gnus-summary-article-number)))
102 (gnus-configure-windows 'article)
103 (if (or (null gnus-current-article)
104 (null gnus-article-current)
105 (/= article (cdr gnus-article-current))
106 (not (equal (car gnus-article-current) gnus-newsgroup-name)))
107 ;; Selected subject is different from current article's.
108 (gnus-summary-display-article article)
109 (gnus-summary-recenter)
110 (gnus-eval-in-buffer-window
111 (cdr (assq 'article gnus-window-to-buffer))
112 (gnus-article-prev-page lines))))
113 (gnus-summary-position-cursor))
115 (defun gnus-summary-toggle-header (arg)
116 "Show the headers if they are hidden, or hide them if they are shown.
117 If ARG is a positive number, show the entire header.
118 If ARG is a negative number, hide the unwanted header lines."
120 (gnus-set-global-variables)
122 (set-buffer (cdr (assq 'article gnus-window-to-buffer)))
123 (let ((buffer-read-only nil))
125 (if (> arg 0) (remove-text-properties (point-min) (point-max)
126 gnus-hidden-properties)
127 (if (< arg 0) (run-hooks 'gnus-article-display-hook)))
128 (if (text-property-any (point-min) (point-max) 'invisible t)
129 (if tm-gnus/decode-all
130 (let (mime-viewer/ignored-field-list)
131 (run-hooks 'gnus-article-display-hook)
133 (remove-text-properties (point-min) (point-max)
134 gnus-hidden-properties)
136 (let (gnus-have-all-headers)
137 (run-hooks 'gnus-article-display-hook)
140 (pop-to-buffer gnus-summary-buffer)
141 (set-window-point (get-buffer-window (current-buffer)) (point-min)))))
144 ;; Set article window start at LINE, where LINE is the number of lines
145 ;; from the head of the article.
146 (defun gnus-article-set-window-start (&optional line)
147 (let ((article-buffer (cdr (assq 'article gnus-window-to-buffer))))
149 (get-buffer-window article-buffer)
151 (set-buffer article-buffer)
152 (goto-char (point-min))
155 (gnus-message 6 "Moved to bookmark")
156 (search-forward "\n\n" nil t)
164 (defun tm-gnus/decode-summary-from-and-subjects ()
169 (mime/decode-string (or (header-from header) ""))
173 (mime/decode-string (or (header-subject header) ""))
176 gnus-newsgroup-headers)
179 (add-hook 'gnus-select-group-hook
180 (function tm-gnus/decode-summary-from-and-subjects))
186 (setq gnus-show-mime-method
189 (let (buffer-read-only)
190 (mime/decode-message-header)
193 (defun tm-gnus/set-mime-method (mode)
196 (setq gnus-show-mime nil)
197 (setq gnus-article-display-hook
198 (list (function (lambda ()
200 (gnus-set-mode-line 'article)
201 (set-buffer-modified-p nil)
202 (pop-to-buffer mime::preview/article-buffer)
204 (set-alist 'gnus-window-to-buffer 'article tm-gnus/preview-buffer)
206 (setq gnus-show-mime t)
207 (setq gnus-article-display-hook tm-gnus/original-article-display-hook)
208 (set-alist 'gnus-window-to-buffer 'article gnus-article-buffer)
211 (tm-gnus/set-mime-method tm-gnus/decode-all)
213 (defun tm-gnus/toggle-mime (arg)
214 "Toggle MIME processing mode.
215 With arg, turn MIME processing on if arg is positive."
217 (setq tm-gnus/decode-all
219 (not tm-gnus/decode-all)
221 (gnus-set-global-variables)
222 (tm-gnus/set-mime-method tm-gnus/decode-all)
223 (gnus-summary-select-article gnus-show-all-headers 'force)
230 (add-hook 'gnus-exit-gnus-hook
233 (let ((buf (get-buffer tm-gnus/preview-buffer)))