comparison lisp/mule/japanese.el @ 428:3ecd8885ac67 r21-2-22

Import from CVS: tag r21-2-22
author cvs
date Mon, 13 Aug 2007 11:28:15 +0200
parents
children 98528da0b7fc
comparison
equal deleted inserted replaced
427:0a0253eac470 428:3ecd8885ac67
1 ;;; japanese.el --- Japanese support -*- coding: iso-2022-7bit; -*-
2
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation.
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-hira")
109 (load "its-kata")
110 (load "its-hankaku")
111 (load "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 ;; Can't do this here any more. Must do it when selecting egg-wnn
124 ;; or egg-sj3
125 ;; (setq egg-default-startup-file "eggrc-wnn")
126 (setq-default its:*current-map* (its:get-mode-map "roma-kana"))))
127
128 ;; stuff for providing gramatic processing of Japanese text
129 ;; something like this should probably be created for all environments...
130
131 (defvar aletter (concat "\\(" ascii-char "\\|" kanji-char "\\)"))
132 (defvar kanji-space-insertable (concat
133 "$B!"(B" aletter "\\|"
134 "$B!#(B" aletter "\\|"
135 aletter "$B!J(B" "\\|"
136 "$B!K(B" aletter "\\|"
137 ascii-alphanumeric kanji-kanji-char "\\|"
138 kanji-kanji-char ascii-alphanumeric ))
139
140 (defvar space-insertable (concat " " aletter "\\|" kanji-space-insertable)
141 "Regexp for finding points that can have spaces inserted into them for justification")
142
143 ;; (make-coding-system
144 ;; 'iso-2022-jp 2 ?J
145 ;; "ISO 2022 based 7bit encoding for Japanese (MIME:ISO-2022-JP)"
146 ;; '((ascii japanese-jisx0208-1978 japanese-jisx0208
147 ;; latin-jisx0201 japanese-jisx0212 katakana-jisx0201) nil nil nil
148 ;; short ascii-eol ascii-cntl seven)
149 ;; '((safe-charsets ascii japanese-jisx0208-1978 japanese-jisx0208
150 ;; latin-jisx0201 japanese-jisx0212 katakana-jisx0201)
151 ;; (mime-charset . iso-2022-jp)))
152
153 (make-coding-system
154 'iso-2022-jp 'iso2022
155 "Coding-system used for communication with mail and news in Japan."
156 '(charset-g0 ascii
157 short t
158 seven t
159 input-charset-conversion ((latin-jisx0201 ascii)
160 (japanese-jisx0208-1978 japanese-jisx0208))
161 mnemonic "MULE/7bit"
162 ))
163
164 (define-coding-system-alias 'junet 'iso-2022-jp)
165
166 ;; (make-coding-system
167 ;; 'iso-2022-jp-2 2 ?J
168 ;; "ISO 2022 based 7bit encoding for CJK, Latin-1, and Greek (MIME:ISO-2022-JP-2)"
169 ;; '((ascii japanese-jisx0208-1978 japanese-jisx0208
170 ;; latin-jisx0201 japanese-jisx0212 katakana-jisx0201
171 ;; chinese-gb2312 korean-ksc5601) nil
172 ;; (nil latin-iso8859-1 greek-iso8859-7) nil
173 ;; short ascii-eol ascii-cntl seven nil single-shift)
174 ;; '((safe-charsets ascii japanese-jisx0208-1978 japanese-jisx0208
175 ;; latin-jisx0201 japanese-jisx0212 katakana-jisx0201
176 ;; chinese-gb2312 korean-ksc5601
177 ;; latin-iso8859-1 greek-iso8859-7)
178 ;; (mime-charset . iso-2022-jp-2)))
179
180 ;; (make-coding-system
181 ;; 'japanese-shift-jis 1 ?S
182 ;; "Shift-JIS 8-bit encoding for Japanese (MIME:SHIFT_JIS)"
183 ;; nil
184 ;; '((safe-charsets ascii japanese-jisx0208 japanese-jisx0208-1978
185 ;; latin-jisx0201 katakana-jisx0201)
186 ;; (mime-charset . shift_jis)
187 ;; (charset-origin-alist (japanese-jisx0208 "SJIS" encode-sjis-char)
188 ;; (katakana-jisx0201 "SJIS" encode-sjis-char))))
189
190 (make-coding-system
191 'shift_jis 'shift-jis
192 "Coding-system of Shift-JIS used in Japan."
193 '(mnemonic "Ja/SJIS"))
194
195 ;; (define-coding-system-alias 'shift_jis 'japanese-shift-jis)
196 ;; (define-coding-system-alias 'sjis 'japanese-shift-jis)
197
198 ;; (make-coding-system
199 ;; 'japanese-iso-7bit-1978-irv 2 ?j
200 ;; "ISO 2022 based 7-bit encoding for Japanese JISX0208-1978 and JISX0201-Roman"
201 ;; '((ascii japanese-jisx0208-1978 japanese-jisx0208
202 ;; latin-jisx0201 japanese-jisx0212 katakana-jisx0201 t) nil nil nil
203 ;; short ascii-eol ascii-cntl seven nil nil use-roman use-oldjis)
204 ;; '(ascii japanese-jisx0208-1978 japanese-jisx0208 latin-jisx0201))
205
206 (make-coding-system
207 'iso-2022-jp-1978-irv 'iso2022
208 "Coding-system used for old JIS terminal."
209 '(charset-g0 ascii
210 short t
211 seven t
212 output-charset-conversion ((ascii latin-jisx0201)
213 (japanese-jisx0208 japanese-jisx0208-1978))
214 mnemonic "Ja-78/7bit"
215 ))
216
217 ;; (define-coding-system-alias 'iso-2022-jp-1978-irv 'japanese-iso-7bit-1978-irv)
218 ;; (define-coding-system-alias 'old-jis 'japanese-iso-7bit-1978-irv)
219
220 (define-coding-system-alias 'old-jis 'iso-2022-jp-1978-irv)
221
222 ;; (make-coding-system
223 ;; 'japanese-iso-8bit 2 ?E
224 ;; "ISO 2022 based EUC encoding for Japanese (MIME:EUC-JP)"
225 ;; '(ascii japanese-jisx0208 katakana-jisx0201 japanese-jisx0212
226 ;; short ascii-eol ascii-cntl nil nil single-shift)
227 ;; '((safe-charsets ascii latin-jisx0201 japanese-jisx0208 japanese-jisx0208-1978
228 ;; katakana-jisx0201 japanese-jisx0212)
229 ;; (mime-charset . euc-jp)))
230
231 (make-coding-system
232 'euc-jp 'iso2022
233 "Coding-system of Japanese EUC (Extended Unix Code)."
234 '(charset-g0 ascii
235 charset-g1 japanese-jisx0208
236 charset-g2 katakana-jisx0201
237 charset-g3 japanese-jisx0212
238 short t
239 mnemonic "Ja/EUC"
240 ))
241
242 ;; (define-coding-system-alias 'euc-japan-1990 'japanese-iso-8bit)
243 ;; (define-coding-system-alias 'euc-japan 'japanese-iso-8bit)
244 ;; (define-coding-system-alias 'euc-jp 'japanese-iso-8bit)
245
246 (define-coding-system-alias 'euc-japan 'euc-jp) ; only for w3
247 (define-coding-system-alias 'japanese-euc 'euc-jp)
248
249 (set-language-info-alist
250 "Japanese" '((setup-function . setup-japanese-environment-internal)
251 (exit-function . exit-japanese-environment)
252 (tutorial . "TUTORIAL.ja")
253 (charset japanese-jisx0208 japanese-jisx0208-1978
254 japanese-jisx0212 latin-jisx0201 katakana-jisx0201)
255 (coding-system iso-2022-jp euc-jp
256 shift_jis iso-2022-jp-2)
257 (coding-priority iso-2022-jp euc-jp
258 shift_jis iso-2022-jp-2)
259 ;; (input-method . "japanese")
260 (features japan-util)
261 (sample-text . "Japanese ($BF|K\8l(B) $B$3$s$K$A$O(B, )IºÝÆÁÊ")-A
262 (documentation . t)))
263
264 ;;; japanese.el ends here