1 ;;; characters.el --- set syntax and category for multibyte characters
3 ;; Copyright (C) 1995 Electrotechnical Laboratory, JAPAN.
4 ;; Licensed to the Free Software Foundation.
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-7bit'.
30 ;; This file does not define the syntax for Latin-N character sets;
31 ;; those are defined by the files latin-N.el.
33 ;;; Predefined categories.
35 ;; For each character set.
37 (define-category ?a "ASCII")
38 (define-category ?l "Latin")
39 (define-category ?t "Thai")
40 (define-category ?g "Greek")
41 (define-category ?b "Arabic")
42 (define-category ?w "Hebrew")
43 (define-category ?y "Cyrillic")
44 (define-category ?k "Japanese katakana")
45 (define-category ?r "Japanese roman")
46 (define-category ?c "Chinese")
47 (define-category ?j "Japanese")
48 (define-category ?h "Korean")
49 (define-category ?e "Ethiopic (Ge'ez)")
50 (define-category ?v "Vietnamese")
51 (define-category ?i "Indian")
52 (define-category ?o "Lao")
53 (define-category ?q "Tibetan")
55 ;; For each group (row) of 2-byte character sets.
57 (define-category ?A "Alpha numeric characters of 2-byte character sets")
58 (define-category ?C "Chinese (Han) characters of 2-byte character sets")
59 (define-category ?G "Greek characters of 2-byte characters sets")
60 (define-category ?H "Japanese Hiragana characters of 2-byte character sets")
61 (define-category ?K "Japanese Katakana characters of 2-byte character sets")
62 (define-category ?N "Korean Hangul characters of 2-byte character sets")
63 (define-category ?Y "Cyrillic character of 2-byte character sets")
64 (define-category ?I "Indian Glyphs")
66 ;; For phonetic classifications.
68 (define-category ?0 "consonant")
69 (define-category ?1 "base (independent) vowel")
70 (define-category ?2 "upper diacritical mark (including upper vowel)")
71 (define-category ?3 "lower diacritical mark (including lower vowel)")
72 (define-category ?4 "tone mark")
73 (define-category ?5 "symbol")
74 (define-category ?6 "digit")
75 (define-category ?7 "vowel-modifying diacritical mark")
76 (define-category ?8 "vowel-signs")
77 (define-category ?9 "semivowel lower")
80 (define-category ?| "While filling, we can break a line at this character.")
82 ;; Keep the followings for `kinsoku' processing. See comments in
84 (define-category ?> "A character which can't be placed at beginning of line.")
85 (define-category ?< "A character which can't be placed at end of line.")
88 ;;; Setting syntax and category.
93 (while (< ch 127) ; All ASCII characters have
94 (modify-category-entry ch ?a) ; the category `a' (ASCII)
95 (modify-category-entry ch ?l) ; and `l' (Latin).
98 ;; Arabic character set
100 (let ((charsets '(arabic-iso8859-6
105 (modify-syntax-entry (make-char (car charsets)) "w")
106 (modify-category-entry (make-char (car charsets)) ?b)
107 (setq charsets (cdr charsets))))
109 ;; Chinese character set (GB2312)
111 (modify-syntax-entry (make-char 'chinese-gb2312) "w")
112 (modify-syntax-entry (make-char 'chinese-gb2312 33) "_")
113 (modify-syntax-entry (make-char 'chinese-gb2312 34) "_")
114 (modify-syntax-entry (make-char 'chinese-gb2312 41) "_")
115 (modify-syntax-entry ?\
\e$A!2
\e(B "(
\e$A!3
\e(B")
116 (modify-syntax-entry ?\
\e$A!4
\e(B "(
\e$A!5
\e(B")
117 (modify-syntax-entry ?\
\e$A!6
\e(B "(
\e$A!7
\e(B")
118 (modify-syntax-entry ?\
\e$A!8
\e(B "(
\e$A!9
\e(B")
119 (modify-syntax-entry ?\
\e$A!:
\e(B "(
\e$A!;
\e(B")
120 (modify-syntax-entry ?\
\e$A!<
\e(B "(
\e$A!=
\e(B")
121 (modify-syntax-entry ?\
\e$A!>
\e(B "(
\e$A!?
\e(B")
122 (modify-syntax-entry ?\
\e$A!3
\e(B ")
\e$A!2
\e(B")
123 (modify-syntax-entry ?\
\e$A!5
\e(B ")
\e$A!4
\e(B")
124 (modify-syntax-entry ?\
\e$A!7
\e(B ")
\e$A!6
\e(B")
125 (modify-syntax-entry ?\
\e$A!9
\e(B ")
\e$A!8
\e(B")
126 (modify-syntax-entry ?\
\e$A!;
\e(B ")
\e$A!:
\e(B")
127 (modify-syntax-entry ?\
\e$A!=
\e(B ")
\e$A!<
\e(B")
128 (modify-syntax-entry ?\
\e$A!?
\e(B ")
\e$A!>
\e(B")
130 (modify-category-entry (make-char 'chinese-gb2312) ?c)
131 (modify-category-entry (make-char 'chinese-gb2312) ?\|)
132 (modify-category-entry (make-char 'chinese-gb2312 35) ?A)
133 (modify-category-entry (make-char 'chinese-gb2312 36) ?H)
134 (modify-category-entry (make-char 'chinese-gb2312 37) ?K)
135 (modify-category-entry (make-char 'chinese-gb2312 38) ?G)
136 (modify-category-entry (make-char 'chinese-gb2312 39) ?Y)
137 (modify-category-entry (make-char 'chinese-gb2312 35) ?A)
140 (modify-category-entry (make-char 'chinese-gb2312 row) ?C)
141 (setq row (1+ row))))
143 ;; Chinese character set (BIG5)
145 (let ((generic-big5-1-char (make-char 'chinese-big5-1))
146 (generic-big5-2-char (make-char 'chinese-big5-2)))
147 (modify-syntax-entry generic-big5-1-char "w")
148 (modify-syntax-entry generic-big5-2-char "w")
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 ?C)
154 (modify-category-entry generic-big5-2-char ?C)
156 (modify-category-entry generic-big5-1-char ?\|)
157 (modify-category-entry generic-big5-2-char ?\|))
160 ;; Chinese character set (CNS11643)
162 (let ((cns-list '(chinese-cns11643-1
171 (setq generic-char (make-char (car cns-list)))
172 (modify-syntax-entry generic-char "w")
173 (modify-category-entry generic-char ?c)
174 (modify-category-entry generic-char ?C)
175 (modify-category-entry generic-char ?|)
176 (setq cns-list (cdr cns-list))))
178 ;; Cyrillic character set (ISO-8859-5)
180 (modify-category-entry (make-char 'cyrillic-iso8859-5) ?y)
184 (modify-syntax-entry (make-char 'cyrillic-iso8859-5 c) "w")
186 (modify-syntax-entry ?
\e,L-
\e(B ".")
187 (modify-syntax-entry ?
\e,Lp
\e(B ".")
188 (modify-syntax-entry ?
\e,L}
\e(B ".")
190 ;; Devanagari character set
192 (let ((deflist '(;; chars syntax category
193 ("
\e$(5!!!"!#
\e(B" "w" ?7) ; vowel-modifying diacritical mark
194 ; chandrabindu, anuswar, visarga
195 ("
\e$(5!$
\e(B-
\e$(5!2
\e(B" "w" ?1) ; independent vowel
196 ("
\e$(5!3
\e(B-
\e$(5!X
\e(B" "w" ?0) ; consonant
197 ("
\e$(5!Z
\e(B-
\e$(5!g
\e(B" "w" ?8) ; matra
198 ("
\e$(5!q
\e(B-
\e$(5!z
\e(B" "w" ?6) ; digit
200 elm chars len syntax category to ch i)
202 (setq elm (car deflist))
203 (setq chars (car elm)
209 (if (= (aref chars i) ?-)
212 (setq ch (sref chars i)
215 (modify-syntax-entry ch syntax)
216 (modify-category-entry ch category)
218 (setq i (+ i (char-bytes to))))
219 (setq deflist (cdr deflist))))
221 ;; Ethiopic character set
223 (modify-category-entry (make-char 'ethiopic) ?e)
224 (modify-syntax-entry (make-char 'ethiopic) "w")
225 (let ((chars '(?
\e$(3$h
\e(B ?
\e$(3$i
\e(B ?
\e$(3$j
\e(B ?
\e$(3$k
\e(B ?
\e$(3$l
\e(B ?
\e$(3$m
\e(B ?
\e$(3$n
\e(B ?
\e$(3$o
\e(B ?
\e$(3%i
\e(B ?
\e$(3%t
\e(B ?
\e$(3%u
\e(B ?
\e$(3%v
\e(B ?
\e$(3%w
\e(B ?
\e$(3%x
\e(B)))
227 (modify-syntax-entry (car chars) ".")
228 (setq chars (cdr chars))))
230 ;; European character set (Latin-1,2,3,4,5)
232 (modify-category-entry (make-char 'latin-iso8859-1) ?l)
233 (modify-category-entry (make-char 'latin-iso8859-2) ?l)
234 (modify-category-entry (make-char 'latin-iso8859-3) ?l)
235 (modify-category-entry (make-char 'latin-iso8859-4) ?l)
236 (modify-category-entry (make-char 'latin-iso8859-9) ?l)
238 ;; Greek character set (ISO-8859-7)
240 (modify-category-entry (make-char 'greek-iso8859-7) ?g)
244 (modify-syntax-entry (make-char 'greek-iso8859-7 c) "w")
246 (modify-syntax-entry (make-char 'greek-iso8859-7 160) "w") ; NBSP
247 (modify-syntax-entry ?
\e,F7
\e(B ".")
248 (modify-syntax-entry ?
\e,F;
\e(B ".")
249 (modify-syntax-entry ?
\e,F=
\e(B ".")
251 ;; Hebrew character set (ISO-8859-8)
253 (modify-category-entry (make-char 'hebrew-iso8859-8) ?w)
257 (modify-syntax-entry (make-char 'hebrew-iso8859-8 c) "w")
259 (modify-syntax-entry (make-char 'hebrew-iso8859-8 160) "w") ; NBSP
261 ;; Indian character set (IS 13194 and other Emacs original Indian charsets)
263 (modify-category-entry (make-char 'indian-is13194) ?i)
264 (modify-category-entry (make-char 'indian-2-column) ?I)
265 (modify-category-entry (make-char 'indian-1-column) ?I)
267 ;; Japanese character set (JISX0201-kana, JISX0201-roman, JISX0208, JISX0212)
269 (modify-category-entry (make-char 'katakana-jisx0201) ?k)
270 (modify-category-entry (make-char 'latin-jisx0201) ?r)
271 (modify-category-entry (make-char 'japanese-jisx0208) ?j)
272 (modify-category-entry (make-char 'japanese-jisx0212) ?j)
273 (modify-category-entry (make-char 'katakana-jisx0201) ?\|)
274 (modify-category-entry (make-char 'japanese-jisx0208) ?\|)
275 (modify-category-entry (make-char 'japanese-jisx0212) ?\|)
278 (modify-syntax-entry (make-char 'japanese-jisx0208) "w")
279 (modify-syntax-entry (make-char 'japanese-jisx0208 33) "_")
280 (modify-syntax-entry (make-char 'japanese-jisx0208 34) "_")
281 (modify-syntax-entry (make-char 'japanese-jisx0208 40) "_")
282 (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)))
284 (modify-syntax-entry (car chars) "w")
285 (setq chars (cdr chars))))
286 (modify-syntax-entry ?\
\e$B!J
\e(B "(
\e$B!K
\e(B")
287 (modify-syntax-entry ?\
\e$B!N
\e(B "(
\e$B!O
\e(B")
288 (modify-syntax-entry ?\
\e$B!P
\e(B "(
\e$B!Q
\e(B")
289 (modify-syntax-entry ?\
\e$B!V
\e(B "(
\e$B!W
\e(B")
290 (modify-syntax-entry ?\
\e$B!X
\e(B "(
\e$B!Y
\e(B")
291 (modify-syntax-entry ?\
\e$B!K
\e(B ")
\e$B!J
\e(B")
292 (modify-syntax-entry ?\
\e$B!O
\e(B ")
\e$B!N
\e(B")
293 (modify-syntax-entry ?\
\e$B!Q
\e(B ")
\e$B!P
\e(B")
294 (modify-syntax-entry ?\
\e$B!W
\e(B ")
\e$B!V
\e(B")
295 (modify-syntax-entry ?\
\e$B!Y
\e(B ")
\e$B!X
\e(B")
297 (modify-category-entry (make-char 'japanese-jisx0208 35) ?A)
298 (modify-category-entry (make-char 'japanese-jisx0208 36) ?H)
299 (modify-category-entry (make-char 'japanese-jisx0208 37) ?K)
300 (modify-category-entry (make-char 'japanese-jisx0208 38) ?G)
301 (modify-category-entry (make-char 'japanese-jisx0208 39) ?Y)
304 (modify-category-entry (make-char 'japanese-jisx0208 row) ?C)
305 (setq row (1+ row))))
306 (modify-category-entry ?
\e$B!<
\e(B ?K)
307 (let ((chars '(?
\e$B!+
\e(B ?
\e$B!,
\e(B)))
309 (modify-category-entry (car chars) ?K)
310 (modify-category-entry (car chars) ?H)
311 (setq chars (cdr chars))))
312 (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)))
314 (modify-category-entry (car chars) ?C)
315 (setq chars (cdr chars))))
318 (modify-syntax-entry (make-char 'japanese-jisx0212) "w")
319 (modify-syntax-entry (make-char 'japanese-jisx0212 33) "_")
320 (modify-syntax-entry (make-char 'japanese-jisx0212 34) "_")
321 (modify-syntax-entry (make-char 'japanese-jisx0212 35) "_")
323 (modify-category-entry (make-char 'japanese-jisx0212 ) ?C)
326 (modify-syntax-entry (make-char 'katakana-jisx0201) "w")
327 (let ((chars '(?
\e(I!
\e(B ?
\e(I"
\e(B ?
\e(I#
\e(B ?
\e(I$
\e(B ?
\e(I%
\e(B)))
329 (modify-syntax-entry (car chars) ".")
330 (setq chars (cdr chars))))
332 ;; Korean character set (KSC5601)
334 (modify-syntax-entry (make-char 'korean-ksc5601) "w")
335 (modify-syntax-entry (make-char 'korean-ksc5601 33) "_")
336 (modify-syntax-entry (make-char 'korean-ksc5601 34) "_")
337 (modify-syntax-entry (make-char 'korean-ksc5601 38) "_")
338 (modify-syntax-entry (make-char 'korean-ksc5601 39) "_")
339 (modify-syntax-entry (make-char 'korean-ksc5601 40) "_")
340 (modify-syntax-entry (make-char 'korean-ksc5601 41) "_")
342 (modify-category-entry (make-char 'korean-ksc5601) ?h)
343 (modify-category-entry (make-char 'korean-ksc5601 35) ?A)
344 (modify-category-entry (make-char 'korean-ksc5601 37) ?G)
345 (modify-category-entry (make-char 'korean-ksc5601 42) ?H)
346 (modify-category-entry (make-char 'korean-ksc5601 43) ?K)
347 (modify-category-entry (make-char 'korean-ksc5601 44) ?Y)
351 (modify-category-entry (make-char 'lao) ?o)
353 (let ((deflist '(;; chars syntax category
354 ("
\e(1!
\e(B-
\e(1N
\e(B" "w" ?0) ; consonant
355 ("
\e(1PRS]`
\e(B-
\e(1d
\e(B" "w" ?1) ; vowel base
356 ("
\e(1QT
\e(B-
\e(1W[m
\e(B" "w" ?2) ; vowel upper
357 ("
\e(1XY
\e(B" "w" ?3) ; vowel lower
358 ("
\e(1h
\e(B-
\e(1l
\e(B" "w" ?4) ; tone mark
359 ("
\e(1\
\e(B" "w" ?9) ; semivowel lower
360 ("
\e(1p
\e(B-
\e(1y
\e(B" "w" ?6) ; digit
361 ("
\e(1Of
\e(B" "_" ?0) ; symbol
363 elm chars len syntax category to ch i)
365 (setq elm (car deflist))
366 (setq chars (car elm)
372 (if (= (aref chars i) ?-)
375 (setq ch (sref chars i)
378 (modify-syntax-entry ch syntax)
379 (modify-category-entry ch category)
381 (setq i (+ i (char-bytes to))))
382 (setq deflist (cdr deflist))))
384 ;; Thai character set (TIS620)
386 (modify-category-entry (make-char 'thai-tis620) ?t)
388 (let ((deflist '(;; chars syntax category
389 ("
\e,T!
\e(B-
\e,TCEG
\e(B-
\e,TN
\e(B" "w" ?0) ; consonant
390 ("
\e,TDFPRS`
\e(B-
\e,Te
\e(B" "w" ?1) ; vowel base
391 ("
\e,TQT
\e(B-
\e,TWgn
\e(B" "w" ?2) ; vowel upper
392 ("
\e,TX
\e(B-
\e,TZ
\e(B" "w" ?3) ; vowel lower
393 ("
\e,Th
\e(B-
\e,Tm
\e(B" "w" ?4) ; tone mark
394 ("
\e,Tp
\e(B-
\e,Ty
\e(B" "w" ?6) ; digit
395 ("
\e,TOf_oz{
\e(B" "_" ?5) ; symbol
397 elm chars len syntax category to ch i)
399 (setq elm (car deflist))
400 (setq chars (car elm)
406 (if (= (aref chars i) ?-)
409 (setq ch (sref chars i)
412 (modify-syntax-entry ch syntax)
413 (modify-category-entry ch category)
415 (setq i (+ i (char-bytes to))))
416 (setq deflist (cdr deflist))))
418 ;; Tibetan character set
422 (modify-category-entry (make-char 'tibetan row) ?q)
423 (setq row (1+ row))))
425 (modify-category-entry (make-char 'tibetan-1-column 33) ?q)
427 (let ((deflist '(;; chars syntax category
428 ("
\e$(7"!
\e(B-
\e$(7"J
\e(B" "w" ?0) ; consonant
429 ("
\e$(7#!
\e(B-
\e$(7#J#P#Q
\e(B" "w" ?0) ;
430 ("
\e$(7$!
\e(B-
\e$(7$e
\e(B" "w" ?0) ;
431 ("
\e$(7%!
\e(B-
\e$(7%u
\e(B" "w" ?0) ;
432 ("
\e$(7"S"["\"]"^"a
\e(B" "w" ?2) ; upper vowel
433 ("
\e$(7"_"c"d"g"h"i"j"k"l
\e(B" "w" ?2) ; upper modifier
434 ("
\e$(7!I"Q"U"e!e!g
\e(B" "w" ?3) ; lowel vowel/modifier
435 ("
\e$(7!P
\e(B-
\e$(7!Y!Z
\e(B-
\e$(7!c
\e(B" "w" ?6) ; digit
436 ("
\e$(7!;!=
\e(B-
\e$(7!B!D"`
\e(B" "." ?|) ; line-break char
437 ("
\e$(8!;!=!?!@!A!D"`
\e(B" "." ?|) ;
438 ("
\e$(7!8!;!=
\e(B-
\e$(7!B!D"`!m!d
\e(B" "." ?>) ; prohibition
439 ("
\e$(8!;!=!?!@!A!D"`
\e(B" "." ?>) ;
440 ("
\e$(7!0
\e(B-
\e$(7!:!l#R#S"f
\e(B" "." ?<) ; prohibition
441 ("
\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
443 elm chars len syntax category to ch i)
445 (setq elm (car deflist))
446 (setq chars (car elm)
452 (if (= (aref chars i) ?-)
455 (setq ch (sref chars i)
458 (modify-syntax-entry ch syntax)
459 (modify-category-entry ch category)
461 (setq i (+ i (char-bytes to))))
462 (setq deflist (cdr deflist))))
464 ;; Vietnamese character set
466 (let ((lower (make-char 'vietnamese-viscii-lower))
467 (upper (make-char 'vietnamese-viscii-upper)))
468 (modify-syntax-entry lower "w")
469 (modify-syntax-entry upper "w")
470 (modify-category-entry lower ?v)
471 (modify-category-entry upper ?v)
472 (modify-category-entry lower ?l) ; To make a word with
473 (modify-category-entry upper ?l) ; latin characters.
477 ;;; Setting word boundary.
479 (setq word-combining-categories
482 (setq word-separating-categories ; (2-byte character sets)
483 '((?A . ?K) ; Alpha numeric - Katakana
484 (?A . ?C) ; Alpha numeric - Chinese
485 (?H . ?A) ; Hiragana - Alpha numeric
486 (?H . ?K) ; Hiragana - Katakana
487 (?H . ?C) ; Hiragana - Chinese
488 (?K . ?A) ; Katakana - Alpha numeric
489 (?K . ?C) ; Katakana - Chinese
490 (?C . ?A) ; Chinese - Alpha numeric
491 (?C . ?K) ; Chinese - Katakana