70
|
1 ;;; japanese-hooks.el --- pre-loaded support for Japanese.
|
|
2
|
|
3 ;; Copyright (C) 1992,93,94,95 Free Software Foundation, Inc.
|
|
4 ;; Copyright (C) 1995 Amdahl Corporation.
|
|
5 ;; Copyright (C) 1995 Sun Microsystems.
|
|
6
|
|
7 ;; This file is part of XEmacs.
|
|
8
|
|
9 ;; XEmacs is free software; you can redistribute it and/or modify it
|
|
10 ;; under the terms of the GNU General Public License as published by
|
|
11 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
12 ;; any later version.
|
|
13
|
|
14 ;; XEmacs is distributed in the hope that it will be useful, but
|
|
15 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
16 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
17 ;; General Public License for more details.
|
|
18
|
|
19 ;; You should have received a copy of the GNU General Public License
|
|
20 ;; along with XEmacs; see the file COPYING. If not, write to the
|
|
21 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
22 ;; Boston, MA 02111-1307, USA.
|
|
23
|
|
24 ;;; Synched up with: Mule 2.3.
|
|
25
|
|
26 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
27 ;;; JAPANESE
|
|
28 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
29
|
|
30 ;;; Syntax of Japanese characters.
|
74
|
31 (modify-syntax-entry 'katakana-jisx0201 "w")
|
70
|
32 (modify-syntax-entry 'japanese-jisx0212 "w")
|
|
33
|
|
34 (modify-syntax-entry 'japanese-jisx0208 "w")
|
|
35 (loop for row in '(33 34 40)
|
|
36 do (modify-syntax-entry `[japanese-jisx0208 ,row] "_"))
|
|
37 (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)
|
|
38 do (modify-syntax-entry char "w"))
|
|
39 (modify-syntax-entry ?\$B!J(B "($B!K(B")
|
|
40 (modify-syntax-entry ?\$B!N(B "($B!O(B")
|
|
41 (modify-syntax-entry ?\$B!P(B "($B!Q(B")
|
|
42 (modify-syntax-entry ?\$B!V(B "($B!W(B")
|
|
43 (modify-syntax-entry ?\$B!X(B "($B!Y(B")
|
|
44 (modify-syntax-entry ?\$B!K(B ")$B!J(B")
|
|
45 (modify-syntax-entry ?\$B!O(B ")$B!N(B")
|
|
46 (modify-syntax-entry ?\$B!Q(B ")$B!P(B")
|
|
47 (modify-syntax-entry ?\$B!W(B ")$B!V(B")
|
|
48 (modify-syntax-entry ?\$B!Y(B ")$B!X(B")
|
|
49
|
|
50
|
|
51 ;;; Character categories S, A, H, K, G, Y, and C
|
|
52 (define-category ?S "Japanese 2-byte symbol character.")
|
|
53 (modify-category-entry [japanese-jisx0208 33] ?S)
|
|
54 (modify-category-entry [japanese-jisx0208 34] ?S)
|
|
55 (modify-category-entry [japanese-jisx0208 40] ?S)
|
|
56 (define-category ?A "Japanese 2-byte Alphanumeric character.")
|
|
57 (modify-category-entry [japanese-jisx0208 35] ?A)
|
|
58 (define-category ?H "Japanese 2-byte Hiragana character.")
|
|
59 (modify-category-entry [japanese-jisx0208 36] ?H)
|
|
60 (define-category ?K "Japanese 2-byte Katakana character.")
|
|
61 (modify-category-entry [japanese-jisx0208 37] ?K)
|
|
62 (define-category ?G "Japanese 2-byte Greek character.")
|
|
63 (modify-category-entry [japanese-jisx0208 38] ?G)
|
|
64 (define-category ?Y "Japanese 2-byte Cyrillic character.")
|
|
65 (modify-category-entry [japanese-jisx0208 39] ?Y)
|
|
66 (define-category ?C "Japanese 2-byte Kanji characters.")
|
|
67 (loop for row from 48 to 126 do (modify-category-entry `[japanese-jisx0208 ,row] ?C))
|
|
68 (loop for char in '(?$B!<(B ?$B!+(B ?$B!,(B)
|
|
69 do (modify-category-entry char ?K)
|
|
70 (modify-category-entry char ?H))
|
|
71 (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)
|
|
72 do (modify-category-entry char ?C))
|
|
73 (modify-category-entry 'japanese-jisx0212 ?C)
|
|
74
|
|
75 (defvar japanese-word-regexp
|
|
76 "\\cA+\\cH*\\|\\cK+\\cH*\\|\\cC+\\cH*\\|\\cH+\\|\\ck+\\|\\sw+"
|
|
77 "Regular expression used to match a Japanese word.")
|
|
78
|
|
79 (set-word-regexp japanese-word-regexp)
|
|
80 (setq forward-word-regexp "\\w\\>")
|
|
81 (setq backward-word-regexp "\\<\\w")
|
|
82
|
|
83 ;;; Paragraph setting
|
|
84 (setq sentence-end
|
|
85 (concat
|
|
86 "\\("
|
|
87 "\\("
|
|
88 "[.?!][]\"')}]*"
|
|
89 "\\|"
|
|
90 "[$B!%!)!*(B][$B!O!I!G!K!Q!M!S!U!W!Y(B]*"
|
|
91 "\\)"
|
|
92 "\\($\\|\t\\| \\)"
|
|
93 "\\|"
|
|
94 "$B!#(B"
|
|
95 "\\)"
|
|
96 "[ \t\n]*"))
|
|
97 (setq paragraph-start "^[ $B!!(B\t\n\f]")
|
|
98 (setq paragraph-separate "^[ $B!!(B\t\f]*$")
|
|
99
|
|
100 (make-coding-system
|
|
101 'shift-jis 'shift-jis
|
|
102 "Coding-system of Shift-JIS used in Japan."
|
|
103 '(mnemonic "SJIS"))
|
|
104
|
|
105 (copy-coding-system 'shift-jis 'sjis)
|
|
106
|
|
107 (make-coding-system
|
|
108 'iso-2022-jp 'iso2022
|
|
109 "Coding-system used for communication with mail and news in Japan."
|
|
110 '(charset-g0 ascii
|
|
111 short t
|
|
112 seven t
|
74
|
113 input-charset-conversion ((latin-jisx0201 ascii)
|
70
|
114 (japanese-jisx0208-1978 japanese-jisx0208))
|
|
115 mnemonic "Mail/Ja"
|
|
116 ))
|
|
117
|
|
118 (copy-coding-system 'iso-2022-jp 'junet)
|
|
119
|
|
120 (make-coding-system
|
|
121 'oldjis 'iso2022
|
|
122 "Coding-system used for old JIS terminal."
|
|
123 '(charset-g0 ascii
|
|
124 short t
|
|
125 seven t
|
74
|
126 output-charset-conversion ((ascii latin-jisx0201)
|
70
|
127 (japanese-jisx0208 japanese-jisx0208-1978))
|
|
128 mnemonic "Mail/Ja-old"
|
|
129 ))
|
|
130
|
|
131 (make-coding-system
|
|
132 'euc-japan 'iso2022
|
|
133 "Coding-system of Japanese EUC (Extended Unix Code)."
|
|
134 '(charset-g0 ascii
|
|
135 charset-g1 japanese-jisx0208
|
74
|
136 charset-g2 katakana-jisx0201
|
70
|
137 charset-g3 japanese-jisx0212
|
|
138 short t
|
|
139 mnemonic "EUC/Ja"
|
|
140 ))
|
|
141
|
|
142 (define-language-environment 'japanese
|
|
143 "Japanese (includes JIS and EUC)"
|
|
144 (lambda ()
|
|
145 (set-coding-category-system 'iso-7 'iso-2022-jp)
|
|
146 (set-coding-category-system 'iso-8-2 'euc-japan)
|
74
|
147 (set-coding-priority-list '(iso-7 iso-8-2 shift-jis no-conversion))
|
70
|
148 ;;'(iso-8-2 iso-8-designate iso-8-1 shift-jis big5)
|
|
149
|
98
|
150 ;; EGG specific setup 97.02.05 jhod
|
|
151 (when (featurep 'egg)
|
|
152 (when (not (featurep 'egg-jpn))
|
|
153 (provide 'egg-jpn)
|
|
154 (setq wnn-server-type 'jserver)
|
|
155 (load "its/its-hira")
|
|
156 (load "its/its-kata")
|
|
157 (load "its/its-hankaku")
|
|
158 (load "its/its-zenkaku")
|
|
159 (setq its:*standard-modes*
|
|
160 (append
|
|
161 (list (its:get-mode-map "roma-kana")
|
|
162 (its:get-mode-map "roma-kata")
|
|
163 (its:get-mode-map "downcase")
|
|
164 (its:get-mode-map "upcase")
|
|
165 (its:get-mode-map "zenkaku-downcase")
|
|
166 (its:get-mode-map "zenkaku-upcase"))
|
|
167 its:*standard-modes*)))
|
|
168 (setq-default its:*current-map* (its:get-mode-map "roma-kana")))
|
70
|
169
|
|
170 ;; Added by mrb, who doesn't speak japanese - so be sceptical...
|
|
171 ;; (when (string-match "solaris\\|sunos" system-configuration)
|
|
172 ;;(set-native-coding-system 'euc-japan) ; someday
|
|
173 (set-pathname-coding-system 'euc-japan)
|
|
174 (add-hook 'comint-exec-hook
|
|
175 (lambda ()
|
|
176 (let ((proc (get-buffer-process (current-buffer))))
|
|
177 (set-process-input-coding-system proc 'euc-japan)
|
|
178 (set-process-output-coding-system proc 'euc-japan))))
|
110
|
179 (set-buffer-file-coding-system-for-read 'autodetect)
|
|
180 (set-default-buffer-file-coding-system 'euc-japan)
|
|
181 (setq keyboard-coding-system 'euc-japan)
|
|
182 (setq terminal-coding-system 'euc-japan)
|
102
|
183 (when (eq 'x (device-type (selected-device)))
|
|
184 (x-use-halfwidth-roman-font 'japanese-jisx0208 "jisx0201"))
|
70
|
185
|
|
186 (when (eq system-type 'ms-dos)
|
|
187 ;; Shift-JIS is the standard coding system under Japanese MS-DOS
|
|
188 ;; This isn't really code - just a hint to future implementors
|
110
|
189 (setq keyboard-coding-system 'shift-jis-dos)
|
|
190 (setq terminal-coding-system 'shift-jis-dos)
|
|
191 (set-default-buffer-file-coding-system 'shift-jis-dos)
|
70
|
192 ;;(set-default-process-coding-system 'shift-jis-dos 'shift-jis-dos)
|
|
193 )
|
|
194 ))
|
|
195
|
|
196 (set-coding-category-system 'shift-jis 'shift-jis)
|
110
|
197
|
|
198 ;; stuff for providing gramatic processing of Japanese text
|
|
199 ;; something like this should probably be created for all environments...
|
|
200
|
|
201 (defvar aletter (concat "\\(" ascii-char "\\|" kanji-char "\\)"))
|
|
202 (defvar kanji-space-insertable (concat
|
|
203 "$B!"(B" aletter "\\|"
|
|
204 "$B!#(B" aletter "\\|"
|
|
205 aletter "$B!J(B" "\\|"
|
|
206 "$B!K(B" aletter "\\|"
|
|
207 ascii-alphanumeric kanji-kanji-char "\\|"
|
|
208 kanji-kanji-char ascii-alphanumeric ))
|
|
209
|
|
210 (defvar space-insertable (concat " " aletter "\\|" kanji-space-insertable)
|
|
211 "Regexp for finding points that can have spaces inserted into them for justification")
|