Mercurial > emacs
comparison lisp/gnus/gnus-mule.el @ 19996:cb6f1cb0f072
Require nntp instead of gnus and message.
Set euc-kr for newsgroup "han". Delete code for add-hooking
gnus-mule-initialize and setting coding system for nntp.
Set default coding system for encoding to
iso-latin-1.
(gnus-mule-select-coding-system): Get a coding system of the
current newsgroup from gnus-summary-buffer.
(gnus-mule-decode-summary): Deleted.
(gnus-mule-initialize): Add-hook gnus-mule-select-coding-system to
gnus-parse-headers-hook. Don't add-hook gnus-mule-decode-summary
and gnus-mule-decode-article. Don't set process coding system for
nntp stream to 'no-conversion, instead set
nntp-coding-system-for-read to 'binary. Set
nnheader-file-coding-system and nnmail-file-coding-system to
'binary.
Set nntp-coding-system-for-write to
binary.
author | Kenichi Handa <handa@m17n.org> |
---|---|
date | Fri, 26 Sep 1997 01:50:55 +0000 |
parents | 574f61c01920 |
children | 6aa000284161 |
comparison
equal
deleted
inserted
replaced
19995:6182146747a7 | 19996:cb6f1cb0f072 |
---|---|
1 ;;; gnus-mule.el --- Provide multilingual environment to GNUS | 1 ;;; gnus-mule.el --- Provide multilingual environment to GNUS |
2 | 2 |
3 ;; Copyright (C) 1995 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1995,1997 Free Software Foundation, Inc. |
4 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | 4 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. |
5 | 5 |
6 ;; Keywords: gnus, mule | 6 ;; Keywords: gnus, mule |
7 | 7 |
8 ;; This file is part of GNU Emacs. | 8 ;; This file is part of GNU Emacs. |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
23 ;; Boston, MA 02111-1307, USA. | 23 ;; Boston, MA 02111-1307, USA. |
24 | 24 |
25 ;;; Commentary: | 25 ;;; Commentary: |
26 | 26 |
27 ;; This package enables GNUS to code convert automatically | 27 ;; This package enables Gnus to code convert automatically |
28 ;; accoding to a coding system specified for each news group. | 28 ;; accoding to a coding system specified for each news group. |
29 ;; Please put the following line in your .emacs: | |
30 ;; (add-hook 'gnus-startup-hook 'gnus-mule-initialize) | |
31 ;; If you want to specify some coding system for a specific news | 29 ;; If you want to specify some coding system for a specific news |
32 ;; group, add the fllowing line in your .emacs: | 30 ;; group, add the fllowing line in your .emacs: |
33 ;; (gnus-mule-add-group "xxx.yyy.zzz" 'some-coding-system) | 31 ;; (gnus-mule-add-group "xxx.yyy.zzz" 'some-coding-system) |
34 | 32 |
35 ;; By default, only few news groups are registered as the target of | 33 ;; By default, only few news groups are registered as the target of |
36 ;; code conversion. So, each regional users had better set an | 34 ;; code conversion. So, each regional users had better set an |
37 ;; appropriate coding system for as below: | 35 ;; appropriate coding system for as below: |
38 ;; (gnus-mule-add-group "" 'iso-2022-jp) ;; the case for Japanese | 36 ;; (gnus-mule-add-group "" 'iso-2022-jp) ;; the case for Japanese |
39 | 37 |
40 (require 'gnus) | 38 (require 'nntp) |
41 (require 'message) | |
42 | 39 |
43 (defvar gnus-newsgroup-coding-systems nil | 40 (defvar gnus-newsgroup-coding-systems nil |
44 "Assoc list of news groups vs corresponding coding systems. | 41 "Assoc list of news groups vs corresponding coding systems. |
45 Each element is has the form (PATTERN CODING-FOR-READ . CODING-FOR-POST), | 42 Each element is has the form (PATTERN CODING-FOR-READ . CODING-FOR-POST), |
46 where, | 43 where, |
80 | 77 |
81 ;; Flag to indicate if article buffer is already decoded or not.") | 78 ;; Flag to indicate if article buffer is already decoded or not.") |
82 (defvar gnus-mule-article-decoded nil) | 79 (defvar gnus-mule-article-decoded nil) |
83 ;; Coding system for reading articles of the current news group. | 80 ;; Coding system for reading articles of the current news group. |
84 (defvar gnus-mule-coding-system nil) | 81 (defvar gnus-mule-coding-system nil) |
82 ;;(make-variable-buffer-local 'gnus-mule-coding-system) | |
85 (defvar gnus-mule-subject nil) | 83 (defvar gnus-mule-subject nil) |
86 (defvar gnus-mule-decoded-subject nil) | 84 (defvar gnus-mule-decoded-subject nil) |
87 (defvar gnus-mule-original-subject nil) | 85 (defvar gnus-mule-original-subject nil) |
88 | 86 |
89 ;; Encode (if ENCODING is t) or decode (if ENCODING is nil) the | 87 ;; Encode (if ENCODING is t) or decode (if ENCODING is nil) the |
123 coding-system encoding)) | 121 coding-system encoding)) |
124 ))) | 122 ))) |
125 | 123 |
126 ;; Set `gnus-mule-coding-system' to the coding system articles of the | 124 ;; Set `gnus-mule-coding-system' to the coding system articles of the |
127 ;; current news group is encoded. This function is set in | 125 ;; current news group is encoded. This function is set in |
128 ;; `gnus-select-group-hook'. | 126 ;; `gnus-parse-headers-hook'. |
129 (defun gnus-mule-select-coding-system () | 127 (defun gnus-mule-select-coding-system () |
130 (let ((coding-system (gnus-mule-get-coding-system gnus-newsgroup-name))) | 128 (save-excursion |
131 (setq gnus-mule-coding-system | 129 (set-buffer gnus-summary-buffer) |
132 (if (and coding-system (coding-system-p (car coding-system))) | 130 (let ((coding-system (gnus-mule-get-coding-system gnus-newsgroup-name))) |
133 (car coding-system))))) | 131 (setq gnus-mule-coding-system |
132 (if (and coding-system (coding-system-p (car coding-system))) | |
133 (car coding-system)))))) | |
134 | 134 |
135 ;; Decode the current article. This function is set in | 135 ;; Decode the current article. This function is set in |
136 ;; `gnus-article-prepare-hook'. | 136 ;; `gnus-show-traditional-method'. |
137 (defun gnus-mule-decode-article () | 137 (defun gnus-mule-decode-article () |
138 (gnus-mule-code-convert gnus-mule-coding-system nil) | 138 (gnus-mule-code-convert gnus-mule-coding-system nil) |
139 (setq gnus-mule-article-decoded t)) | 139 (setq gnus-mule-article-decoded t)) |
140 | |
141 ;; Decode the current summary buffer. This function is set in | |
142 ;; `gnus-summary-generate-hook'. | |
143 ;; Made by <sangil@hugsvr.kaist.ac.kr>, | |
144 ;; coded by <crisp@hugsvr.kaist.ac.kr>. | |
145 (defun gnus-mule-decode-summary () | |
146 (if gnus-mule-coding-system | |
147 (mapcar | |
148 (lambda (headers) | |
149 (let ((subject (aref headers 1)) | |
150 (author (aref headers 2))) | |
151 (aset headers 1 | |
152 (decode-coding-string subject gnus-mule-coding-system)) | |
153 (aset headers 2 | |
154 (decode-coding-string author gnus-mule-coding-system)))) | |
155 gnus-newsgroup-headers))) | |
156 | 140 |
157 (defun gnus-mule-toggle-article-format () | 141 (defun gnus-mule-toggle-article-format () |
158 "Toggle decoding/encoding of the current article buffer." | 142 "Toggle decoding/encoding of the current article buffer." |
159 (interactive) | 143 (interactive) |
160 (let ((buf (get-buffer gnus-article-buffer))) | 144 (let ((buf (get-buffer gnus-article-buffer))) |
198 "Do several settings for GNUS to enable automatic code conversion." | 182 "Do several settings for GNUS to enable automatic code conversion." |
199 ;; Convenient key definitions | 183 ;; Convenient key definitions |
200 (define-key gnus-article-mode-map "z" 'gnus-mule-toggle-article-format) | 184 (define-key gnus-article-mode-map "z" 'gnus-mule-toggle-article-format) |
201 (define-key gnus-summary-mode-map "z" 'gnus-mule-toggle-article-format) | 185 (define-key gnus-summary-mode-map "z" 'gnus-mule-toggle-article-format) |
202 ;; Hook definition | 186 ;; Hook definition |
203 (add-hook 'gnus-select-group-hook 'gnus-mule-select-coding-system) | 187 (add-hook 'gnus-parse-headers-hook 'gnus-mule-select-coding-system) |
204 (add-hook 'gnus-summary-generate-hook 'gnus-mule-decode-summary) | |
205 (add-hook 'gnus-article-prepare-hook 'gnus-mule-decode-article) | |
206 (add-hook 'message-send-news-hook | 188 (add-hook 'message-send-news-hook |
207 'gnus-mule-message-send-news-function) | 189 'gnus-mule-message-send-news-function) |
208 (add-hook 'message-send-mail-hook | 190 (add-hook 'message-send-mail-hook |
209 'gnus-mule-message-send-mail-function) | 191 'gnus-mule-message-send-mail-function) |
210 (let ((stream (get-process "nntpd"))) | 192 (setq nntp-coding-system-for-read 'binary |
211 (if (processp stream) | 193 nntp-coding-system-for-write 'binary |
212 (set-process-coding-system stream 'no-conversion 'no-conversion)))) | 194 nnheader-file-coding-system 'binary |
213 | 195 nnmail-file-coding-system 'binary) |
214 (gnus-mule-add-group "" 'undecided) | 196 ) |
197 | |
198 (gnus-mule-add-group "" '(undecided . iso-latin-1)) | |
215 (gnus-mule-add-group "fj" 'iso-2022-7bit) | 199 (gnus-mule-add-group "fj" 'iso-2022-7bit) |
216 (gnus-mule-add-group "tnn" 'iso-2022-7bit) | 200 (gnus-mule-add-group "tnn" 'iso-2022-7bit) |
217 (gnus-mule-add-group "japan" 'iso-2022-7bit) | 201 (gnus-mule-add-group "japan" 'iso-2022-7bit) |
218 (gnus-mule-add-group "pin" 'iso-2022-7bit) | 202 (gnus-mule-add-group "pin" 'iso-2022-7bit) |
203 (gnus-mule-add-group "han" 'euc-kr) | |
219 (gnus-mule-add-group "alt.chinese.text" 'chinese-hz) | 204 (gnus-mule-add-group "alt.chinese.text" 'chinese-hz) |
220 (gnus-mule-add-group "alt.hk" 'chinese-hz) | 205 (gnus-mule-add-group "alt.hk" 'chinese-hz) |
221 (gnus-mule-add-group "alt.chinese.text.big5" 'chinese-big5) | 206 (gnus-mule-add-group "alt.chinese.text.big5" 'chinese-big5) |
222 (gnus-mule-add-group "soc.culture.vietnamese" '(nil . vietnamese-viqr)) | 207 (gnus-mule-add-group "soc.culture.vietnamese" '(nil . vietnamese-viqr)) |
223 (gnus-mule-add-group "relcom" 'cyrillic-koi8) | 208 (gnus-mule-add-group "relcom" 'cyrillic-koi8) |
224 | 209 |
225 (add-hook 'gnus-startup-hook 'gnus-mule-initialize) | 210 (provide 'gnus-mule) |
226 | |
227 (modify-coding-system-alist 'network "nntp" 'no-conversion) | |
228 | 211 |
229 ;; gnus-mule.el ends here | 212 ;; gnus-mule.el ends here |