tm 7.76.
[elisp/tm.git] / gnus / gnus-charset.el
1 ;;;
2 ;;; gnus-charset.el --- MIME charset extension for Gnus
3 ;;;
4 ;;; Copyright (C) 1995 Free Software Foundation, Inc.
5 ;;; Copyright (C) 1995,1996 MORIOKA Tomohiko
6 ;;;
7 ;;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
8 ;;; Created: 1996/8/6
9 ;;; Version:
10 ;;;     $Id: gnus-charset.el,v 0.1 1996/08/06 12:07:28 morioka Exp $
11 ;;; Keywords: news, MIME, multimedia, multilingual, encoded-word
12 ;;;
13 ;;; This file is not part of GNU Emacs yet.
14 ;;;
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.
19 ;;;
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.
24 ;;;
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.
28 ;;;
29 ;;; Code:
30
31 (defvar running-xemacs (string-match "XEmacs" emacs-version))
32 (defvar running-xemacs-20 (and running-xemacs
33                                (= emacs-major-version 20)))
34
35
36 ;;; @ newsgroup default charset
37 ;;;
38
39 (defvar gnus-newsgroup-default-charset-alist nil)
40
41 (defun gnus-set-newsgroup-default-charset (newsgroup charset)
42   "Set CHARSET for the NEWSGROUP as default MIME charset."
43   (set-alist 'gnus-newsgroup-default-charset-alist
44              (concat "^" (regexp-quote newsgroup) "\\($\\|\\.\\)")
45              charset))
46
47
48 ;;; @ for mule (Multilingual support)
49 ;;;
50
51 (cond
52  ((featurep 'mule)
53   (cond ((boundp 'MULE) ; for MULE 1.* and 2.*.
54          (defun gnus-set-nntp-coding-system ()
55            (define-service-coding-system gnus-nntp-service nil *noconv*)
56            )
57          (add-hook 'gnus-open-server-hook 'gnus-set-nntp-coding-system)
58          )
59         (running-xemacs-20
60          (or (boundp '*noconv*)
61              (defconst *noconv* 'noconv)
62              )))
63   (call-after-loaded
64    'nnheader
65    (lambda ()
66      (defun nnheader-find-file-noselect (filename &optional nowarn rawfile)
67        (let ((file-coding-system-for-read *noconv*))
68          (find-file-noselect filename nowarn rawfile)
69          ))
70      (defun nnheader-insert-file-contents-literally
71        (filename &optional visit beg end replace)
72        (let ((file-coding-system-for-read *noconv*))
73          (insert-file-contents-literally filename visit beg end replace)
74          ))
75      ))
76   (call-after-loaded
77    'nnmail
78    (lambda ()
79      (defun nnmail-find-file (file)
80        "Insert FILE in server buffer safely. [tm-gnus5.el]"
81        (set-buffer nntp-server-buffer)
82        (erase-buffer)
83        (let ((format-alist nil)
84              (after-insert-file-functions   ; for jam-code-guess
85               (if (memq 'jam-code-guess-after-insert-file-function
86                         after-insert-file-functions)
87                   '(jam-code-guess-after-insert-file-function)))
88              (file-coding-system-for-read *noconv*))
89          (condition-case ()
90              (progn (insert-file-contents file) t)
91            (file-error nil))))
92      ))
93   (defun gnus-prepare-save-mail-function ()
94     (setq file-coding-system *noconv*)
95     )
96   (add-hook 'nnmail-prepare-save-mail-hook
97             'gnus-prepare-save-mail-function)
98   
99   (gnus-set-newsgroup-default-charset "alt.chinese"             'hz)
100   (gnus-set-newsgroup-default-charset "alt.chinese.text.big5"   'big5)
101   (gnus-set-newsgroup-default-charset "tw"                      'big5)
102   (gnus-set-newsgroup-default-charset "hk"                      'big5)
103   (gnus-set-newsgroup-default-charset "hkstar"                  'big5)
104   (gnus-set-newsgroup-default-charset "han"                     'euc-kr)
105   (gnus-set-newsgroup-default-charset "relcom"                  'koi8-r)
106   ))
107
108
109 ;;; @ end
110 ;;;
111
112 (provide 'gnus-charset)
113
114 ;;; gnus-charset.el ends here