1 ;;; characters.el --- set syntax and category for multibyte characters
3 ;; Copyright (C) 1997, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
4 ;; Free Software Foundation, Inc.
5 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
6 ;; 2005, 2006, 2007, 2008, 2009
7 ;; National Institute of Advanced Industrial Science and Technology (AIST)
8 ;; Registration Number H14PRO021
10 ;; National Institute of Advanced Industrial Science and Technology (AIST)
11 ;; Registration Number H13PRO009
13 ;; Keywords: multibyte character, character set, syntax, category
15 ;; This file is part of GNU Emacs.
17 ;; GNU Emacs is free software: you can redistribute it and/or modify
18 ;; it under the terms of the GNU General Public License as published by
19 ;; the Free Software Foundation, either version 3 of the License, or
20 ;; (at your option) any later version.
22 ;; GNU Emacs is distributed in the hope that it will be useful,
23 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
24 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 ;; GNU General Public License for more details.
27 ;; You should have received a copy of the GNU General Public License
28 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
34 ;;; Predefined categories.
36 ;; For each character set.
38 (define-category ?a "ASCII
39 ASCII graphic characters 32-126 (ISO646 IRV:1983[4/0])")
40 (define-category ?l "Latin")
41 (define-category ?t "Thai")
42 (define-category ?g "Greek")
43 (define-category ?b "Arabic")
44 (define-category ?w "Hebrew")
45 (define-category ?y "Cyrillic")
46 (define-category ?k "Katakana
48 (define-category ?r "Roman
50 (define-category ?c "Chinese")
51 (define-category ?j "Japanese")
52 (define-category ?h "Korean")
53 (define-category ?e "Ethiopic
55 (define-category ?v "Viet
57 (define-category ?i "Indian")
58 (define-category ?o "Lao")
59 (define-category ?q "Tibetan")
61 ;; For each group (row) of 2-byte character sets.
63 (define-category ?A "2-byte alnum
64 Alpha-numeric characters of 2-byte character sets")
65 (define-category ?C "2-byte han
66 Chinese (Han) characters of 2-byte character sets")
67 (define-category ?G "2-byte Greek
68 Greek characters of 2-byte character sets")
69 (define-category ?H "2-byte Hiragana
70 Japanese Hiragana characters of 2-byte character sets")
71 (define-category ?K "2-byte Katakana
72 Japanese Katakana characters of 2-byte character sets")
73 (define-category ?N "2-byte Korean
74 Korean Hangul characters of 2-byte character sets")
75 (define-category ?Y "2-byte Cyrillic
76 Cyrillic characters of 2-byte character sets")
77 (define-category ?I "Indian Glyphs")
79 ;; For phonetic classifications.
81 (define-category ?0 "consonant")
82 (define-category ?1 "base vowel
83 base (independent) vowel")
84 (define-category ?2 "upper diacritic
85 upper diacritical mark (including upper vowel)")
86 (define-category ?3 "lower diacritic
87 lower diacritical mark (including lower vowel)")
88 (define-category ?4 "combining tone
90 (define-category ?5 "symbol")
91 (define-category ?6 "digit")
92 (define-category ?7 "vowel diacritic
93 vowel-modifying diacritical mark")
94 (define-category ?8 "vowel-signs")
95 (define-category ?9 "semivowel lower")
98 (define-category ?| "line breakable
99 While filling, we can break a line at this character.")
101 ;; For indentation calculation.
104 This character counts as a space for indentation purposes.")
106 ;; Keep the following for `kinsoku' processing. See comments in
108 (define-category ?> "Not at bol
109 A character which can't be placed at beginning of line.")
110 (define-category ?< "Not at eol
111 A character which can't be placed at end of line.")
114 (define-category ?^ "Combining
115 Combining diacritic or mark")
117 ;;; Setting syntax and category.
121 ;; All ASCII characters have the category `a' (ASCII) and `l' (Latin).
122 (modify-category-entry '(32 . 127) ?a)
123 (modify-category-entry '(32 . 127) ?l)
125 ;; Deal with the CJK charsets first. Since the syntax of blocks is
126 ;; defined per charset, and the charsets may contain e.g. Latin
127 ;; characters, we end up with the wrong syntax definitions if we're
130 ;; Chinese characters (Unicode)
131 (modify-category-entry '(#x2E80 . #x312F) ?|)
132 (modify-category-entry '(#x3190 . #x33FF) ?|)
133 (modify-category-entry '(#x3400 . #x9FAF) ?C)
134 (modify-category-entry '(#x3400 . #x9FAF) ?c)
135 (modify-category-entry '(#x3400 . #x9FAF) ?|)
136 (modify-category-entry '(#xF900 . #xFAFF) ?C)
137 (modify-category-entry '(#xF900 . #xFAFF) ?c)
138 (modify-category-entry '(#xF900 . #xFAFF) ?|)
139 (modify-category-entry '(#x20000 . #x2AFFF) ?|)
140 (modify-category-entry '(#x2F800 . #x2FFFF) ?|)
141 (modify-category-entry '(#x20000 . #x2AFFF) ?C)
142 (modify-category-entry '(#x2F800 . #x2FFFF) ?C)
145 ;; Chinese character set (GB2312)
147 (map-charset-chars #'modify-syntax-entry 'chinese-gb2312 "_" #x2121 #x217E)
148 (map-charset-chars #'modify-syntax-entry 'chinese-gb2312 "_" #x2221 #x227E)
149 (map-charset-chars #'modify-syntax-entry 'chinese-gb2312 "_" #x2921 #x297E)
151 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?c)
152 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?A #x2330 #x2339)
153 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?A #x2341 #x235A)
154 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?A #x2361 #x237A)
155 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?H #x2421 #x247E)
156 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?K #x2521 #x257E)
157 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?G #x2621 #x267E)
158 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?Y #x2721 #x277E)
159 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?C #x3021 #x7E7E)
161 ;; Chinese character set (BIG5)
163 (map-charset-chars #'modify-category-entry 'big5 ?c)
164 (map-charset-chars #'modify-category-entry 'big5 ?C #xA259 #xA25F)
165 (map-charset-chars #'modify-category-entry 'big5 ?C #xA440 #xC67E)
166 (map-charset-chars #'modify-category-entry 'big5 ?C #xC940 #xF9DF)
168 ;; Chinese character set (CNS11643)
170 (dolist (c '(chinese-cns11643-1 chinese-cns11643-2 chinese-cns11643-3
171 chinese-cns11643-4 chinese-cns11643-5 chinese-cns11643-6
173 (map-charset-chars #'modify-category-entry c ?c)
174 (if (eq c 'chinese-cns11643-1)
175 (map-charset-chars #'modify-category-entry c ?C #x4421 #x7E7E)
176 (map-charset-chars #'modify-category-entry c ?C)))
178 ;; Japanese character set (JISX0201, JISX0208, JISX0212, JISX0213)
180 (map-charset-chars #'modify-category-entry 'katakana-jisx0201 ?k)
182 (map-charset-chars #'modify-category-entry 'latin-jisx0201 ?r)
184 (dolist (l '(katakana-jisx0201 japanese-jisx0208 japanese-jisx0212
185 japanese-jisx0213-1 japanese-jisx0213-2))
186 (map-charset-chars #'modify-category-entry l ?j))
188 ;; Unicode equivalents of JISX0201-kana
189 (let ((range '(#xff61 . #xff9f)))
190 (modify-category-entry range ?k)
191 (modify-category-entry range ?j)
192 (modify-category-entry range ?\|))
195 (let ((range '(#x30a0 . #x30ff)))
196 ;; ?K is double width, ?k isn't specified
197 (modify-category-entry range ?K)
198 (modify-category-entry range ?\|))
201 (let ((range '(#x3040 . #x309d)))
202 ;; ?H is actually defined to be double width
203 ;;(modify-category-entry range ?H)
204 (modify-category-entry range ?\|)
208 (map-charset-chars #'modify-syntax-entry 'japanese-jisx0208 "_" #x2121 #x227E)
209 (map-charset-chars #'modify-syntax-entry 'japanese-jisx0208 "_" #x2821 #x287E)
210 (let ((chars '(?ー ?゛ ?゜ ?ヽ ?ヾ ?ゝ ?ゞ ?〃 ?仝 ?々 ?〆 ?〇)))
212 (modify-syntax-entry (car chars) "w")))
214 (map-charset-chars #'modify-category-entry 'japanese-jisx0208 ?A #x2321 #x237E)
215 (map-charset-chars #'modify-category-entry 'japanese-jisx0208 ?H #x2421 #x247E)
216 (map-charset-chars #'modify-category-entry 'japanese-jisx0208 ?K #x2521 #x257E)
217 (map-charset-chars #'modify-category-entry 'japanese-jisx0208 ?G #x2621 #x267E)
218 (map-charset-chars #'modify-category-entry 'japanese-jisx0208 ?Y #x2721 #x277E)
219 (map-charset-chars #'modify-category-entry 'japanese-jisx0208 ?C #x3021 #x7E7E)
220 (modify-category-entry ?ー ?K)
221 (let ((chars '(?゛ ?゜)))
223 (modify-category-entry (car chars) ?K)
224 (modify-category-entry (car chars) ?H)
225 (setq chars (cdr chars))))
226 (let ((chars '(?ヽ ?ヾ ?ゝ ?ゞ ?〃 ?仝 ?々 ?〆 ?〇)))
228 (modify-category-entry (car chars) ?C)
229 (setq chars (cdr chars))))
233 (map-charset-chars #'modify-syntax-entry 'japanese-jisx0212 "_" #x2121 #x237E)
237 (let ((chars '(?。 ?、 ?・)))
239 (modify-syntax-entry (car chars) ".")
240 (setq chars (cdr chars))))
242 (modify-syntax-entry ?\「 "(」")
243 (modify-syntax-entry ?\」 "(「")
245 ;; Korean character set (KSC5601)
247 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?h)
249 (map-charset-chars #'modify-syntax-entry 'korean-ksc5601 "_" #x2121 #x227E)
250 (map-charset-chars #'modify-syntax-entry 'korean-ksc5601 "_" #x2621 #x277E)
251 (map-charset-chars #'modify-syntax-entry 'korean-ksc5601 "_" #x2830 #x287E)
252 (map-charset-chars #'modify-syntax-entry 'korean-ksc5601 "_" #x2930 #x297E)
253 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?A #x2330 #x2339)
254 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?A #x2341 #x235A)
255 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?A #x2361 #x237A)
256 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?G #x2521 #x257E)
257 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?H #x2A21 #x2A7E)
258 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?K #x2B21 #x2B7E)
259 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?Y #x2C21 #x2C7E)
261 ;; These are in more than one charset.
262 (let ((parens (concat "〈〉《》「」『』【】〔〕〖〗〘〙〚〛"
266 (dotimes (i (/ (length parens) 2))
267 (setq open (aref parens (* i 2))
268 close (aref parens (1+ (* i 2))))
269 (modify-syntax-entry open (format "(%c" close))
270 (modify-syntax-entry close (format ")%c" open))))
272 ;; Arabic character set
274 (let ((charsets '(arabic-iso8859-6
279 (map-charset-chars #'modify-category-entry (car charsets) ?b)
280 (setq charsets (cdr charsets))))
281 (modify-category-entry '(#x600 . #x6ff) ?b)
282 (modify-category-entry '(#xfb50 . #xfdff) ?b)
283 (modify-category-entry '(#xfe70 . #xfefe) ?b)
285 ;; Cyrillic character set (ISO-8859-5)
287 (modify-syntax-entry ?№ ".")
289 ;; Ethiopic character set
291 (modify-category-entry '(#x1200 . #x1399) ?e)
292 (modify-category-entry '(#x2d80 . #x2dde) ?e)
293 (let ((chars '(?፡ ?። ?፣ ?፤ ?፥ ?፦ ?፧ ?፨)))
295 (modify-syntax-entry (car chars) ".")
296 (setq chars (cdr chars))))
297 (map-charset-chars #'modify-category-entry 'ethiopic ?e)
299 ;; Hebrew character set (ISO-8859-8)
301 (modify-syntax-entry #x5be ".") ; MAQAF
302 (modify-syntax-entry #x5c0 ".") ; PASEQ
303 (modify-syntax-entry #x5c3 ".") ; SOF PASUQ
304 (modify-syntax-entry #x5f3 ".") ; GERESH
305 (modify-syntax-entry #x5f4 ".") ; GERSHAYIM
307 ;; Indian character set (IS 13194 and other Emacs original Indian charsets)
309 (modify-category-entry '(#x901 . #x970) ?i)
310 (map-charset-chars #'modify-category-entry 'indian-is13194 ?i)
311 (map-charset-chars #'modify-category-entry 'indian-2-column ?i)
315 (modify-category-entry '(#xe80 . #xeff) ?o)
316 (map-charset-chars #'modify-category-entry 'lao ?o)
318 (let ((deflist '(("ກ-ຮ" "w" ?0) ; consonant
319 ("ະາຳຽເ-ໄ" "w" ?1) ; vowel base
320 ("ັິ-ືົໍ" "w" ?2) ; vowel upper
321 ("ຸູ" "w" ?3) ; vowel lower
322 ("່-໋" "w" ?4) ; tone mark
323 ("ຼຽ" "w" ?9) ; semivowel lower
324 ("໐-໙" "w" ?6) ; digit
325 ("ຯໆ" "_" ?5) ; symbol
327 elm chars len syntax category to ch i)
329 (setq elm (car deflist))
330 (setq chars (car elm)
336 (if (= (aref chars i) ?-)
339 (setq ch (aref chars i)
342 (unless (string-equal syntax "w")
343 (modify-syntax-entry ch syntax))
344 (modify-category-entry ch category)
347 (setq deflist (cdr deflist))))
349 ;; Thai character set (TIS620)
351 (modify-category-entry '(#xe00 . #xe7f) ?t)
352 (map-charset-chars #'modify-category-entry 'thai-tis620 ?t)
354 (let ((deflist '(;; chars syntax category
355 ("ก-รลว-ฮ" "w" ?0) ; consonant
356 ("ฤฦะาำเ-ๅ" "w" ?1) ; vowel base
357 ("ัิ-ื็๎" "w" ?2) ; vowel upper
358 ("ุ-ฺ" "w" ?3) ; vowel lower
359 ("่-ํ" "w" ?4) ; tone mark
360 ("๐-๙" "w" ?6) ; digit
361 ("ฯๆ฿๏๚๛" "_" ?5) ; 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 (aref chars i)
378 (unless (string-equal syntax "w")
379 (modify-syntax-entry ch syntax))
380 (modify-category-entry ch category)
383 (setq deflist (cdr deflist))))
385 ;; Tibetan character set
387 (modify-category-entry '(#xf00 . #xfff) ?q)
388 (map-charset-chars #'modify-category-entry 'tibetan ?q)
389 (map-charset-chars #'modify-category-entry 'tibetan-1-column ?q)
391 (let ((deflist '(;; chars syntax category
392 ("ཀ-ཀྵཪ" "w" ?0) ; consonant
394 ("ིེཻོཽྀ" "w" ?2) ; upper vowel
395 ("ཾྂྃ྆྇ྈྉྊྋ" "w" ?2) ; upper modifier
396 ("྄ཱུ༙༵༷" "w" ?3) ; lowel vowel/modifier
397 ("" "w" ?3) ; invisible vowel a
398 ("༠-༩༪-༳" "w" ?6) ; digit
399 ("་།-༒༔ཿ" "." ?|) ; line-break char
401 ("༈་།-༒༔ཿ༽༴" "." ?>) ; prohibition
403 ("ༀ-༊༼࿁࿂྅" "." ?<) ; prohibition
404 ("༓༕-༘༚-༟༶༸-༻༾༿྾྿-࿏" "." ?q) ; others
406 elm chars len syntax category to ch i)
408 (setq elm (car deflist))
409 (setq chars (car elm)
415 (if (= (aref chars i) ?-)
418 (setq ch (aref chars i)
421 (unless (string-equal syntax "w")
422 (modify-syntax-entry ch syntax))
423 (modify-category-entry ch category)
426 (setq deflist (cdr deflist))))
428 ;; Vietnamese character set
430 ;; To make a word with Latin characters
431 (map-charset-chars #'modify-category-entry 'vietnamese-viscii-lower ?l)
432 (map-charset-chars #'modify-category-entry 'vietnamese-viscii-lower ?v)
434 (map-charset-chars #'modify-category-entry 'vietnamese-viscii-upper ?l)
435 (map-charset-chars #'modify-category-entry 'vietnamese-viscii-upper ?v)
437 (let ((tbl (standard-case-table))
440 (let* ((char (decode-char 'vietnamese-viscii-upper i))
441 (charl (decode-char 'vietnamese-viscii-lower i))
442 (uc (encode-char char 'ucs))
443 (lc (encode-char charl 'ucs)))
444 (set-case-syntax-pair char (decode-char 'vietnamese-viscii-lower i)
446 (if uc (modify-category-entry uc ?v))
447 (if lc (modify-category-entry lc ?v)))
451 (let ((deflist '(;; chars syntax category
452 ((?ꪀ. ?ꪯ) "w" ?0) ; cosonant
453 ("ꪱꪵꪶ" "w" ?1) ; vowel base
454 ((?ꪹ . ?ꪽ) "w" ?1) ; vowel base
455 ("ꪰꪲꪳꪷꪸꪾ" "w" ?2) ; vowel upper
456 ("ꪴ" "w" ?3) ; vowel lower
457 ("ꫀꫂ" "w" ?1) ; non-combining tone-mark
458 ("꪿꫁" "w" ?4) ; combining tone-mark
459 ((?ꫛ . ?꫟) "_" ?5) ; symbol
461 (dolist (elm deflist)
462 (let ((chars (car elm))
464 (category (nth 2 elm)))
467 (modify-syntax-entry chars syntax)
468 (modify-category-entry chars category))
470 (modify-syntax-entry x syntax)
471 (modify-category-entry x category))
476 (modify-category-entry '(#x80 . #x024F) ?l)
478 (let ((tbl (standard-case-table)) c)
482 ;; Fixme: Some of the non-word syntaxes here perhaps should be
483 ;; reviewed. (Note that the following all implicitly have word
484 ;; syntax: ¢£¤¥¨ª¯²³´¶¸¹º.) There should be a well-defined way of
485 ;; relating Unicode categories to Emacs syntax codes.
487 ;; NBSP isn't semantically interchangeable with other whitespace chars,
488 ;; so it's more like punctation.
489 (set-case-syntax ? "." tbl)
490 (set-case-syntax ?¡ "." tbl)
491 (set-case-syntax ?¦ "_" tbl)
492 (set-case-syntax ?§ "." tbl)
493 (set-case-syntax ?© "_" tbl)
494 (set-case-syntax-delims 171 187 tbl) ; « »
495 (set-case-syntax ?¬ "_" tbl)
496 (set-case-syntax ? "_" tbl)
497 (set-case-syntax ?® "_" tbl)
498 (set-case-syntax ?° "_" tbl)
499 (set-case-syntax ?± "_" tbl)
500 (set-case-syntax ?µ "_" tbl)
501 (set-case-syntax ?· "_" tbl)
502 (set-case-syntax ?¼ "_" tbl)
503 (set-case-syntax ?½ "_" tbl)
504 (set-case-syntax ?¾ "_" tbl)
505 (set-case-syntax ?¿ "." tbl)
508 (set-case-syntax-pair c (+ c 32) tbl)
510 (set-case-syntax ?× "_" tbl)
511 (set-case-syntax ?ß "w" tbl)
512 (set-case-syntax ?÷ "_" tbl)
515 ;; Latin Extended-A, Latin Extended-B
518 (modify-category-entry c ?l)
521 (let ((pair-ranges '((#x0100 . #x012F)
544 (dolist (elt pair-ranges)
545 (let ((from (car elt)) (to (cdr elt)))
547 (set-case-syntax-pair from (1+ from) tbl)
548 (setq from (+ from 2))))))
550 ;; In some languages, such as Turkish, U+0049 LATIN CAPITAL LETTER I
551 ;; and U+0131 LATIN SMALL LETTER DOTLESS I make a case pair, and so
552 ;; do U+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE and U+0069 LATIN
555 ;; We used to set up half of those correspondence unconditionally,
556 ;; but that makes searches slow. So now we don't set up either half
557 ;; of these correspondences by default.
559 ;; (set-downcase-syntax ?İ ?i tbl)
560 ;; (set-upcase-syntax ?I ?ı tbl)
562 (set-case-syntax-pair ?DŽ ?dž tbl)
563 (set-case-syntax-pair ?Dž ?dž tbl)
564 (set-case-syntax-pair ?LJ ?lj tbl)
565 (set-case-syntax-pair ?Lj ?lj tbl)
566 (set-case-syntax-pair ?NJ ?nj tbl)
567 (set-case-syntax-pair ?Nj ?nj tbl)
569 ;; 01F0; F; 006A 030C; # LATIN SMALL LETTER J WITH CARON
570 (set-case-syntax-pair ?DZ ?dz tbl)
571 (set-case-syntax-pair ?Dz ?dz tbl)
572 (set-case-syntax-pair ?Ƕ ?ƕ tbl)
573 (set-case-syntax-pair ?Ƿ ?ƿ tbl)
575 ;; Latin Extended Additional
576 (modify-category-entry '(#x1e00 . #x1ef9) ?l)
580 (or (<= c #x1e94) (>= c #x1ea0))
581 (set-case-syntax-pair c (1+ c) tbl))
585 (modify-category-entry '(#x0370 . #x03ff) ?g)
588 (if (or (and (>= c #x0391) (<= c #x03a1))
589 (and (>= c #x03a3) (<= c #x03ab)))
590 (set-case-syntax-pair c (+ c 32) tbl))
594 (set-case-syntax-pair c (1+ c) tbl))
596 (set-case-syntax-pair ?Ά ?ά tbl)
597 (set-case-syntax-pair ?Έ ?έ tbl)
598 (set-case-syntax-pair ?Ή ?ή tbl)
599 (set-case-syntax-pair ?Ί ?ί tbl)
600 (set-case-syntax-pair ?Ό ?ό tbl)
601 (set-case-syntax-pair ?Ύ ?ύ tbl)
602 (set-case-syntax-pair ?Ώ ?ώ tbl)
607 (set-case-syntax-pair c (+ c #x30) tbl)
611 (modify-category-entry '(#x1f00 . #x1fff) ?g)
614 (and (<= (logand c #x000f) 7)
616 (not (memq c '(#x1f50 #x1f52 #x1f54 #x1f56)))
617 (/= (logand c #x00f0) 7)
618 (set-case-syntax-pair (+ c 8) c tbl))
620 (set-case-syntax-pair ?Ᾰ ?ᾰ tbl)
621 (set-case-syntax-pair ?Ᾱ ?ᾱ tbl)
622 (set-case-syntax-pair ?Ὰ ?ὰ tbl)
623 (set-case-syntax-pair ?Ά ?ά tbl)
624 (set-case-syntax-pair ?ᾼ ?ᾳ tbl)
625 (set-case-syntax-pair ?Ὲ ?ὲ tbl)
626 (set-case-syntax-pair ?Έ ?έ tbl)
627 (set-case-syntax-pair ?Ὴ ?ὴ tbl)
628 (set-case-syntax-pair ?Ή ?ή tbl)
629 (set-case-syntax-pair ?ῌ ?ῃ tbl)
630 (set-case-syntax-pair ?Ῐ ?ῐ tbl)
631 (set-case-syntax-pair ?Ῑ ?ῑ tbl)
632 (set-case-syntax-pair ?Ὶ ?ὶ tbl)
633 (set-case-syntax-pair ?Ί ?ί tbl)
634 (set-case-syntax-pair ?Ῠ ?ῠ tbl)
635 (set-case-syntax-pair ?Ῡ ?ῡ tbl)
636 (set-case-syntax-pair ?Ὺ ?ὺ tbl)
637 (set-case-syntax-pair ?Ύ ?ύ tbl)
638 (set-case-syntax-pair ?Ῥ ?ῥ tbl)
639 (set-case-syntax-pair ?Ὸ ?ὸ tbl)
640 (set-case-syntax-pair ?Ό ?ό tbl)
641 (set-case-syntax-pair ?Ὼ ?ὼ tbl)
642 (set-case-syntax-pair ?Ώ ?ώ tbl)
643 (set-case-syntax-pair ?ῼ ?ῳ tbl)
646 (modify-category-entry '(#x0400 . #x04FF) ?y)
651 (set-case-syntax-pair c (+ c 80) tbl))
654 (set-case-syntax-pair c (+ c 32) tbl))
656 (or (and (>= c #x0460) (<= c #x0480))
657 (and (>= c #x048c) (<= c #x04be))
658 (and (>= c #x04d0) (<= c #x04f4)))
659 (set-case-syntax-pair c (1+ c) tbl))
661 (set-case-syntax-pair ?Ӂ ?ӂ tbl)
662 (set-case-syntax-pair ?Ӄ ?ӄ tbl)
663 (set-case-syntax-pair ?Ӈ ?ӈ tbl)
664 (set-case-syntax-pair ?Ӌ ?ӌ tbl)
665 (set-case-syntax-pair ?Ӹ ?ӹ tbl)
667 ;; general punctuation
670 (set-case-syntax c " " tbl)
673 (set-case-syntax c "." tbl)
675 ;; Fixme: These aren't all right:
678 (set-case-syntax c "_" tbl)
680 ;; Punctuation syntax for quotation marks (like `)
682 (set-case-syntax c "." tbl)
684 ;; Fixme: These aren't all right:
686 (set-case-syntax c "_" tbl)
689 (set-case-syntax c "." tbl)
695 (set-case-syntax-pair c (+ c #x10) tbl)
698 ;; Fixme: The following blocks might be better as symbol rather than
703 (set-case-syntax c "." tbl)
705 ;; Mathematical Operators
707 (set-case-syntax c "." tbl)
709 ;; Miscellaneous Technical
711 (set-case-syntax c "." tbl)
715 (set-case-syntax c "_" tbl)
721 (set-case-syntax-pair c (+ c 26) tbl)
722 (modify-category-entry c ?l)
723 (modify-category-entry (+ c 26) ?l)
729 (set-case-syntax-pair c (+ c #x20) tbl)
730 (modify-category-entry c ?l)
731 (modify-category-entry (+ c #x20) ?l)
734 ;; Combining diacritics
735 (modify-category-entry '(#x300 . #x362) ?^)
737 (modify-category-entry '(#x20d0 . #x20e3) ?^)
739 ;; Fixme: syntax for symbols &c
743 '("⁅⁆" ; U+2045 U+2046
797 (modify-syntax-entry (aref elt 0) (string ?\( (aref elt 1)))
798 (modify-syntax-entry (aref elt 1) (string ?\) (aref elt 0)))))
801 ;; For each character set, put the information of the most proper
802 ;; coding system to encode it by `preferred-coding-system' property.
804 ;; Fixme: should this be junked?
805 (let ((l '((latin-iso8859-1 . iso-latin-1)
806 (latin-iso8859-2 . iso-latin-2)
807 (latin-iso8859-3 . iso-latin-3)
808 (latin-iso8859-4 . iso-latin-4)
809 (thai-tis620 . thai-tis620)
810 (greek-iso8859-7 . greek-iso-8bit)
811 (arabic-iso8859-6 . iso-2022-7bit)
812 (hebrew-iso8859-8 . hebrew-iso-8bit)
813 (katakana-jisx0201 . japanese-shift-jis)
814 (latin-jisx0201 . japanese-shift-jis)
815 (cyrillic-iso8859-5 . cyrillic-iso-8bit)
816 (latin-iso8859-9 . iso-latin-5)
817 (japanese-jisx0208-1978 . iso-2022-jp)
818 (chinese-gb2312 . chinese-iso-8bit)
819 (chinese-gbk . chinese-gbk)
820 (gb18030-2-byte . chinese-gb18030)
821 (gb18030-4-byte-bmp . chinese-gb18030)
822 (gb18030-4-byte-smp . chinese-gb18030)
823 (gb18030-4-byte-ext-1 . chinese-gb18030)
824 (gb18030-4-byte-ext-2 . chinese-gb18030)
825 (japanese-jisx0208 . iso-2022-jp)
826 (korean-ksc5601 . iso-2022-kr)
827 (japanese-jisx0212 . iso-2022-jp)
828 (chinese-big5-1 . chinese-big5)
829 (chinese-big5-2 . chinese-big5)
830 (chinese-sisheng . iso-2022-7bit)
831 (ipa . iso-2022-7bit)
832 (vietnamese-viscii-lower . vietnamese-viscii)
833 (vietnamese-viscii-upper . vietnamese-viscii)
834 (arabic-digit . iso-2022-7bit)
835 (arabic-1-column . iso-2022-7bit)
837 (arabic-2-column . iso-2022-7bit)
838 (indian-is13194 . devanagari)
839 (indian-glyph . devanagari)
840 (tibetan-1-column . tibetan)
841 (ethiopic . iso-2022-7bit)
842 (chinese-cns11643-1 . iso-2022-cn)
843 (chinese-cns11643-2 . iso-2022-cn)
844 (chinese-cns11643-3 . iso-2022-cn)
845 (chinese-cns11643-4 . iso-2022-cn)
846 (chinese-cns11643-5 . iso-2022-cn)
847 (chinese-cns11643-6 . iso-2022-cn)
848 (chinese-cns11643-7 . iso-2022-cn)
849 (indian-2-column . devanagari)
851 (latin-iso8859-14 . iso-latin-8)
852 (latin-iso8859-15 . iso-latin-9))))
854 (put-charset-property (car (car l)) 'preferred-coding-system (cdr (car l)))
858 ;; Setup auto-fill-chars for charsets that should invoke auto-filling.
859 ;; SPACE and NEWLINE are already set.
861 (set-char-table-range auto-fill-chars '(#x3041 . #x30FF) t)
862 (set-char-table-range auto-fill-chars '(#x3400 . #x4DB5) t)
863 (set-char-table-range auto-fill-chars '(#x4e00 . #x9fbb) t)
864 (set-char-table-range auto-fill-chars '(#xF900 . #xFAFF) t)
865 (set-char-table-range auto-fill-chars '(#xFF00 . #xFF9F) t)
866 (set-char-table-range auto-fill-chars '(#x20000 . #x2FFFF) t)
869 ;;; Setting char-width-table. The default is 1.
871 ;; 0: non-spacing, enclosing combining, formatting, Hangul Jamo medial
872 ;; and final characters.
873 (let ((l '((#x0300 . #x036F)
996 (#xE0001 . #xE01EF))))
998 (set-char-table-range char-width-table elt 0)))
1000 ;; 2: East Asian Wide and Full-width characters.
1001 (let ((l '((#x1100 . #x115F)
1011 (#x30000 . #x3FFFF))))
1013 (set-char-table-range char-width-table elt 2)))
1015 ;; Other double width
1016 ;;(map-charset-chars
1017 ;; (lambda (range ignore) (set-char-table-range char-width-table range 2))
1019 ;; (map-charset-chars
1020 ;; (lambda (range ignore) (set-char-table-range char-width-table range 2))
1023 (lambda (range ignore) (set-char-table-range char-width-table range 2))
1026 (lambda (range ignore) (set-char-table-range char-width-table range 2))
1029 (defvar cjk-char-width-table
1030 (let ((table (make-char-table nil)))
1031 (dolist (charset '(big5 chinese-gb2312 chinese-cns11643-1
1032 japanese-jisx0208 korean-ksc5601))
1033 (map-charset-chars #'(lambda (range arg)
1034 (set-char-table-range table range 2))
1036 (optimize-char-table table)
1037 (set-char-table-parent table char-width-table)
1039 "Character width table used in CJK language environment.")
1041 (defun use-cjk-char-width-table ()
1043 Setup char-width-table appropriate for CJK language environment."
1044 (setq char-width-table cjk-char-width-table))
1046 (defun use-default-char-width-table ()
1048 Setup char-width-table appropriate for non-CJK language environment."
1049 (setq char-width-table (char-table-parent cjk-char-width-table)))
1051 (optimize-char-table (standard-case-table))
1052 (optimize-char-table (standard-category-table))
1053 (optimize-char-table (standard-syntax-table))
1056 ;; Setting char-script-table.
1058 ;; The Unicode blocks actually extend past some of these ranges with
1059 ;; undefined codepoints.
1060 (let ((script-list nil))
1063 '((#x0000 #x007F latin)
1064 (#x00A0 #x024F latin)
1065 (#x0250 #x02AF phonetic)
1066 (#x02B0 #x036F latin)
1067 (#x0370 #x03E1 greek)
1068 (#x03E2 #x03EF coptic)
1069 (#x03F0 #x03F3 greek)
1070 (#x0400 #x04FF cyrillic)
1071 (#x0530 #x058F armenian)
1072 (#x0590 #x05FF hebrew)
1073 (#x0600 #x06FF arabic)
1074 (#x0700 #x074F syriac)
1076 (#x0780 #x07BF thaana)
1077 (#x0900 #x097F devanagari)
1078 (#x0980 #x09FF bengali)
1079 (#x0A00 #x0A7F gurmukhi)
1080 (#x0A80 #x0AFF gujarati)
1081 (#x0B00 #x0B7F oriya)
1082 (#x0B80 #x0BFF tamil)
1083 (#x0C00 #x0C7F telugu)
1084 (#x0C80 #x0CFF kannada)
1085 (#x0D00 #x0D7F malayalam)
1086 (#x0D80 #x0DFF sinhala)
1087 (#x0E00 #x0E5F thai)
1089 (#x0F00 #x0FFF tibetan)
1090 (#x1000 #x105F myanmar)
1091 (#x10A0 #x10FF georgian)
1092 (#x1100 #x11FF hangul)
1093 (#x1200 #x139F ethiopic)
1094 (#x13A0 #x13FF cherokee)
1095 (#x1400 #x167F canadian-aboriginal)
1096 (#x1680 #x169F ogham)
1097 (#x16A0 #x16FF runic)
1098 (#x1780 #x17FF khmer)
1099 (#x1800 #x18AF mongolian)
1100 (#x1D00 #x1DFF phonetic)
1101 (#x1E00 #x1EFF latin)
1102 (#x1F00 #x1FFF greek)
1103 (#x2000 #x27FF symbol)
1104 (#x2800 #x28FF braille)
1105 (#x2D80 #x2DDF ethiopic)
1107 (#x2FF0 #x2FFF ideographic-description)
1108 (#x3000 #x303F cjk-misc)
1109 (#x3040 #x30FF kana)
1110 (#x3100 #x312F bopomofo)
1111 (#x3130 #x318F hangul)
1112 (#x3190 #x319F kanbun)
1113 (#x31A0 #x31BF bopomofo)
1116 (#xAA00 #xAA5F cham)
1117 (#xAA80 #xAADF tai-viet)
1118 (#xAC00 #xD7AF hangul)
1120 (#xFB1D #xFB4F hebrew)
1121 (#xFB50 #xFDFF arabic)
1122 (#xFE70 #xFEFC arabic)
1123 (#xFF00 #xFF5F cjk-misc)
1124 (#xFF61 #xFF9F kana)
1125 (#xFFE0 #xFFE6 cjk-misc)
1126 (#x10000 #x100FF linear-b)
1127 (#x10100 #x1013F aegean-number)
1128 (#x10140 #x1018A ancient-greek-number)
1129 (#x10190 #x1019B ancient-symbol)
1130 (#x101D0 #x101FF phaistos-disc)
1131 (#x10280 #x1029F lycian)
1132 (#x102A0 #x102DF carian)
1133 (#x10300 #x1032F olt-italic)
1134 (#x10380 #x1039F ugaritic)
1135 (#x103A0 #x103DF old-persian)
1136 (#x10400 #x1044F deseret)
1137 (#x10450 #x1047F shavian)
1138 (#x10480 #x104AF osmanya)
1139 (#x10800 #x1083F cypriot-syllabary)
1140 (#x10900 #x1091F phoenician)
1141 (#x10920 #x1093F lydian)
1142 (#x10A00 #x10A5F kharoshthi)
1143 (#x12000 #x123FF cuneiform)
1144 (#x12400 #x1247F cuneiform-numbers-and-punctuation)
1145 (#x1D000 #x1D0FF byzantine-musical-symbol)
1146 (#x1D100 #x1D1FF musical-symbol)
1147 (#x1D200 #x1D24F ancient-greek-musical-notation)
1148 (#x1D300 #x1D35F tai-xuan-jing-symbol)
1149 (#x1D360 #x1D37F counting-rod-numeral)
1150 (#x1D400 #x1D7FF mathematical)
1151 (#x1F000 #x1F02F mahjong-tile)
1152 (#x1F030 #x1F09F domino-tile)
1153 (#x20000 #x2AFFF han)
1154 (#x2F800 #x2FFFF han)))
1155 (set-char-table-range char-script-table
1156 (cons (car elt) (nth 1 elt)) (nth 2 elt))
1157 (or (memq (nth 2 elt) script-list)
1158 (setq script-list (cons (nth 2 elt) script-list))))
1159 (set-char-table-extra-slot char-script-table 0 (nreverse script-list)))
1162 #'(lambda (range ignore)
1163 (set-char-table-range char-script-table range 'tibetan))
1167 ;;; Setting unicode-category-table.
1169 ;; This macro is to build unicode-category-table at compile time so
1170 ;; that C code can access the table efficiently.
1171 (defmacro build-unicode-category-table ()
1172 (let ((table (make-char-table 'unicode-category-table nil)))
1173 (dotimes (i #x110000)
1174 (if (or (< i #xD800)
1175 (and (> i #xF900) (< i #x30000))
1176 (and (> i #xE0000) (< i #xE0200)))
1177 (aset table i (get-char-code-property i 'general-category))))
1178 (set-char-table-range table '(#xE000 . #xF8FF) 'Co)
1179 (set-char-table-range table '(#xF0000 . #xFFFFD) 'Co)
1180 (set-char-table-range table '(#x100000 . #x10FFFD) 'Co)
1181 (optimize-char-table table 'eq)
1184 (setq unicode-category-table (build-unicode-category-table))
1187 ;;; Setting word boundary.
1189 (setq word-combining-categories
1195 (setq word-separating-categories ; (2-byte character sets)
1196 '((?H . ?K) ; Hiragana - Katakana
1203 ;; arch-tag: 85889c35-9f4d-4912-9bf5-82de31b0d42d
1204 ;;; characters.el ends here