This commit was generated by cvs2svn to compensate for changes in r5912,
[elisp/gnus.git-] / lisp / gnus-i18n.el
1 ;;; gnus-i18n.el --- Internationalization for Gnus
2
3 ;; Copyright (C) 1996,1997 Free Software Foundation, Inc.
4
5 ;; Author: MORIOKA Tomohiko <morioka@jaist.ac.jp>
6 ;; Created: 1997/11/27
7 ;; Keywords: internationalization, news, mail
8
9 ;; This file is not part of GNU Emacs yet.
10
11 ;; This program is free software; you can redistribute it and/or
12 ;; modify it under the terms of the GNU General Public License as
13 ;; published by the Free Software Foundation; either version 2, or (at
14 ;; your option) any later version.
15
16 ;; This program is distributed in the hope that it will be useful, but
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19 ;; General Public License for more details.
20
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs; see the file COPYING.  If not, write to the
23 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
24 ;; Boston, MA 02111-1307, USA.
25
26 ;;; Code:
27
28 ;;; @ newsgroup default charset
29 ;;;
30
31 (defvar gnus-newsgroup-default-charset-alist
32   '(("^\\(fj\\|tnn\\|japan\\)\\."       . iso-2022-jp-2)
33     ("^han\\."                          . euc-kr)
34     ("^relcom\\."                       . koi8-r)
35     ("^alt\\.chinese\\.text\\.big5"     . cn-big5)
36     ("^hk\\(star\\)?\\."                . cn-big5)
37     ("^tw\\."                           . cn-big5)
38     ("^alt\\.chinese"                   . hz-gb-2312)
39     )
40   "Alist of newsgroup patterns vs. corresponding default MIME charset.
41 Each element looks like (REGEXP . SYMBOL).  REGEXP is pattern for
42 newsgroup name.  SYMBOL is MIME charset or coding-system.")
43
44 (defun gnus-set-newsgroup-default-charset (newsgroup charset)
45   "Set CHARSET for the NEWSGROUP as default MIME charset."
46   (let* ((ng-regexp (concat "^" (regexp-quote newsgroup) "\\($\\|\\.\\)"))
47          (pair (assoc ng-regexp gnus-newsgroup-default-charset-alist))
48          )
49     (if pair
50         (setcdr pair charset)
51       (setq gnus-newsgroup-default-charset-alist
52             (cons (cons ng-regexp charset)
53                   gnus-newsgroup-default-charset-alist))
54       )))
55
56
57 ;;; @ localization
58 ;;;
59
60 (defun gnus-set-summary-default-charset ()
61   "Set up `default-mime-charset' of summary buffer.
62 It is specified by variable `gnus-newsgroup-default-charset-alist'
63 \(cf. function `gnus-set-newsgroup-default-charset')."
64   (if (buffer-live-p gnus-summary-buffer)
65       (let ((charset
66              (catch 'found
67                (let ((group
68                       (save-excursion
69                         (set-buffer gnus-summary-buffer)
70                         gnus-newsgroup-name))
71                      (alist gnus-newsgroup-default-charset-alist))
72                  (while alist
73                    (let ((pair (car alist)))
74                      (if (string-match (car pair) group)
75                          (throw 'found (cdr pair))
76                        ))
77                    (setq alist (cdr alist)))
78                  ))))
79         (if charset
80             (progn
81               (save-excursion
82                 (set-buffer gnus-summary-buffer)
83                 (make-local-variable 'default-mime-charset)
84                 (setq default-mime-charset charset))
85               (make-local-variable 'default-mime-charset)
86               (setq default-mime-charset charset))
87           (kill-local-variable 'default-mime-charset)))))
88
89
90 ;;; @ end
91 ;;;
92
93 (provide 'gnus-i18n)
94
95 ;;; gnus-i18n.el ends here