This commit was generated by cvs2svn to compensate for changes in r542,
[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.6 1996/08/22 17:51:22 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; see the file COPYING.  If not, write to
25 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
27
28 ;;; Code:
29
30 (require 'gnus)
31
32
33 ;;; @ newsgroup default charset
34 ;;;
35
36 (defvar gnus-newsgroup-default-charset-alist nil)
37
38 (defun gnus-set-newsgroup-default-charset (newsgroup charset)
39   "Set CHARSET for the NEWSGROUP as default MIME charset."
40   (let* ((ng-regexp (concat "^" (regexp-quote newsgroup) "\\($\\|\\.\\)"))
41          (pair (assoc ng-regexp gnus-newsgroup-default-charset-alist))
42          )
43     (if pair
44         (setcdr pair charset)
45       (setq gnus-newsgroup-default-charset-alist
46             (cons (cons ng-regexp charset)
47                   gnus-newsgroup-default-charset-alist))
48       )))
49
50
51 ;;; @ for mule (Multilingual support)
52 ;;;
53
54 (cond
55  ((featurep 'mule)
56   (require 'emu)
57   (defvar nntp-open-binary-connection-function
58     (if (featurep 'gnus-load)
59         ;; maybe Red Gnus
60         (if (boundp 'nntp-open-connection-function)
61             nntp-open-connection-function
62           'nntp-open-network-stream)
63       ;; maybe Gnus 5.[01] or Gnus 5.[23]
64       (if (boundp 'nntp-open-server-function)
65           nntp-open-server-function
66         'nntp-open-network-stream)
67       ))
68   (defun nntp-open-network-stream-with-no-code-conversion (&rest args)
69     (let ((proc (apply nntp-open-binary-connection-function args)))
70       (set-process-input-coding-system proc *noconv*)
71       proc))
72   (if (featurep 'gnus-load)
73       (setq nntp-open-connection-function
74             'nntp-open-network-stream-with-no-code-conversion)
75     (setq nntp-open-server-function
76           'nntp-open-network-stream-with-no-code-conversion)
77     )
78   (call-after-loaded
79    'nnheader
80    (lambda ()
81      (defun nnheader-find-file-noselect (filename &optional nowarn rawfile)
82        (let ((file-coding-system-for-read *noconv*))
83          (find-file-noselect filename nowarn rawfile)
84          ))
85      (defun nnheader-insert-file-contents-literally
86        (filename &optional visit beg end replace)
87        (let ((file-coding-system-for-read *noconv*))
88          (insert-file-contents-literally filename visit beg end replace)
89          ))
90      ))
91   (call-after-loaded
92    'nnmail
93    (lambda ()
94      (defun nnmail-find-file (file)
95        "Insert FILE in server buffer safely. [gnus-charset.el]"
96        (set-buffer nntp-server-buffer)
97        (erase-buffer)
98        (let ((format-alist nil)
99              (after-insert-file-functions   ; for jam-code-guess
100               (if (memq 'jam-code-guess-after-insert-file-function
101                         after-insert-file-functions)
102                   '(jam-code-guess-after-insert-file-function)))
103              (file-coding-system-for-read *noconv*))
104          (condition-case ()
105              (progn (insert-file-contents file) t)
106            (file-error nil))))
107      ))
108   (defun gnus-prepare-save-mail-function ()
109     (setq file-coding-system *noconv*)
110     )
111   (add-hook 'nnmail-prepare-save-mail-hook
112             'gnus-prepare-save-mail-function)
113   
114   (gnus-set-newsgroup-default-charset "alt.chinese"             'hz)
115   (gnus-set-newsgroup-default-charset "alt.chinese.text.big5"   'big5)
116   (gnus-set-newsgroup-default-charset "tw"                      'big5)
117   (gnus-set-newsgroup-default-charset "hk"                      'big5)
118   (gnus-set-newsgroup-default-charset "hkstar"                  'big5)
119   (gnus-set-newsgroup-default-charset "han"                     'euc-kr)
120   (gnus-set-newsgroup-default-charset "relcom"                  'koi8-r)
121   ))
122
123
124 ;;; @ end
125 ;;;
126
127 (provide 'gnus-charset)
128
129 ;;; gnus-charset.el ends here