4
|
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:
|
74
|
8 ;; $Id: gnus-charset.el,v 1.1.1.2 1996/12/21 20:50:47 steve Exp $
|
4
|
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 ()
|
74
|
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 ; for jam-code-guess
|
|
92 (if (memq 'jam-code-guess-after-insert-file-function
|
|
93 after-insert-file-functions)
|
|
94 '(jam-code-guess-after-insert-file-function))))
|
|
95 (apply 'find-file-noselect args)))
|
4
|
96 )
|
74
|
97 ;; Red Gnus 0.67 or later
|
|
98 (defun nnheader-insert-file-contents
|
4
|
99 (filename &optional visit beg end replace)
|
|
100 (as-binary-input-file
|
74
|
101 (let ((format-alist nil)
|
|
102 (auto-mode-alist (nnheader-auto-mode-alist))
|
|
103 (default-major-mode 'fundamental-mode)
|
|
104 (enable-local-variables nil)
|
|
105 (after-insert-file-functions ; for jam-code-guess
|
|
106 (if (memq 'jam-code-guess-after-insert-file-function
|
|
107 after-insert-file-functions)
|
|
108 '(jam-code-guess-after-insert-file-function))))
|
|
109 (insert-file-contents filename visit beg end replace))
|
|
110 ))
|
|
111 ;; imported from Red Gnus 0.66
|
|
112 (or (fboundp 'nnheader-auto-mode-alist)
|
|
113 (defun nnheader-auto-mode-alist ()
|
|
114 (let ((alist auto-mode-alist)
|
|
115 out)
|
|
116 (while alist
|
|
117 (when (listp (cdar alist))
|
|
118 (push (car alist) out))
|
|
119 (pop alist))
|
|
120 (nreverse out)))
|
|
121 )
|
|
122 ;; alias for Old Gnus
|
|
123 (defalias 'nnheader-insert-file-contents-literally
|
|
124 'nnheader-insert-file-contents)
|
4
|
125 ))
|
|
126 (call-after-loaded
|
|
127 'nnmail
|
|
128 (lambda ()
|
|
129 (defun nnmail-find-file (file)
|
|
130 "Insert FILE in server buffer safely. [gnus-charset.el]"
|
|
131 (set-buffer nntp-server-buffer)
|
|
132 (erase-buffer)
|
|
133 (let ((format-alist nil)
|
|
134 (after-insert-file-functions ; for jam-code-guess
|
|
135 (if (memq 'jam-code-guess-after-insert-file-function
|
|
136 after-insert-file-functions)
|
|
137 '(jam-code-guess-after-insert-file-function)))
|
|
138 )
|
|
139 (as-binary-input-file
|
|
140 (condition-case ()
|
|
141 (progn (insert-file-contents file) t)
|
|
142 (file-error nil))
|
|
143 )))
|
|
144 ))
|
|
145 (defun gnus-prepare-save-mail-function ()
|
|
146 (setq file-coding-system *noconv*
|
70
|
147 coding-system-for-write 'no-conversion)
|
4
|
148 )
|
|
149 (add-hook 'nnmail-prepare-save-mail-hook
|
|
150 'gnus-prepare-save-mail-function)
|
|
151
|
|
152 (gnus-set-newsgroup-default-charset "alt.chinese" 'hz-gb-2312)
|
|
153 (gnus-set-newsgroup-default-charset "alt.chinese.text.big5" 'cn-big5)
|
|
154 (gnus-set-newsgroup-default-charset "fj" 'iso-2022-jp-2)
|
|
155 (gnus-set-newsgroup-default-charset "han" 'euc-kr)
|
|
156 (gnus-set-newsgroup-default-charset "hk" 'cn-big5)
|
|
157 (gnus-set-newsgroup-default-charset "hkstar" 'cn-big5)
|
|
158 (gnus-set-newsgroup-default-charset "relcom" 'koi8-r)
|
|
159 (gnus-set-newsgroup-default-charset "tw" 'cn-big5)
|
|
160 ))
|
|
161
|
|
162
|
|
163 ;;; @ end
|
|
164 ;;;
|
|
165
|
|
166 (provide 'gnus-charset)
|
|
167
|
|
168 ;;; gnus-charset.el ends here
|