comparison lisp/tm/gnus-charset.el @ 4:b82b59fe008d r19-15b3

Import from CVS: tag r19-15b3
author cvs
date Mon, 13 Aug 2007 08:46:56 +0200
parents
children 4b173ad71786
comparison
equal deleted inserted replaced
3:30df88044ec6 4:b82b59fe008d
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 1.1.1.1 1996/12/18 03:55:31 steve 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 GNU Emacs; see the file COPYING. If not, write to the
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26 ;; Boston, MA 02111-1307, USA.
27
28 ;;; Code:
29
30 (require 'gnus)
31
32 (defvar gnus-is-red-gnus-or-later
33 (or (featurep 'gnus-load)
34 (module-installed-p 'gnus-sum)
35 ))
36
37
38 ;;; @ newsgroup default charset
39 ;;;
40
41 (defvar gnus-newsgroup-default-charset-alist nil)
42
43 (defun gnus-set-newsgroup-default-charset (newsgroup charset)
44 "Set CHARSET for the NEWSGROUP as default MIME charset."
45 (let* ((ng-regexp (concat "^" (regexp-quote newsgroup) "\\($\\|\\.\\)"))
46 (pair (assoc ng-regexp gnus-newsgroup-default-charset-alist))
47 )
48 (if pair
49 (setcdr pair charset)
50 (setq gnus-newsgroup-default-charset-alist
51 (cons (cons ng-regexp charset)
52 gnus-newsgroup-default-charset-alist))
53 )))
54
55
56 ;;; @ for mule (Multilingual support)
57 ;;;
58
59 (cond
60 ((featurep 'mule)
61 (require 'emu)
62 (defvar nntp-open-binary-connection-function
63 (if gnus-is-red-gnus-or-later
64 ;; maybe Red Gnus
65 (if (boundp 'nntp-open-connection-function)
66 nntp-open-connection-function
67 'nntp-open-network-stream)
68 ;; maybe Gnus 5.[01] or Gnus 5.[23]
69 (if (boundp 'nntp-open-server-function)
70 nntp-open-server-function
71 'nntp-open-network-stream)
72 ))
73 (defun nntp-open-network-stream-with-no-code-conversion (&rest args)
74 (let ((proc (apply nntp-open-binary-connection-function args)))
75 (set-process-input-coding-system proc *noconv*)
76 proc))
77 (if gnus-is-red-gnus-or-later
78 (setq nntp-open-connection-function
79 'nntp-open-network-stream-with-no-code-conversion)
80 (setq nntp-open-server-function
81 'nntp-open-network-stream-with-no-code-conversion)
82 )
83 (call-after-loaded
84 'nnheader
85 (lambda ()
86 (defun nnheader-find-file-noselect (&rest args)
87 (as-binary-input-file
88 (let ((format-alist nil)
89 (auto-mode-alist (nnheader-auto-mode-alist))
90 (default-major-mode 'fundamental-mode)
91 (after-insert-file-functions nil))
92 (apply 'find-file-noselect args)))
93 )
94 ;; Red Gnus 0.67 or later
95 (defun nnheader-insert-file-contents
96 (filename &optional visit beg end replace)
97 (as-binary-input-file
98 (let ((format-alist nil)
99 (auto-mode-alist (nnheader-auto-mode-alist))
100 (default-major-mode 'fundamental-mode)
101 (after-insert-file-functions nil))
102 (insert-file-contents filename visit beg end replace))
103 ))
104 ;; alias for Old Gnus
105 (defalias 'nnheader-insert-file-contents-literally
106 'nnheader-insert-file-contents)
107 ))
108 (call-after-loaded
109 'nnmail
110 (lambda ()
111 (defun nnmail-find-file (file)
112 "Insert FILE in server buffer safely. [gnus-charset.el]"
113 (set-buffer nntp-server-buffer)
114 (erase-buffer)
115 (let ((format-alist nil)
116 (after-insert-file-functions ; for jam-code-guess
117 (if (memq 'jam-code-guess-after-insert-file-function
118 after-insert-file-functions)
119 '(jam-code-guess-after-insert-file-function)))
120 )
121 (as-binary-input-file
122 (condition-case ()
123 (progn (insert-file-contents file) t)
124 (file-error nil))
125 )))
126 ))
127 (defun gnus-prepare-save-mail-function ()
128 (setq file-coding-system *noconv*
129 coding-system-for-write 'no-conversion)
130 )
131 (add-hook 'nnmail-prepare-save-mail-hook
132 'gnus-prepare-save-mail-function)
133
134 (gnus-set-newsgroup-default-charset "alt.chinese" 'hz-gb-2312)
135 (gnus-set-newsgroup-default-charset "alt.chinese.text.big5" 'cn-big5)
136 (gnus-set-newsgroup-default-charset "fj" 'iso-2022-jp-2)
137 (gnus-set-newsgroup-default-charset "han" 'euc-kr)
138 (gnus-set-newsgroup-default-charset "hk" 'cn-big5)
139 (gnus-set-newsgroup-default-charset "hkstar" 'cn-big5)
140 (gnus-set-newsgroup-default-charset "relcom" 'koi8-r)
141 (gnus-set-newsgroup-default-charset "tw" 'cn-big5)
142 ))
143
144
145 ;;; @ end
146 ;;;
147
148 (provide 'gnus-charset)
149
150 ;;; gnus-charset.el ends here