Mercurial > hg > xemacs-beta
comparison lisp/language/japanese.el @ 159:3bb7ccffb0c0 r20-3b6
Import from CVS: tag r20-3b6
author | cvs |
---|---|
date | Mon, 13 Aug 2007 09:41:43 +0200 |
parents | |
children | acd284d43ca1 |
comparison
equal
deleted
inserted
replaced
158:558dfa75ffb3 | 159:3bb7ccffb0c0 |
---|---|
1 ;;; japanese.el --- Japanese support | |
2 | |
3 ;; Copyright (C) 1995 Free Software Foundation, Inc. | |
4 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN. | |
5 ;; Copyright (C) 1997 MORIOKA Tomohiko | |
6 | |
7 ;; Keywords: multilingual, Japanese | |
8 | |
9 ;; This file is part of XEmacs. | |
10 | |
11 ;; XEmacs is free software; you can redistribute it and/or modify it | |
12 ;; under the terms of the GNU General Public License as published by | |
13 ;; the Free Software Foundation; either version 2, or (at your option) | |
14 ;; any later version. | |
15 | |
16 ;; XEmacs 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 XEmacs; see the file COPYING. If not, write to the Free | |
23 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
24 ;; 02111-1307, USA. | |
25 | |
26 ;;; Commentary: | |
27 | |
28 ;; For Japanese, character sets JISX0201, JISX0208, JISX0212 are | |
29 ;; supported. | |
30 | |
31 ;;; Code: | |
32 | |
33 ;;; Syntax of Japanese characters. | |
34 (modify-syntax-entry 'katakana-jisx0201 "w") | |
35 (modify-syntax-entry 'japanese-jisx0212 "w") | |
36 | |
37 (modify-syntax-entry 'japanese-jisx0208 "w") | |
38 (loop for row in '(33 34 40) | |
39 do (modify-syntax-entry `[japanese-jisx0208 ,row] "_")) | |
40 (loop for char in '(?$B!<(B ?$B!+(B ?$B!,(B ?$B!3(B ?$B!4(B ?$B!5(B ?$B!6(B ?$B!7(B ?$B!8(B ?$B!9(B ?$B!:(B ?$B!;(B) | |
41 do (modify-syntax-entry char "w")) | |
42 (modify-syntax-entry ?\$B!J(B "($B!K(B") | |
43 (modify-syntax-entry ?\$B!N(B "($B!O(B") | |
44 (modify-syntax-entry ?\$B!P(B "($B!Q(B") | |
45 (modify-syntax-entry ?\$B!V(B "($B!W(B") | |
46 (modify-syntax-entry ?\$B!X(B "($B!Y(B") | |
47 (modify-syntax-entry ?\$B!K(B ")$B!J(B") | |
48 (modify-syntax-entry ?\$B!O(B ")$B!N(B") | |
49 (modify-syntax-entry ?\$B!Q(B ")$B!P(B") | |
50 (modify-syntax-entry ?\$B!W(B ")$B!V(B") | |
51 (modify-syntax-entry ?\$B!Y(B ")$B!X(B") | |
52 | |
53 ;;; Character categories S, A, H, K, G, Y, and C | |
54 (define-category ?S "Japanese 2-byte symbol character.") | |
55 (modify-category-entry [japanese-jisx0208 33] ?S) | |
56 (modify-category-entry [japanese-jisx0208 34] ?S) | |
57 (modify-category-entry [japanese-jisx0208 40] ?S) | |
58 (define-category ?A "Japanese 2-byte Alphanumeric character.") | |
59 (modify-category-entry [japanese-jisx0208 35] ?A) | |
60 (define-category ?H "Japanese 2-byte Hiragana character.") | |
61 (modify-category-entry [japanese-jisx0208 36] ?H) | |
62 (define-category ?K "Japanese 2-byte Katakana character.") | |
63 (modify-category-entry [japanese-jisx0208 37] ?K) | |
64 (define-category ?G "Japanese 2-byte Greek character.") | |
65 (modify-category-entry [japanese-jisx0208 38] ?G) | |
66 (define-category ?Y "Japanese 2-byte Cyrillic character.") | |
67 (modify-category-entry [japanese-jisx0208 39] ?Y) | |
68 (define-category ?C "Japanese 2-byte Kanji characters.") | |
69 (loop for row from 48 to 126 | |
70 do (modify-category-entry `[japanese-jisx0208 ,row] ?C)) | |
71 (loop for char in '(?$B!<(B ?$B!+(B ?$B!,(B) | |
72 do (modify-category-entry char ?K) | |
73 (modify-category-entry char ?H)) | |
74 (loop for char in '(?$B!3(B ?$B!4(B ?$B!5(B ?$B!6(B ?$B!7(B ?$B!8(B ?$B!9(B ?$B!:(B ?$B!;(B) | |
75 do (modify-category-entry char ?C)) | |
76 (modify-category-entry 'japanese-jisx0212 ?C) | |
77 | |
78 (defvar japanese-word-regexp | |
79 "\\cA+\\cH*\\|\\cK+\\cH*\\|\\cC+\\cH*\\|\\cH+\\|\\ck+\\|\\sw+" | |
80 "Regular expression used to match a Japanese word.") | |
81 | |
82 (set-word-regexp japanese-word-regexp) | |
83 (setq forward-word-regexp "\\w\\>") | |
84 (setq backward-word-regexp "\\<\\w") | |
85 | |
86 ;;; Paragraph setting | |
87 (setq sentence-end | |
88 (concat | |
89 "\\(" | |
90 "\\(" | |
91 "[.?!][]\"')}]*" | |
92 "\\|" | |
93 "[$B!%!)!*(B][$B!O!I!G!K!Q!M!S!U!W!Y(B]*" | |
94 "\\)" | |
95 "\\($\\|\t\\| \\)" | |
96 "\\|" | |
97 "$B!#(B" | |
98 "\\)" | |
99 "[ \t\n]*")) | |
100 (setq paragraph-start "^[ $B!!(B\t\n\f]") | |
101 (setq paragraph-separate "^[ $B!!(B\t\f]*$") | |
102 | |
103 ;; EGG specific setup | |
104 (define-egg-environment 'japanese | |
105 "Japanese settings for egg." | |
106 (lambda () | |
107 (when (not (featurep 'egg-jpn)) | |
108 (load "its/its-hira") | |
109 (load "its/its-kata") | |
110 (load "its/its-hankaku") | |
111 (load "its/its-zenkaku") | |
112 (setq its:*standard-modes* | |
113 (append | |
114 (list (its:get-mode-map "roma-kana") | |
115 (its:get-mode-map "roma-kata") | |
116 (its:get-mode-map "downcase") | |
117 (its:get-mode-map "upcase") | |
118 (its:get-mode-map "zenkaku-downcase") | |
119 (its:get-mode-map "zenkaku-upcase")) | |
120 its:*standard-modes*)) | |
121 (provide 'egg-jpn)) | |
122 (setq wnn-server-type 'jserver) | |
123 (setq egg-default-startup-file "eggrc-wnn") | |
124 (setq-default its:*current-map* (its:get-mode-map "roma-kana")))) | |
125 | |
126 ;; stuff for providing gramatic processing of Japanese text | |
127 ;; something like this should probably be created for all environments... | |
128 | |
129 (defvar aletter (concat "\\(" ascii-char "\\|" kanji-char "\\)")) | |
130 (defvar kanji-space-insertable (concat | |
131 "$B!"(B" aletter "\\|" | |
132 "$B!#(B" aletter "\\|" | |
133 aletter "$B!J(B" "\\|" | |
134 "$B!K(B" aletter "\\|" | |
135 ascii-alphanumeric kanji-kanji-char "\\|" | |
136 kanji-kanji-char ascii-alphanumeric )) | |
137 | |
138 (defvar space-insertable (concat " " aletter "\\|" kanji-space-insertable) | |
139 "Regexp for finding points that can have spaces inserted into them for justification") | |
140 | |
141 ;; (define-coding-system-alias 'iso-2022-7 'iso-2022-jp) | |
142 ;; (define-coding-system-alias 'iso-2022-7 'junet) | |
143 | |
144 (make-coding-system | |
145 'iso-2022-jp 'iso2022 | |
146 "Coding-system used for communication with mail and news in Japan." | |
147 '(charset-g0 ascii | |
148 short t | |
149 seven t | |
150 input-charset-conversion ((latin-jisx0201 ascii) | |
151 (japanese-jisx0208-1978 japanese-jisx0208)) | |
152 mnemonic "MULE/7bit" | |
153 )) | |
154 | |
155 (copy-coding-system 'iso-2022-jp 'junet) | |
156 | |
157 ;; (make-coding-system | |
158 ;; 'shift_jis 1 ?S | |
159 ;; "Coding-system of Shift-JIS used in Japan." t) | |
160 | |
161 (make-coding-system | |
162 'shift_jis 'shift-jis | |
163 "Coding-system of Shift-JIS used in Japan." | |
164 '(mnemonic "Ja/SJIS")) | |
165 | |
166 ;;(define-coding-system-alias 'shift_jis 'sjis) | |
167 | |
168 (copy-coding-system 'shift_jis 'sjis) | |
169 | |
170 ;; (make-coding-system | |
171 ;; 'iso-2022-jp-1978-irv 2 ?J | |
172 ;; "Coding-system used for old jis terminal." | |
173 ;; '((ascii t) nil nil nil | |
174 ;; short ascii-eol ascii-cntl seven nil nil use-roman use-oldjis)) | |
175 | |
176 (make-coding-system | |
177 'iso-2022-jp-1978-irv 'iso2022 | |
178 "Coding-system used for old JIS terminal." | |
179 '(charset-g0 ascii | |
180 short t | |
181 seven t | |
182 output-charset-conversion ((ascii latin-jisx0201) | |
183 (japanese-jisx0208 japanese-jisx0208-1978)) | |
184 mnemonic "Ja-78/7bit" | |
185 )) | |
186 | |
187 ;;(define-coding-system-alias 'iso-2022-jp-1978-irv 'old-jis) | |
188 | |
189 (copy-coding-system 'iso-2022-jp-1978-irv 'old-jis) | |
190 | |
191 ;; (make-coding-system | |
192 ;; 'euc-japan-1990 2 ?E | |
193 ;; "Coding-system of Japanese EUC (Extended Unix Code)." | |
194 ;; '(ascii japanese-jisx0208 katakana-jisx0201 japanese-jisx0212 | |
195 ;; short ascii-eol ascii-cntl nil nil single-shift)) | |
196 | |
197 (make-coding-system | |
198 'euc-jp 'iso2022 | |
199 "Coding-system of Japanese EUC (Extended Unix Code)." | |
200 '(charset-g0 ascii | |
201 charset-g1 japanese-jisx0208 | |
202 charset-g2 katakana-jisx0201 | |
203 charset-g3 japanese-jisx0212 | |
204 short t | |
205 mnemonic "Ja/EUC" | |
206 )) | |
207 | |
208 ;;(define-coding-system-alias 'euc-japan-1990 'euc-japan) | |
209 | |
210 (copy-coding-system 'euc-jp 'euc-japan) ; only for w3 | |
211 (copy-coding-system 'euc-jp 'japanese-euc) | |
212 | |
213 (register-input-method | |
214 "Japanese" '("quail-ja-hiragana" quail-use-package "quail/japanese")) | |
215 (register-input-method | |
216 "Japanese" '("quail-ja" quail-use-package "quail/japanese")) | |
217 | |
218 (defun setup-japanese-environment () | |
219 "Setup multilingual environment (MULE) for Japanese." | |
220 (interactive) | |
221 (setq coding-category-iso-8-2 'euc-jp) | |
222 | |
223 (set-coding-priority | |
224 '(coding-category-iso-7 | |
225 coding-category-iso-8-2 | |
226 coding-category-sjis | |
227 coding-category-iso-8-1 | |
228 coding-category-iso-else | |
229 coding-category-internal)) | |
230 | |
231 (if (eq system-type 'ms-dos) | |
232 (progn | |
233 (setq-default buffer-file-coding-system 'shift_jis) | |
234 (set-terminal-coding-system 'shift_jis) | |
235 (set-keyboard-coding-system 'shift_jis) | |
236 (setq default-process-coding-system '(shift_jis-dos . shift_jis-dos))) | |
237 (setq-default buffer-file-coding-system 'iso-2022-jp) | |
238 (set-terminal-coding-system 'iso-2022-jp) | |
239 (set-keyboard-coding-system 'iso-2022-jp)) | |
240 | |
241 (set-default-input-method "Japanese" "quail-ja") | |
242 | |
243 (setq sendmail-coding-system 'iso-2022-jp | |
244 rmail-file-coding-system 'iso-2022-jp) | |
245 ) | |
246 | |
247 (defun describe-japanese-support () | |
248 "Describe how Emacs supports Japanese." | |
249 (interactive) | |
250 (describe-language-support-internal "Japanese")) | |
251 | |
252 (set-language-info-alist | |
253 "Japanese" '((setup-function . setup-japanese-environment) | |
254 (describe-function . describe-japanese-support) | |
255 (tutorial . "TUTORIAL.jp") | |
256 (charset . (japanese-jisx0208 japanese-jisx0208-1978 | |
257 japanese-jisx0212 latin-jisx0201 | |
258 katakana-jisx0201)) | |
259 (coding-system . (euc-jp shift_jis | |
260 iso-2022-jp iso-2022-jp-1978-irv)) | |
261 (sample-text . "Japanese ($BF|K\8l(B) $B$3$s$K$A$O(B, (I:]FAJ(B") | |
262 (documentation . nil))) | |
263 | |
264 ;; for XEmacs (will be obsoleted) | |
265 | |
266 (define-language-environment 'japanese | |
267 "Japanese (includes JIS and EUC)" | |
268 (lambda () | |
269 (set-coding-category-system 'iso-7 'iso-2022-jp) | |
270 (set-coding-category-system 'iso-8-2 'euc-jp) | |
271 (set-coding-priority-list '(iso-7 iso-8-2 shift-jis no-conversion)) | |
272 ;;'(iso-8-2 iso-8-designate iso-8-1 shift-jis big5) | |
273 | |
274 ;; Added by mrb, who doesn't speak japanese - so be sceptical... | |
275 ;; (when (string-match "solaris\\|sunos" system-configuration) | |
276 ;;(set-native-coding-system 'euc-japan) ; someday | |
277 (set-pathname-coding-system 'euc-jp) | |
278 (add-hook 'comint-exec-hook | |
279 (lambda () | |
280 (let ((proc (get-buffer-process (current-buffer)))) | |
281 (set-process-input-coding-system proc 'euc-jp) | |
282 (set-process-output-coding-system proc 'euc-jp)))) | |
283 ;;(set-buffer-file-coding-system-for-read 'automatic-conversion) | |
284 (set-default-buffer-file-coding-system 'euc-jp) | |
285 (setq keyboard-coding-system 'euc-jp) | |
286 (setq terminal-coding-system 'euc-jp) | |
287 (when (eq 'x (device-type (selected-device))) | |
288 (x-use-halfwidth-roman-font 'japanese-jisx0208 "jisx0201")) | |
289 | |
290 (when (eq system-type 'ms-dos) | |
291 ;; Shift-JIS is the standard coding system under Japanese MS-DOS | |
292 ;; This isn't really code - just a hint to future implementors | |
293 (setq keyboard-coding-system 'shift_jis-dos) | |
294 (setq terminal-coding-system 'shift_jis-dos) | |
295 (set-default-buffer-file-coding-system 'shift_jis-dos) | |
296 ;;(set-default-process-coding-system 'shift_jis-dos 'shift_jis-dos) | |
297 ) | |
298 )) | |
299 | |
300 (set-coding-category-system 'shift-jis 'shift_jis) | |
301 | |
302 ;;; japanese.el ends here |