561adc902d259fef58d32be11fa23b7280fbf131
[elisp/tm.git] / gnus / gnus-charset.el
1 ;;; gnus-charset.el --- MIME charset extension for Gnus
2
3 ;; Copyright (C) 1995,1996 Free Software Foundation, Inc.
4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Created: 1996/8/6
7 ;; Version:
8 ;;      $Id: gnus-charset.el,v 0.2 1996/08/12 09:06:54 morioka Exp $
9 ;; Keywords: news, MIME, multimedia, multilingual, encoded-word
10
11 ;; This file is not part of GNU Emacs yet.
12
13 ;; This program is free software; you can redistribute it and/or
14 ;; modify it under the terms of the GNU General Public License as
15 ;; published by the Free Software Foundation; either version 2, or (at
16 ;; your option) any later version.
17
18 ;; This program is distributed in the hope that it will be useful, but
19 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21 ;; General Public License for more details.
22
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with This program.  If not, write to the Free Software
25 ;; Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
26
27 ;;; Code:
28
29 (defvar running-xemacs (string-match "XEmacs" emacs-version))
30 (defvar running-xemacs-20 (and running-xemacs
31                                (= emacs-major-version 20)))
32
33
34 ;;; @ newsgroup default charset
35 ;;;
36
37 (defvar gnus-newsgroup-default-charset-alist nil)
38
39 (defun gnus-set-newsgroup-default-charset (newsgroup charset)
40   "Set CHARSET for the NEWSGROUP as default MIME charset."
41   (set-alist 'gnus-newsgroup-default-charset-alist
42              (concat "^" (regexp-quote newsgroup) "\\($\\|\\.\\)")
43              charset))
44
45
46 ;;; @ for mule (Multilingual support)
47 ;;;
48
49 (cond
50  ((featurep 'mule)
51   (cond ((boundp 'MULE) ; for MULE 1.* and 2.*.
52          (defun gnus-set-nntp-coding-system ()
53            (define-service-coding-system gnus-nntp-service nil *noconv*)
54            )
55          (add-hook 'gnus-open-server-hook 'gnus-set-nntp-coding-system)
56          )
57         (running-xemacs-20
58          (or (boundp '*noconv*)
59              (defconst *noconv* 'noconv)
60              )))
61   (call-after-loaded
62    'nnheader
63    (lambda ()
64      (defun nnheader-find-file-noselect (filename &optional nowarn rawfile)
65        (let ((file-coding-system-for-read *noconv*))
66          (find-file-noselect filename nowarn rawfile)
67          ))
68      (defun nnheader-insert-file-contents-literally
69        (filename &optional visit beg end replace)
70        (let ((file-coding-system-for-read *noconv*))
71          (insert-file-contents-literally filename visit beg end replace)
72          ))
73      ))
74   (call-after-loaded
75    'nnmail
76    (lambda ()
77      (defun nnmail-find-file (file)
78        "Insert FILE in server buffer safely. [tm-gnus5.el]"
79        (set-buffer nntp-server-buffer)
80        (erase-buffer)
81        (let ((format-alist nil)
82              (after-insert-file-functions   ; for jam-code-guess
83               (if (memq 'jam-code-guess-after-insert-file-function
84                         after-insert-file-functions)
85                   '(jam-code-guess-after-insert-file-function)))
86              (file-coding-system-for-read *noconv*))
87          (condition-case ()
88              (progn (insert-file-contents file) t)
89            (file-error nil))))
90      ))
91   (defun gnus-prepare-save-mail-function ()
92     (setq file-coding-system *noconv*)
93     )
94   (add-hook 'nnmail-prepare-save-mail-hook
95             'gnus-prepare-save-mail-function)
96   
97   (gnus-set-newsgroup-default-charset "alt.chinese"             'hz)
98   (gnus-set-newsgroup-default-charset "alt.chinese.text.big5"   'big5)
99   (gnus-set-newsgroup-default-charset "tw"                      'big5)
100   (gnus-set-newsgroup-default-charset "hk"                      'big5)
101   (gnus-set-newsgroup-default-charset "hkstar"                  'big5)
102   (gnus-set-newsgroup-default-charset "han"                     'euc-kr)
103   (gnus-set-newsgroup-default-charset "relcom"                  'koi8-r)
104   ))
105
106
107 ;;; @ end
108 ;;;
109
110 (provide 'gnus-charset)
111
112 ;;; gnus-charset.el ends here