1 ;;; characters.el --- set syntax and category for multibyte characters
3 ;; Copyright (C) 1995 Free Software Foundation, Inc.
4 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
6 ;; Keywords: multibyte character, character set, syntax, category
8 ;; This file is part of GNU Emacs.
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
11 ;; it under the terms of the GNU General Public License as published by
12 ;; the Free Software Foundation; either version 2, or (at your option)
15 ;; GNU Emacs is distributed in the hope that it will be useful,
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 ;; GNU General Public License for more details.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
23 ;; Boston, MA 02111-1307, USA.
27 ;; This file contains multibyte characters. Save this file always in
28 ;; the coding system `iso-2022-7'.
30 ;;; Predefined categories.
32 ;; For each character set.
34 (define-category ?a "ASCII")
35 (define-category ?l "Latin")
36 (define-category ?t "Thai")
37 (define-category ?g "Greek")
38 (define-category ?b "Arabic")
39 (define-category ?w "Hebrew")
40 (define-category ?y "Cyrillic")
41 (define-category ?k "Japanese katakana")
42 (define-category ?r "Japanese roman")
43 (define-category ?c "Chinese")
44 (define-category ?j "Japanese")
45 (define-category ?h "Korean")
46 (define-category ?e "Ethiopic (Ge'ez)")
47 (define-category ?v "Vietnamese")
48 (define-category ?i "Indian")
49 (define-category ?o "Lao")
50 (define-category ?q "Tibetan")
52 ;; For each group (row) of 2-byte character sets.
54 (define-category ?A "Alpha numeric characters of 2-byte character sets")
55 (define-category ?C "Chinese (Han) characters of 2-byte character sets")
56 (define-category ?G "Greek characters of 2-byte characters sets")
57 (define-category ?H "Japanese Hiragana characters of 2-byte character sets")
58 (define-category ?K "Japanese Katakana characters of 2-byte character sets")
59 (define-category ?N "Korean Hangul characters of 2-byte character sets")
60 (define-category ?Y "Cyrillic character of 2-byte character sets")
61 (define-category ?I "Indian Glyphs")
63 ;; For phonetic classifications.
65 (define-category ?0 "consonant")
66 (define-category ?1 "base vowel")
67 (define-category ?2 "upper diacritical mark (including upper vowel)")
68 (define-category ?3 "lower diacritical mark (including lower vowel)")
69 (define-category ?4 "tone mark")
70 (define-category ?5 "vowel")
71 (define-category ?6 "digit")
72 (define-category ?7 "vowel-modifying diacritical mark")
73 (define-category ?8 "vowel-signs")
74 (define-category ?9 "semivowel lower")
77 (define-category ?| "While filling, we can break a line at this character.")
79 ;; Keep the followings for `kinsoku' processing. See comments in
81 (define-category ?> "A character which can't be placed at beginning of line.")
82 (define-category ?< "A character which can't be placed at end of line.")
85 ;;; Setting syntax and category.
90 (while (< ch 127) ; All ASCII characters have
91 (modify-category-entry ch ?a) ; the category `a' (ASCII)
92 (modify-category-entry ch ?l) ; and `l' (Latin).
95 ;; Arabic character set
97 (let ((charsets '(arabic-iso8859-6
102 (modify-syntax-entry (make-char (car charsets)) "w")
103 (modify-category-entry (make-char (car charsets)) ?b)
104 (setq charsets (cdr charsets))))
106 ;; Chinese character set (GB2312)
108 (modify-syntax-entry (make-char 'chinese-gb2312) "w")
109 (modify-syntax-entry (make-char 'chinese-gb2312 33) "_")
110 (modify-syntax-entry (make-char 'chinese-gb2312 34) "_")
111 (modify-syntax-entry (make-char 'chinese-gb2312 41) "_")
112 (modify-syntax-entry ?\
\e$A!2
\e(B "(
\e$A!3
\e(B")
113 (modify-syntax-entry ?\
\e$A!4
\e(B "(
\e$A!5
\e(B")
114 (modify-syntax-entry ?\
\e$A!6
\e(B "(
\e$A!7
\e(B")
115 (modify-syntax-entry ?\
\e$A!8
\e(B "(
\e$A!9
\e(B")
116 (modify-syntax-entry ?\
\e$A!:
\e(B "(
\e$A!;
\e(B")
117 (modify-syntax-entry ?\
\e$A!<
\e(B "(
\e$A!=
\e(B")
118 (modify-syntax-entry ?\
\e$A!>
\e(B "(
\e$A!?
\e(B")
119 (modify-syntax-entry ?\
\e$A!3
\e(B ")
\e$A!2
\e(B")
120 (modify-syntax-entry ?\
\e$A!5
\e(B ")
\e$A!4
\e(B")
121 (modify-syntax-entry ?\
\e$A!7
\e(B ")
\e$A!6
\e(B")
122 (modify-syntax-entry ?\
\e$A!9
\e(B ")
\e$A!8
\e(B")
123 (modify-syntax-entry ?\
\e$A!;
\e(B ")
\e$A!:
\e(B")
124 (modify-syntax-entry ?\
\e$A!=
\e(B ")
\e$A!<
\e(B")
125 (modify-syntax-entry ?\
\e$A!?
\e(B ")
\e$A!>
\e(B")
127 (modify-category-entry (make-char 'chinese-gb2312) ?c)
128 (modify-category-entry (make-char 'chinese-gb2312) ?\|)
129 (modify-category-entry (make-char 'chinese-gb2312 35) ?A)
130 (modify-category-entry (make-char 'chinese-gb2312 36) ?H)
131 (modify-category-entry (make-char 'chinese-gb2312 37) ?K)
132 (modify-category-entry (make-char 'chinese-gb2312 38) ?G)
133 (modify-category-entry (make-char 'chinese-gb2312 39) ?Y)
134 (modify-category-entry (make-char 'chinese-gb2312 35) ?A)
137 (modify-category-entry (make-char 'chinese-gb2312 row) ?C)
138 (setq row (1+ row))))
140 ;; Chinese character set (BIG5)
142 (let ((generic-big5-1-char (make-char 'chinese-big5-1))
143 (generic-big5-2-char (make-char 'chinese-big5-2)))
144 (modify-syntax-entry generic-big5-1-char "w")
145 (modify-syntax-entry generic-big5-2-char "w")
147 (modify-category-entry generic-big5-1-char ?c)
148 (modify-category-entry generic-big5-2-char ?c)
150 (modify-category-entry generic-big5-1-char ?C)
151 (modify-category-entry generic-big5-2-char ?C)
153 (modify-category-entry generic-big5-1-char ?\|)
154 (modify-category-entry generic-big5-2-char ?\|))
157 ;; Chinese character set (CNS11643)
159 (let ((cns-list '(chinese-cns11643-1
168 (setq generic-char (make-char (car cns-list)))
169 (modify-syntax-entry generic-char "w")
170 (modify-category-entry generic-char ?c)
171 (modify-category-entry generic-char ?C)
172 (modify-category-entry generic-char ?|)
173 (setq cns-list (cdr cns-list))))
175 ;; Cyrillic character set (ISO-8859-5)
177 (modify-category-entry (make-char 'cyrillic-iso8859-5) ?y)
181 (modify-syntax-entry (make-char 'cyrillic-iso8859-5 c) "w")
183 (modify-syntax-entry ?
\e,L-
\e(B ".")
184 (modify-syntax-entry ?
\e,Lp
\e(B ".")
185 (modify-syntax-entry ?
\e,L}
\e(B ".")
187 ;; Devanagari character set
189 (let ((deflist '(;; chars syntax category
190 ("
\e$(5!!!"!#
\e(B" "w" ?7) ; vowel-modifying diacritical mark
191 ; chandrabindu, anuswar, visarga
192 ("
\e$(5!$
\e(B-
\e$(5!2
\e(B" "w" ?5) ; independent vowel
193 ("
\e$(5!3
\e(B-
\e$(5!X
\e(B" "w" ?0) ; consonant
194 ("
\e$(5!Z
\e(B-
\e$(5!g
\e(B" "w" ?8) ; matra
195 ("
\e$(5!q
\e(B-
\e$(5!z
\e(B" "w" ?6) ; digit
197 elm chars len syntax category to ch i)
199 (setq elm (car deflist))
200 (setq chars (car elm)
206 (if (= (aref chars i) ?-)
209 (setq ch (sref chars i)
212 (modify-syntax-entry ch syntax)
213 (modify-category-entry ch category)
215 (setq i (+ i (char-bytes to))))
216 (setq deflist (cdr deflist))))
218 ;; Ethiopic character set
220 (modify-category-entry (make-char 'ethiopic) ?e)
222 ;; European character set (Latin-1,2,3,4,5)
224 (modify-category-entry (make-char 'latin-iso8859-1) ?l)
225 (modify-category-entry (make-char 'latin-iso8859-2) ?l)
226 (modify-category-entry (make-char 'latin-iso8859-3) ?l)
227 (modify-category-entry (make-char 'latin-iso8859-4) ?l)
228 (modify-category-entry (make-char 'latin-iso8859-9) ?l)
230 ;; ISO-8859-1 (Latin-1)
232 (while (< c 128) ; from '
\e,A@
\e(B' to '
\e,A
\7f\e(B'
233 (modify-syntax-entry (make-char 'latin-iso8859-1 c) "w")
235 (modify-syntax-entry (make-char 'latin-iso8859-1 32) "w") ; NBSP
236 (modify-syntax-entry ?
\e,AW
\e(B "_")
237 (modify-syntax-entry ?
\e,Aw
\e(B "_")
240 ;; ISO-8859-2 (Latin-2)
243 (modify-syntax-entry (make-char 'latin-iso8859-2 c) "w")
245 (let ((chars '(?
\e,B!
\e(B ?
\e,B#
\e(B ?
\e,B%
\e(B ?
\e,B&
\e(B ?
\e,B)
\e(B ?
\e,B*
\e(B ?
\e,B+
\e(B ?
\e,B,
\e(B ?
\e,B.
\e(B ?
\e,B/
\e(B ?
\e,B1
\e(B ?
\e,B3
\e(B ?
\e,B5
\e(B ?
\e,B6
\e(B ?
\e,B9
\e(B ?
\e,B:
\e(B ?
\e,B;
\e(B ?
\e,B<
\e(B)))
247 (modify-syntax-entry (car chars) "w")
248 (setq chars (cdr chars))))
249 (modify-syntax-entry (make-char 'latin-iso8859-2 160) "w") ; NBSP
250 (modify-syntax-entry ?
\e,BW
\e(B ".")
251 (modify-syntax-entry ?
\e,Bw
\e(B ".")
253 ;; Greek character set (ISO-8859-7)
255 (modify-category-entry (make-char 'greek-iso8859-7) ?g)
259 (modify-syntax-entry (make-char 'greek-iso8859-7 c) "w")
261 (modify-syntax-entry (make-char 'greek-iso8859-7 160) "w") ; NBSP
262 (modify-syntax-entry ?
\e,F7
\e(B ".")
263 (modify-syntax-entry ?
\e,F;
\e(B ".")
264 (modify-syntax-entry ?
\e,F=
\e(B ".")
266 ;; Hebrew character set (ISO-8859-8)
268 (modify-category-entry (make-char 'hebrew-iso8859-8) ?w)
272 (modify-syntax-entry (make-char 'hebrew-iso8859-8 c) "w")
274 (modify-syntax-entry (make-char 'hebrew-iso8859-8 160) "w") ; NBSP
276 ;; Indian character set (IS 13194 and other Emacs original Indian charsets)
278 (modify-category-entry (make-char 'indian-is13194) ?i)
279 (modify-category-entry (make-char 'indian-2-column) ?I)
280 (modify-category-entry (make-char 'indian-1-column) ?I)
282 ;; Japanese character set (JISX0201-kana, JISX0201-roman, JISX0208, JISX0212)
284 (modify-category-entry (make-char 'katakana-jisx0201) ?k)
285 (modify-category-entry (make-char 'latin-jisx0201) ?r)
286 (modify-category-entry (make-char 'japanese-jisx0208) ?j)
287 (modify-category-entry (make-char 'japanese-jisx0212) ?j)
288 (modify-category-entry (make-char 'katakana-jisx0201) ?\|)
289 (modify-category-entry (make-char 'japanese-jisx0208) ?\|)
290 (modify-category-entry (make-char 'japanese-jisx0212) ?\|)
293 (modify-syntax-entry (make-char 'japanese-jisx0208) "w")
294 (modify-syntax-entry (make-char 'japanese-jisx0208 33) "_")
295 (modify-syntax-entry (make-char 'japanese-jisx0208 34) "_")
296 (modify-syntax-entry (make-char 'japanese-jisx0208 40) "_")
297 (let ((chars '(?
\e$B!<
\e(B ?
\e$B!+
\e(B ?
\e$B!,
\e(B ?
\e$B!3
\e(B ?
\e$B!4
\e(B ?
\e$B!5
\e(B ?
\e$B!6
\e(B ?
\e$B!7
\e(B ?
\e$B!8
\e(B ?
\e$B!9
\e(B ?
\e$B!:
\e(B ?
\e$B!;
\e(B)))
299 (modify-syntax-entry (car chars) "w")
300 (setq chars (cdr chars))))
301 (modify-syntax-entry ?\
\e$B!J
\e(B "(
\e$B!K
\e(B")
302 (modify-syntax-entry ?\
\e$B!N
\e(B "(
\e$B!O
\e(B")
303 (modify-syntax-entry ?\
\e$B!P
\e(B "(
\e$B!Q
\e(B")
304 (modify-syntax-entry ?\
\e$B!V
\e(B "(
\e$B!W
\e(B")
305 (modify-syntax-entry ?\
\e$B!X
\e(B "(
\e$B!Y
\e(B")
306 (modify-syntax-entry ?\
\e$B!K
\e(B ")
\e$B!J
\e(B")
307 (modify-syntax-entry ?\
\e$B!O
\e(B ")
\e$B!N
\e(B")
308 (modify-syntax-entry ?\
\e$B!Q
\e(B ")
\e$B!P
\e(B")
309 (modify-syntax-entry ?\
\e$B!W
\e(B ")
\e$B!V
\e(B")
310 (modify-syntax-entry ?\
\e$B!Y
\e(B ")
\e$B!X
\e(B")
312 (modify-category-entry (make-char 'japanese-jisx0208 35) ?A)
313 (modify-category-entry (make-char 'japanese-jisx0208 36) ?H)
314 (modify-category-entry (make-char 'japanese-jisx0208 37) ?K)
315 (modify-category-entry (make-char 'japanese-jisx0208 38) ?G)
316 (modify-category-entry (make-char 'japanese-jisx0208 39) ?Y)
319 (modify-category-entry (make-char 'japanese-jisx0208 row) ?C)
320 (setq row (1+ row))))
321 (modify-category-entry ?
\e$B!<
\e(B ?K)
322 (let ((chars '(?
\e$B!+
\e(B ?
\e$B!,
\e(B)))
324 (modify-category-entry (car chars) ?K)
325 (modify-category-entry (car chars) ?H)
326 (setq chars (cdr chars))))
327 (let ((chars '(?
\e$B!3
\e(B ?
\e$B!4
\e(B ?
\e$B!5
\e(B ?
\e$B!6
\e(B ?
\e$B!7
\e(B ?
\e$B!8
\e(B ?
\e$B!9
\e(B ?
\e$B!:
\e(B ?
\e$B!;
\e(B)))
329 (modify-category-entry (car chars) ?C)
330 (setq chars (cdr chars))))
333 (modify-syntax-entry (make-char 'japanese-jisx0212) "w")
334 (modify-syntax-entry (make-char 'japanese-jisx0212 33) "_")
335 (modify-syntax-entry (make-char 'japanese-jisx0212 34) "_")
336 (modify-syntax-entry (make-char 'japanese-jisx0212 35) "_")
338 (modify-category-entry (make-char 'japanese-jisx0212 ) ?C)
341 (modify-syntax-entry (make-char 'katakana-jisx0201) "w")
342 (let ((chars '(?
\e(I!
\e(B ?
\e(I"
\e(B ?
\e(I#
\e(B ?
\e(I$
\e(B ?
\e(I%
\e(B)))
344 (modify-syntax-entry (car chars) ".")
345 (setq chars (cdr chars))))
347 ;; Korean character set (KSC5601)
349 (modify-syntax-entry (make-char 'korean-ksc5601) "w")
350 (modify-syntax-entry (make-char 'korean-ksc5601 33) "_")
351 (modify-syntax-entry (make-char 'korean-ksc5601 34) "_")
352 (modify-syntax-entry (make-char 'korean-ksc5601 38) "_")
353 (modify-syntax-entry (make-char 'korean-ksc5601 39) "_")
354 (modify-syntax-entry (make-char 'korean-ksc5601 40) "_")
355 (modify-syntax-entry (make-char 'korean-ksc5601 41) "_")
357 (modify-category-entry (make-char 'korean-ksc5601) ?h)
358 (modify-category-entry (make-char 'korean-ksc5601 35) ?A)
359 (modify-category-entry (make-char 'korean-ksc5601 37) ?G)
360 (modify-category-entry (make-char 'korean-ksc5601 42) ?H)
361 (modify-category-entry (make-char 'korean-ksc5601 43) ?K)
362 (modify-category-entry (make-char 'korean-ksc5601 44) ?Y)
366 (modify-category-entry (make-char 'lao) ?o)
368 (let ((deflist '(;; chars syntax category
369 ("
\e(1!
\e(B-
\e(1N
\e(B" "w" ?0) ; consonant
370 ("
\e(1PRS]`
\e(B-
\e(1d
\e(B" "w" ?1) ; vowel base
371 ("
\e(1QT
\e(B-
\e(1W[m
\e(B" "w" ?2) ; vowel upper
372 ("
\e(1XY
\e(B" "w" ?3) ; vowel lower
373 ("
\e(1h
\e(B-
\e(1l
\e(B" "w" ?4) ; tone mark
374 ("
\e(1\
\e(B" "w" ?9) ; semivowel lower
375 ("
\e(1p
\e(B-
\e(1y
\e(B" "w" ?0) ; digit and misc
376 ("
\e(1Of
\e(B" "_" ?0) ; symbol
378 elm chars len syntax category to ch i)
380 (setq elm (car deflist))
381 (setq chars (car elm)
387 (if (= (aref chars i) ?-)
390 (setq ch (sref chars i)
393 (modify-syntax-entry ch syntax)
394 (modify-category-entry ch category)
396 (setq i (+ i (char-bytes to))))
397 (setq deflist (cdr deflist))))
399 ;; Thai character set (TIS620)
401 (modify-category-entry (make-char 'thai-tis620) ?t)
403 (let ((deflist '(;; chars syntax category
404 ("
\e,T!
\e(B-
\e,TCEG
\e(B-
\e,TN
\e(B" "w" ?0) ; consonant
405 ("
\e,TDFPRS`
\e(B-
\e,Te
\e(B" "w" ?1) ; vowel base
406 ("
\e,TQT
\e(B-
\e,TWgn
\e(B" "w" ?2) ; vowel upper
407 ("
\e,TX
\e(B-
\e,TZ
\e(B" "w" ?3) ; vowel lower
408 ("
\e,Th
\e(B-
\e,Tm
\e(B" "w" ?4) ; tone mark
409 ("
\e,TOfp
\e(B-
\e,Ty
\e(B" "w" ?0) ; digit and misc
410 ("
\e,T_oz{
\e(B" "_" ?0) ; symbol
412 elm chars len syntax category to ch i)
414 (setq elm (car deflist))
415 (setq chars (car elm)
421 (if (= (aref chars i) ?-)
424 (setq ch (sref chars i)
427 (modify-syntax-entry ch syntax)
428 (modify-category-entry ch category)
430 (setq i (+ i (char-bytes to))))
431 (setq deflist (cdr deflist))))
433 ;; Tibetan character set
437 (modify-category-entry (make-char 'tibetan row) ?q)
438 (setq row (1+ row))))
440 (modify-category-entry (make-char 'tibetan-1-column 33) ?q)
442 (let ((deflist '(;; chars syntax category
443 ("
\e$(7"!
\e(B-
\e$(7"J
\e(B" "w" ?0) ; consonant
444 ("
\e$(7#!
\e(B-
\e$(7#J#P#Q
\e(B" "w" ?0) ;
445 ("
\e$(7$!
\e(B-
\e$(7$e
\e(B" "w" ?0) ;
446 ("
\e$(7%!
\e(B-
\e$(7%u
\e(B" "w" ?0) ;
447 ("
\e$(7"S"["\"]"^"a
\e(B" "w" ?2) ; upper vowel
448 ("
\e$(7"_"c"d"g"h"i"j"k"l
\e(B" "w" ?2) ; upper modifier
449 ("
\e$(7!I"Q"U"e!e!g
\e(B" "w" ?3) ; lowel vowel/modifier
450 ("
\e$(7!P
\e(B-
\e$(7!Y!Z
\e(B-
\e$(7!c
\e(B" "w" ?6) ; digit
451 ("
\e$(7!;!=
\e(B-
\e$(7!B!D"`
\e(B" "." ?|) ; line-break char
452 ("
\e$(8!;!=!?!@!A!D"`
\e(B" "." ?|) ;
453 ("
\e$(7!8!;!=
\e(B-
\e$(7!B!D"`!m!d
\e(B" "." ?>) ; prohibition
454 ("
\e$(8!;!=!?!@!A!D"`
\e(B" "." ?>) ;
455 ("
\e$(7!0
\e(B-
\e$(7!:!l#R#S"f
\e(B" "." ?<) ; prohibition
456 ("
\e$(7!C!E
\e(B-
\e$(7!H!J
\e(B-
\e$(7!O!f!h
\e(B-
\e$(7!k!n!o
\e(B" "." ?q) ; others
458 elm chars len syntax category to ch i)
460 (setq elm (car deflist))
461 (setq chars (car elm)
467 (if (= (aref chars i) ?-)
470 (setq ch (sref chars i)
473 (modify-syntax-entry ch syntax)
474 (modify-category-entry ch category)
476 (setq i (+ i (char-bytes to))))
477 (setq deflist (cdr deflist))))
479 ;; Vietnamese character set
481 (let ((lower (make-char 'vietnamese-viscii-lower))
482 (upper (make-char 'vietnamese-viscii-upper)))
483 (modify-syntax-entry lower "w")
484 (modify-syntax-entry upper "w")
485 (modify-category-entry lower ?v)
486 (modify-category-entry upper ?v)
487 (modify-category-entry lower ?l) ; To make a word with
488 (modify-category-entry upper ?l) ; latin characters.
492 ;;; Setting word boundary.
494 (setq word-combining-categories
497 (setq word-separating-categories ; (2-byte character sets)
498 '((?A . ?K) ; Alpha numeric - Katakana
499 (?A . ?C) ; Alpha numeric - Chinese
500 (?H . ?A) ; Hiragana - Alpha numeric
501 (?H . ?K) ; Hiragana - Katakana
502 (?H . ?C) ; Hiragana - Chinese
503 (?K . ?A) ; Katakana - Alpha numeric
504 (?K . ?C) ; Katakana - Chinese
505 (?C . ?A) ; Chinese - Alpha numeric
506 (?C . ?K) ; Chinese - Katakana