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:
|
70
|
8 ;; $Id: gnus-charset.el,v 1.1.1.1 1996/12/18 22:43:38 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 ()
|
70
|
86 (defun nnheader-find-file-noselect (filename &optional nowarn rawfile)
|
|
87 (as-binary-input-file (find-file-noselect filename nowarn rawfile))
|
4
|
88 )
|
70
|
89 (defun nnheader-insert-file-contents-literally
|
4
|
90 (filename &optional visit beg end replace)
|
|
91 (as-binary-input-file
|
70
|
92 (insert-file-contents-literally filename visit beg end replace)
|
|
93 ))
|
4
|
94 ))
|
|
95 (call-after-loaded
|
|
96 'nnmail
|
|
97 (lambda ()
|
|
98 (defun nnmail-find-file (file)
|
|
99 "Insert FILE in server buffer safely. [gnus-charset.el]"
|
|
100 (set-buffer nntp-server-buffer)
|
|
101 (erase-buffer)
|
|
102 (let ((format-alist nil)
|
|
103 (after-insert-file-functions ; for jam-code-guess
|
|
104 (if (memq 'jam-code-guess-after-insert-file-function
|
|
105 after-insert-file-functions)
|
|
106 '(jam-code-guess-after-insert-file-function)))
|
|
107 )
|
|
108 (as-binary-input-file
|
|
109 (condition-case ()
|
|
110 (progn (insert-file-contents file) t)
|
|
111 (file-error nil))
|
|
112 )))
|
|
113 ))
|
|
114 (defun gnus-prepare-save-mail-function ()
|
|
115 (setq file-coding-system *noconv*
|
70
|
116 coding-system-for-write 'no-conversion)
|
4
|
117 )
|
|
118 (add-hook 'nnmail-prepare-save-mail-hook
|
|
119 'gnus-prepare-save-mail-function)
|
|
120
|
|
121 (gnus-set-newsgroup-default-charset "alt.chinese" 'hz-gb-2312)
|
|
122 (gnus-set-newsgroup-default-charset "alt.chinese.text.big5" 'cn-big5)
|
|
123 (gnus-set-newsgroup-default-charset "fj" 'iso-2022-jp-2)
|
|
124 (gnus-set-newsgroup-default-charset "han" 'euc-kr)
|
|
125 (gnus-set-newsgroup-default-charset "hk" 'cn-big5)
|
|
126 (gnus-set-newsgroup-default-charset "hkstar" 'cn-big5)
|
|
127 (gnus-set-newsgroup-default-charset "relcom" 'koi8-r)
|
|
128 (gnus-set-newsgroup-default-charset "tw" 'cn-big5)
|
|
129 ))
|
|
130
|
|
131
|
|
132 ;;; @ end
|
|
133 ;;;
|
|
134
|
|
135 (provide 'gnus-charset)
|
|
136
|
|
137 ;;; gnus-charset.el ends here
|