2 ;;; tm-sgnus.el --- tm-gnus module for September Gnus
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1995,1996 MORIOKA Tomohiko
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; Maintainer: MORIOKA Tomohiko <morioka@jaist.ac.jp>
9 ;;; Created: 1995/09/24
10 ;;; Version: $Revision: 7.54 $
11 ;;; Keywords: news, MIME, multimedia, multilingual, encoded-word
13 ;;; This file is part of tm (Tools for MIME).
15 ;;; This program is free software; you can redistribute it and/or
16 ;;; modify it under the terms of the GNU General Public License as
17 ;;; published by the Free Software Foundation; either version 2, or
18 ;;; (at your option) any later version.
20 ;;; This program is distributed in the hope that it will be useful,
21 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23 ;;; General Public License for more details.
25 ;;; You should have received a copy of the GNU General Public License
26 ;;; along with This program. If not, write to the Free Software
27 ;;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
37 (eval-when-compile (require 'cl))
43 (defconst tm-gnus/RCS-ID
44 "$Id: tm-sgnus.el,v 7.54 1996/04/29 01:55:32 morioka Exp $")
46 (defconst tm-gnus/version
47 (concat (get-version-string tm-gnus/RCS-ID) " for September"))
53 (defvar tm-gnus/automatic-mime-preview t
54 "*If non-nil, show MIME processed article.
55 This variable is set to `gnus-show-mime'.")
57 (setq gnus-show-mime tm-gnus/automatic-mime-preview)
60 ;;; @ command functions
63 (defun tm-gnus/view-message (arg)
64 "MIME decode and play this message."
66 (let ((gnus-break-pages nil))
67 (gnus-summary-select-article t t)
69 (pop-to-buffer gnus-original-article-buffer t)
70 (let (buffer-read-only)
71 (if (text-property-any (point-min) (point-max) 'invisible t)
72 (remove-text-properties (point-min) (point-max)
73 gnus-hidden-properties)
75 (mime/viewer-mode nil nil nil gnus-original-article-buffer
79 (defun tm-gnus/summary-scroll-down ()
80 "Scroll down one line current article."
82 (gnus-summary-scroll-up -1)
85 (defun tm-gnus/summary-toggle-header (&optional arg)
87 (if tm-gnus/automatic-mime-preview
90 (set-buffer gnus-article-buffer)
92 (goto-char (point-min)) (search-forward "\n\n")
95 (mime-viewer/redisplay t)
97 (gnus-summary-select-article hidden t)
99 (gnus-summary-toggle-header arg))
102 (define-key gnus-summary-mode-map "v" (function tm-gnus/view-message))
103 (define-key gnus-summary-mode-map
104 "\e\r" (function tm-gnus/summary-scroll-down))
105 (substitute-key-definition
106 'gnus-summary-toggle-header
107 'tm-gnus/summary-toggle-header gnus-summary-mode-map)
113 (defun tm-gnus/content-header-filter ()
114 (goto-char (point-min))
115 (mime-preview/cut-header)
116 (tm-gnus/code-convert-region-to-emacs (point-min)(point-max)
117 mime/default-coding-system)
118 (mime/decode-message-header)
121 (set-alist 'mime-viewer/content-header-filter-alist
122 'gnus-original-article-mode
123 (function tm-gnus/content-header-filter))
125 (fset 'tm-gnus/code-convert-region-to-emacs
126 (symbol-function 'mime/code-convert-region-to-emacs))
128 (set-alist 'mime-viewer/code-converter-alist
129 'gnus-original-article-mode
130 (function tm-gnus/code-convert-region-to-emacs))
132 (defun mime-viewer/quitting-method-for-sgnus ()
133 (if (not gnus-show-mime)
134 (mime-viewer/kill-buffer))
135 (delete-other-windows)
136 (gnus-article-show-summary)
137 (if (or (not gnus-show-mime)
138 (null gnus-have-all-headers))
139 (gnus-summary-select-article nil t)
145 (set-alist 'mime-viewer/quitting-method-alist
146 'gnus-original-article-mode
147 (function mime-viewer/quitting-method-for-sgnus))
148 (set-alist 'mime-viewer/show-summary-method
149 'gnus-original-article-mode
150 (function mime-viewer/quitting-method-for-sgnus))
157 (defun tm-gnus/partial-preview-function ()
158 (tm-gnus/view-message (gnus-summary-article-number))
164 (set-atype 'mime/content-decoding-condition
165 '((type . "message/partial")
166 (method . mime-article/grab-message/partials)
167 (major-mode . gnus-original-article-mode)
168 (summary-buffer-exp . gnus-summary-buffer)
170 (set-alist 'tm-partial/preview-article-method-alist
171 'gnus-original-article-mode
172 'tm-gnus/partial-preview-function)
179 (defun tm-gnus/article-reset-variable ()
180 (setq tm-gnus/automatic-mime-preview nil)
183 (add-hook 'gnus-article-prepare-hook 'tm-gnus/article-reset-variable)
185 (defun tm-gnus/preview-article ()
186 (make-local-variable 'tm:mother-button-dispatcher)
187 (setq tm:mother-button-dispatcher
188 (function gnus-article-push-button))
189 (let ((mime-viewer/ignored-field-regexp "^:$")
190 (mime/default-coding-system
192 (set-buffer gnus-summary-buffer)
193 mime/default-coding-system)))
194 (mime/viewer-mode nil nil nil gnus-original-article-buffer
197 (setq tm-gnus/automatic-mime-preview t)
198 (run-hooks 'tm-gnus/article-prepare-hook)
201 (setq gnus-show-mime-method (function tm-gnus/preview-article))
203 (defun tm-gnus/article-decode-encoded-word ()
204 (decode-coding-region (point-min)(point-max)
206 (set-buffer gnus-summary-buffer)
207 mime/default-coding-system))
208 (mime/decode-message-header)
209 (run-hooks 'tm-gnus/article-prepare-hook)
212 (setq gnus-decode-encoded-word-method
213 (function tm-gnus/article-decode-encoded-word))
215 ;; (if (boundp 'MULE)
217 ;; (define-service-coding-system gnus-nntp-service nil *noconv*)
218 ;; (if (and (boundp 'nntp-server-process)
219 ;; (processp nntp-server-process)
221 ;; (set-process-coding-system nntp-server-process *noconv* *noconv*)
224 ;; (or (fboundp 'tm-gnus/original-request-article)
225 ;; (fset 'tm-gnus/original-request-article
226 ;; (symbol-function 'gnus-request-article))
229 ;; (defun gnus-request-article (article group &optional buffer)
230 ;; (let ((file-coding-system-for-read *noconv*))
231 ;; (tm-gnus/original-request-article article group buffer)
234 ;; (defun tm-gnus/nnheader-find-file-noselect (&rest args)
235 ;; (let ((file-coding-system-for-read *noconv*))
236 ;; (apply (function find-file-noselect) args)
240 ;; '(fset 'nnheader-find-file-noselect
241 ;; 'tm-gnus/nnheader-find-file-noselect)
244 ;; (defun tm-gnus/nnmail-get-new-mail (&rest args)
245 ;; (let ((file-coding-system-for-read *noconv*))
246 ;; (apply (function tm-gnus/original-nnmail-get-new-mail) args)
250 ;; '(progn (or (fboundp 'tm-gnus/original-nnmail-get-new-mail)
251 ;; (fset 'tm-gnus/original-nnmail-get-new-mail
252 ;; (symbol-function 'nnmail-get-new-mail))
254 ;; (fset 'nnmail-get-new-mail 'tm-gnus/nnmail-get-new-mail)
262 (defvar gnus-newsgroup-default-coding-system-alist nil)
264 (defun gnus-set-newsgroup-default-coding-system (ng cs)
265 "Define CS as default coding system for newsgroup NG."
266 (set-alist 'gnus-newsgroup-default-coding-system-alist
267 (concat "^" (regexp-quote ng) "\\($\\|\\.\\)")
272 (define-service-coding-system gnus-nntp-service nil *noconv*)
273 (if (and (boundp 'nntp-server-process)
274 (processp nntp-server-process)
276 (set-process-coding-system nntp-server-process *noconv* *noconv*)
281 (defun nnheader-find-file-noselect (filename &optional nowarn rawfile)
282 (let ((file-coding-system-for-read '*noconv*))
283 (find-file-noselect filename nowarn rawfile)
285 (defun nnheader-insert-raw-file-contents
286 (filename &optional visit beg end replace)
287 (let ((file-coding-system-for-read '*noconv*))
288 (insert-file-contents filename visit beg end replace)
290 ;;(fset 'nnheader-raw-write-region 'si:write-region)
292 (defun tm-gnus/prepare-save-mail-function ()
293 (setq file-coding-system *noconv*)
295 (add-hook 'nnmail-prepare-save-mail-hook
296 'tm-gnus/prepare-save-mail-function)
297 ;; (add-hook 'nnmbox-prepare-save-mail-hook
298 ;; 'tm-gnus/prepare-save-mail-function)
299 ;; (add-hook 'nnbabyl-prepare-save-mail-hook
300 ;; 'tm-gnus/prepare-save-mail-function)
301 ;; (add-hook 'nnml-prepare-save-mail-hook
302 ;; 'tm-gnus/prepare-save-mail-function)
303 ;; (add-hook 'nnmh-prepare-save-mail-hook
304 ;; 'tm-gnus/prepare-save-mail-function)
305 ;; (add-hook 'nnfolder-prepare-save-mail-hook
306 ;; 'tm-gnus/prepare-save-mail-function)
308 (gnus-set-newsgroup-default-coding-system "alt.chinese.text" '*hz*)
309 (gnus-set-newsgroup-default-coding-system "alt.chinese.text.big5" '*big5*)
310 (gnus-set-newsgroup-default-coding-system "han" '*euc-kr*)
311 (gnus-set-newsgroup-default-coding-system "relcom" '*koi8*)
318 (defun tm-gnus/decode-summary-from-and-subjects ()
319 (let ((rest gnus-newsgroup-default-coding-system-alist)
322 (while (setq cell (car rest))
323 (if (string-match (car cell) gnus-newsgroup-name)
326 (make-local-variable 'mime/default-coding-system)
327 (setq mime/default-coding-system (cdr cell))
329 (setq rest (cdr rest))
333 (let ((from (or (mail-header-from header) ""))
334 (subj (or (mail-header-subject header) ""))
335 (method (car gnus-current-select-method))
337 (if (eq method 'nntp)
340 (decode-coding-string from mime/default-coding-system))
342 (decode-coding-string subj mime/default-coding-system))
344 (mail-header-set-from
345 header (mime-eword/decode-string from))
346 (mail-header-set-subject
347 header (mime-eword/decode-string subj))
349 gnus-newsgroup-headers))
351 (or (boundp 'nnheader-encoded-words-decoding)
352 (add-hook 'gnus-select-group-hook
353 #'tm-gnus/decode-summary-from-and-subjects)
366 (autoload 'tm-bbdb/update-record "tm-bbdb")
368 (defun tm-gnus/bbdb-setup ()
369 (if (memq 'bbdb/gnus-update-record gnus-article-prepare-hook)
371 (remove-hook 'gnus-article-prepare-hook 'bbdb/gnus-update-record)
372 (add-hook 'gnus-article-display-hook 'tm-bbdb/update-record)
375 (add-hook 'gnus-startup-hook 'tm-gnus/bbdb-setup t)
385 ;;; tm-sgnus.el ends here