Adapt MSDOS port to latest changes.
[emacs.git] / lisp / international / characters.el
blob0a51c324d61f39b29b88f1e1c276195cf3ccf489
1 ;;; characters.el --- set syntax and category for multibyte characters
3 ;; Copyright (C) 1997, 2000-2012 Free Software Foundation, Inc.
4 ;; Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
5 ;; 2005, 2006, 2007, 2008, 2009, 2010, 2011
6 ;; National Institute of Advanced Industrial Science and Technology (AIST)
7 ;; Registration Number H14PRO021
8 ;; Copyright (C) 2003
9 ;; National Institute of Advanced Industrial Science and Technology (AIST)
10 ;; Registration Number H13PRO009
12 ;; Keywords: multibyte character, character set, syntax, category
14 ;; This file is part of GNU Emacs.
16 ;; GNU Emacs is free software: you can redistribute it and/or modify
17 ;; it under the terms of the GNU General Public License as published by
18 ;; the Free Software Foundation, either version 3 of the License, or
19 ;; (at your option) any later version.
21 ;; GNU Emacs is distributed in the hope that it will be useful,
22 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
23 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 ;; GNU General Public License for more details.
26 ;; You should have received a copy of the GNU General Public License
27 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
29 ;;; Commentary:
31 ;;; Code:
33 ;;; Predefined categories.
35 ;; For each character set.
37 (define-category ?a "ASCII
38 ASCII graphic characters 32-126 (ISO646 IRV:1983[4/0])")
39 (define-category ?l "Latin")
40 (define-category ?t "Thai")
41 (define-category ?g "Greek")
42 (define-category ?b "Arabic")
43 (define-category ?w "Hebrew")
44 (define-category ?y "Cyrillic")
45 (define-category ?k "Katakana
46 Japanese katakana")
47 (define-category ?r "Roman
48 Japanese roman")
49 (define-category ?c "Chinese")
50 (define-category ?j "Japanese")
51 (define-category ?h "Korean")
52 (define-category ?e "Ethiopic
53 Ethiopic (Ge'ez)")
54 (define-category ?v "Viet
55 Vietnamese")
56 (define-category ?i "Indian")
57 (define-category ?o "Lao")
58 (define-category ?q "Tibetan")
60 ;; For each group (row) of 2-byte character sets.
62 (define-category ?A "2-byte alnum
63 Alpha-numeric characters of 2-byte character sets")
64 (define-category ?C "2-byte han
65 Chinese (Han) characters of 2-byte character sets")
66 (define-category ?G "2-byte Greek
67 Greek characters of 2-byte character sets")
68 (define-category ?H "2-byte Hiragana
69 Japanese Hiragana characters of 2-byte character sets")
70 (define-category ?K "2-byte Katakana
71 Japanese Katakana characters of 2-byte character sets")
72 (define-category ?N "2-byte Korean
73 Korean Hangul characters of 2-byte character sets")
74 (define-category ?Y "2-byte Cyrillic
75 Cyrillic characters of 2-byte character sets")
76 (define-category ?I "Indian Glyphs")
78 ;; For phonetic classifications.
80 (define-category ?0 "consonant")
81 (define-category ?1 "base vowel
82 Base (independent) vowel")
83 (define-category ?2 "upper diacritic
84 Upper diacritical mark (including upper vowel)")
85 (define-category ?3 "lower diacritic
86 Lower diacritical mark (including lower vowel)")
87 (define-category ?4 "combining tone
88 Combining tone mark")
89 (define-category ?5 "symbol")
90 (define-category ?6 "digit")
91 (define-category ?7 "vowel diacritic
92 Vowel-modifying diacritical mark")
93 (define-category ?8 "vowel-signs")
94 (define-category ?9 "semivowel lower")
96 ;; For filling.
97 (define-category ?| "line breakable
98 While filling, we can break a line at this character.")
100 ;; For indentation calculation.
101 (define-category ?\s
102 "space for indent
103 This character counts as a space for indentation purposes.")
105 ;; Keep the following for `kinsoku' processing. See comments in
106 ;; kinsoku.el.
107 (define-category ?> "Not at bol
108 A character which can't be placed at beginning of line.")
109 (define-category ?< "Not at eol
110 A character which can't be placed at end of line.")
112 ;; Base and Combining
113 (define-category ?. "Base
114 Base characters (Unicode General Category L,N,P,S,Zs)")
115 (define-category ?^ "Combining
116 Combining diacritic or mark (Unicode General Category M)")
118 ;; bidi types
119 (define-category ?R "Right-to-left (strong)
120 Characters with \"strong\" right-to-left directionality, i.e.
121 with R, AL, RLE, or RLO Unicode bidi character type.")
123 (define-category ?L "Left-to-right (strong)
124 Characters with \"strong\" left-to-right directionality, i.e.
125 with L, LRE, or LRO Unicode bidi character type.")
128 ;;; Setting syntax and category.
130 ;; ASCII
132 ;; All ASCII characters have the category `a' (ASCII) and `l' (Latin).
133 (modify-category-entry '(32 . 127) ?a)
134 (modify-category-entry '(32 . 127) ?l)
136 ;; Deal with the CJK charsets first. Since the syntax of blocks is
137 ;; defined per charset, and the charsets may contain e.g. Latin
138 ;; characters, we end up with the wrong syntax definitions if we're
139 ;; not careful.
141 ;; Chinese characters (Unicode)
142 (modify-category-entry '(#x2E80 . #x312F) ?|)
143 (modify-category-entry '(#x3190 . #x33FF) ?|)
144 (modify-category-entry '(#x3400 . #x4DBF) ?C)
145 (modify-category-entry '(#x4E00 . #x9FAF) ?C)
146 (modify-category-entry '(#x3400 . #x9FAF) ?c)
147 (modify-category-entry '(#x3400 . #x9FAF) ?|)
148 (modify-category-entry '(#xF900 . #xFAFF) ?C)
149 (modify-category-entry '(#xF900 . #xFAFF) ?c)
150 (modify-category-entry '(#xF900 . #xFAFF) ?|)
151 (modify-category-entry '(#x20000 . #x2FFFF) ?|)
152 (modify-category-entry '(#x20000 . #x2FFFF) ?C)
153 (modify-category-entry '(#x20000 . #x2FFFF) ?c)
156 ;; Chinese character set (GB2312)
158 (map-charset-chars #'modify-syntax-entry 'chinese-gb2312 "_" #x2121 #x217E)
159 (map-charset-chars #'modify-syntax-entry 'chinese-gb2312 "_" #x2221 #x227E)
160 (map-charset-chars #'modify-syntax-entry 'chinese-gb2312 "_" #x2921 #x297E)
162 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?c)
163 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?A #x2330 #x2339)
164 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?A #x2341 #x235A)
165 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?A #x2361 #x237A)
166 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?H #x2421 #x247E)
167 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?K #x2521 #x257E)
168 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?G #x2621 #x267E)
169 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?Y #x2721 #x277E)
170 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?C #x3021 #x7E7E)
172 ;; Chinese character set (BIG5)
174 (map-charset-chars #'modify-category-entry 'big5 ?c)
175 (map-charset-chars #'modify-category-entry 'big5 ?C #xA259 #xA261)
176 (map-charset-chars #'modify-category-entry 'big5 ?C #xA440 #xC67E)
177 (map-charset-chars #'modify-category-entry 'big5 ?C #xC940 #xF9DC)
179 ;; Chinese character set (CNS11643)
181 (dolist (c '(chinese-cns11643-1 chinese-cns11643-2 chinese-cns11643-3
182 chinese-cns11643-4 chinese-cns11643-5 chinese-cns11643-6
183 chinese-cns11643-7))
184 (map-charset-chars #'modify-category-entry c ?c)
185 (if (eq c 'chinese-cns11643-1)
186 (map-charset-chars #'modify-category-entry c ?C #x4421 #x7E7E)
187 (map-charset-chars #'modify-category-entry c ?C)))
189 ;; Japanese character set (JISX0201, JISX0208, JISX0212, JISX0213)
191 (map-charset-chars #'modify-category-entry 'katakana-jisx0201 ?k)
193 (map-charset-chars #'modify-category-entry 'latin-jisx0201 ?r)
195 (dolist (l '(katakana-jisx0201 japanese-jisx0208 japanese-jisx0212
196 japanese-jisx0213-1 japanese-jisx0213-2
197 cp932-2-byte))
198 (map-charset-chars #'modify-category-entry l ?j))
200 ;; Fullwidth characters
201 (modify-category-entry '(#xff01 . #xff60) ?\|)
203 ;; Unicode equivalents of JISX0201-kana
204 (let ((range '(#xff61 . #xff9f)))
205 (modify-category-entry range ?k)
206 (modify-category-entry range ?j)
207 (modify-category-entry range ?\|))
209 ;; Katakana block
210 (modify-category-entry '(#x3099 . #x309C) ?K)
211 (modify-category-entry '(#x30A0 . #x30FF) ?K)
212 (modify-category-entry '(#x31F0 . #x31FF) ?K)
213 (modify-category-entry '(#x30A0 . #x30FA) ?\|)
214 (modify-category-entry #x30FF ?\|)
216 ;; Hiragana block
217 (modify-category-entry '(#x3040 . #x309F) ?H)
218 (modify-category-entry '(#x3040 . #x3096) ?\|)
219 (modify-category-entry #x309F ?\|)
220 (modify-category-entry #x30A0 ?H)
221 (modify-category-entry #x30FC ?H)
224 ;; JISX0208
225 (map-charset-chars #'modify-syntax-entry 'japanese-jisx0208 "_" #x2121 #x227E)
226 (map-charset-chars #'modify-syntax-entry 'japanese-jisx0208 "_" #x2821 #x287E)
227 (let ((chars '(?ー ?゛ ?゜ ?ヽ ?ヾ ?ゝ ?ゞ ?〃 ?仝 ?々 ?〆 ?〇)))
228 (dolist (elt chars)
229 (modify-syntax-entry elt "w")))
231 (map-charset-chars #'modify-category-entry 'japanese-jisx0208 ?A #x2321 #x237E)
232 (map-charset-chars #'modify-category-entry 'japanese-jisx0208 ?H #x2421 #x247E)
233 (map-charset-chars #'modify-category-entry 'japanese-jisx0208 ?K #x2521 #x257E)
234 (map-charset-chars #'modify-category-entry 'japanese-jisx0208 ?G #x2621 #x267E)
235 (map-charset-chars #'modify-category-entry 'japanese-jisx0208 ?Y #x2721 #x277E)
236 (map-charset-chars #'modify-category-entry 'japanese-jisx0208 ?C #x3021 #x7E7E)
237 (let ((chars '(?仝 ?々 ?〆 ?〇)))
238 (while chars
239 (modify-category-entry (car chars) ?C)
240 (setq chars (cdr chars))))
242 ;; JISX0212
244 (map-charset-chars #'modify-syntax-entry 'japanese-jisx0212 "_" #x2121 #x237E)
246 ;; JISX0201-Kana
248 (let ((chars '(?。 ?、 ?・)))
249 (while chars
250 (modify-syntax-entry (car chars) ".")
251 (setq chars (cdr chars))))
253 (modify-syntax-entry ?\「 "(」")
254 (modify-syntax-entry ?\」 "(「")
256 ;; Korean character set (KSC5601)
258 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?h)
260 (map-charset-chars #'modify-syntax-entry 'korean-ksc5601 "_" #x2121 #x227E)
261 (map-charset-chars #'modify-syntax-entry 'korean-ksc5601 "_" #x2621 #x277E)
262 (map-charset-chars #'modify-syntax-entry 'korean-ksc5601 "_" #x2830 #x287E)
263 (map-charset-chars #'modify-syntax-entry 'korean-ksc5601 "_" #x2930 #x297E)
264 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?A #x2330 #x2339)
265 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?A #x2341 #x235A)
266 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?A #x2361 #x237A)
267 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?G #x2521 #x257E)
268 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?H #x2A21 #x2A7E)
269 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?K #x2B21 #x2B7E)
270 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?Y #x2C21 #x2C7E)
272 ;; These are in more than one charset.
273 (let ((parens (concat "〈〉《》「」『』【】〔〕〖〗〘〙〚〛"
274 "︵︶︷︸︹︺︻︼︽︾︿﹀﹁﹂﹃﹄"
275 "()[]{}"))
276 open close)
277 (dotimes (i (/ (length parens) 2))
278 (setq open (aref parens (* i 2))
279 close (aref parens (1+ (* i 2))))
280 (modify-syntax-entry open (format "(%c" close))
281 (modify-syntax-entry close (format ")%c" open))))
283 ;; Arabic character set
285 (let ((charsets '(arabic-iso8859-6
286 arabic-digit
287 arabic-1-column
288 arabic-2-column)))
289 (while charsets
290 (map-charset-chars #'modify-category-entry (car charsets) ?b)
291 (setq charsets (cdr charsets))))
292 (modify-category-entry '(#x600 . #x6ff) ?b)
293 (modify-category-entry '(#xfb50 . #xfdff) ?b)
294 (modify-category-entry '(#xfe70 . #xfefe) ?b)
296 ;; Cyrillic character set (ISO-8859-5)
298 (modify-syntax-entry ?№ ".")
300 ;; Ethiopic character set
302 (modify-category-entry '(#x1200 . #x1399) ?e)
303 (modify-category-entry '(#x2d80 . #x2dde) ?e)
304 (let ((chars '(?፡ ?። ?፣ ?፤ ?፥ ?፦ ?፧ ?፨)))
305 (while chars
306 (modify-syntax-entry (car chars) ".")
307 (setq chars (cdr chars))))
308 (map-charset-chars #'modify-category-entry 'ethiopic ?e)
310 ;; Hebrew character set (ISO-8859-8)
312 (modify-syntax-entry #x5be ".") ; MAQAF
313 (modify-syntax-entry #x5c0 ".") ; PASEQ
314 (modify-syntax-entry #x5c3 ".") ; SOF PASUQ
315 (modify-syntax-entry #x5f3 ".") ; GERESH
316 (modify-syntax-entry #x5f4 ".") ; GERSHAYIM
318 ;; Indian character set (IS 13194 and other Emacs original Indian charsets)
320 (modify-category-entry '(#x901 . #x970) ?i)
321 (map-charset-chars #'modify-category-entry 'indian-is13194 ?i)
322 (map-charset-chars #'modify-category-entry 'indian-2-column ?i)
324 ;; Lao character set
326 (modify-category-entry '(#xe80 . #xeff) ?o)
327 (map-charset-chars #'modify-category-entry 'lao ?o)
329 (let ((deflist '(("ກ-ຮ" "w" ?0) ; consonant
330 ("ະາຳຽເ-ໄ" "w" ?1) ; vowel base
331 ("ັິ-ືົໍ" "w" ?2) ; vowel upper
332 ("ຸູ" "w" ?3) ; vowel lower
333 ("່-໋" "w" ?4) ; tone mark
334 ("ຼຽ" "w" ?9) ; semivowel lower
335 ("໐-໙" "w" ?6) ; digit
336 ("ຯໆ" "_" ?5) ; symbol
338 elm chars len syntax category to ch i)
339 (while deflist
340 (setq elm (car deflist))
341 (setq chars (car elm)
342 len (length chars)
343 syntax (nth 1 elm)
344 category (nth 2 elm)
345 i 0)
346 (while (< i len)
347 (if (= (aref chars i) ?-)
348 (setq i (1+ i)
349 to (aref chars i))
350 (setq ch (aref chars i)
351 to ch))
352 (while (<= ch to)
353 (unless (string-equal syntax "w")
354 (modify-syntax-entry ch syntax))
355 (modify-category-entry ch category)
356 (setq ch (1+ ch)))
357 (setq i (1+ i)))
358 (setq deflist (cdr deflist))))
360 ;; Thai character set (TIS620)
362 (modify-category-entry '(#xe00 . #xe7f) ?t)
363 (map-charset-chars #'modify-category-entry 'thai-tis620 ?t)
365 (let ((deflist '(;; chars syntax category
366 ("ก-รลว-ฮ" "w" ?0) ; consonant
367 ("ฤฦะาำเ-ๅ" "w" ?1) ; vowel base
368 ("ัิ-ื็๎" "w" ?2) ; vowel upper
369 ("ุ-ฺ" "w" ?3) ; vowel lower
370 ("่-ํ" "w" ?4) ; tone mark
371 ("๐-๙" "w" ?6) ; digit
372 ("ฯๆ฿๏๚๛" "_" ?5) ; symbol
374 elm chars len syntax category to ch i)
375 (while deflist
376 (setq elm (car deflist))
377 (setq chars (car elm)
378 len (length chars)
379 syntax (nth 1 elm)
380 category (nth 2 elm)
381 i 0)
382 (while (< i len)
383 (if (= (aref chars i) ?-)
384 (setq i (1+ i)
385 to (aref chars i))
386 (setq ch (aref chars i)
387 to ch))
388 (while (<= ch to)
389 (unless (string-equal syntax "w")
390 (modify-syntax-entry ch syntax))
391 (modify-category-entry ch category)
392 (setq ch (1+ ch)))
393 (setq i (1+ i)))
394 (setq deflist (cdr deflist))))
396 ;; Tibetan character set
398 (modify-category-entry '(#xf00 . #xfff) ?q)
399 (map-charset-chars #'modify-category-entry 'tibetan ?q)
400 (map-charset-chars #'modify-category-entry 'tibetan-1-column ?q)
402 (let ((deflist '(;; chars syntax category
403 ("ཀ-ཀྵཪ" "w" ?0) ; consonant
404 ("ྐ-ྐྵྺྻྼ" "w" ?0) ;
405 ("ིེཻོཽྀ" "w" ?2) ; upper vowel
406 ("ཾྂྃ྆྇ྈྉྊྋ" "w" ?2) ; upper modifier
407 ("྄ཱུ༙༵༷" "w" ?3) ; lower vowel/modifier
408 ("཰" "w" ?3) ; invisible vowel a
409 ("༠-༩༪-༳" "w" ?6) ; digit
410 ("་།-༒༔ཿ" "." ?|) ; line-break char
411 ("་།༏༐༑༔ཿ" "." ?|) ;
412 ("༈་།-༒༔ཿ༽༴" "." ?>) ; prohibition
413 ("་།༏༐༑༔ཿ" "." ?>) ;
414 ("ༀ-༊༼࿁࿂྅" "." ?<) ; prohibition
415 ("༓༕-༘༚-༟༶༸-༻༾༿྾྿-࿏" "." ?q) ; others
417 elm chars len syntax category to ch i)
418 (while deflist
419 (setq elm (car deflist))
420 (setq chars (car elm)
421 len (length chars)
422 syntax (nth 1 elm)
423 category (nth 2 elm)
424 i 0)
425 (while (< i len)
426 (if (= (aref chars i) ?-)
427 (setq i (1+ i)
428 to (aref chars i))
429 (setq ch (aref chars i)
430 to ch))
431 (while (<= ch to)
432 (unless (string-equal syntax "w")
433 (modify-syntax-entry ch syntax))
434 (modify-category-entry ch category)
435 (setq ch (1+ ch)))
436 (setq i (1+ i)))
437 (setq deflist (cdr deflist))))
439 ;; Vietnamese character set
441 ;; To make a word with Latin characters
442 (map-charset-chars #'modify-category-entry 'vietnamese-viscii-lower ?l)
443 (map-charset-chars #'modify-category-entry 'vietnamese-viscii-lower ?v)
445 (map-charset-chars #'modify-category-entry 'vietnamese-viscii-upper ?l)
446 (map-charset-chars #'modify-category-entry 'vietnamese-viscii-upper ?v)
448 (let ((tbl (standard-case-table))
449 (i 32))
450 (while (< i 128)
451 (let* ((char (decode-char 'vietnamese-viscii-upper i))
452 (charl (decode-char 'vietnamese-viscii-lower i))
453 (uc (encode-char char 'ucs))
454 (lc (encode-char charl 'ucs)))
455 (set-case-syntax-pair char (decode-char 'vietnamese-viscii-lower i)
456 tbl)
457 (if uc (modify-category-entry uc ?v))
458 (if lc (modify-category-entry lc ?v)))
459 (setq i (1+ i))))
461 ;; Tai Viet
462 (let ((deflist '(;; chars syntax category
463 ((?ꪀ. ?ꪯ) "w" ?0) ; consonant
464 ("ꪱꪵꪶ" "w" ?1) ; vowel base
465 ((?ꪹ . ?ꪽ) "w" ?1) ; vowel base
466 ("ꪰꪲꪳꪷꪸꪾ" "w" ?2) ; vowel upper
467 ("ꪴ" "w" ?3) ; vowel lower
468 ("ꫀꫂ" "w" ?1) ; non-combining tone-mark
469 ("꪿꫁" "w" ?4) ; combining tone-mark
470 ((?ꫛ . ?꫟) "_" ?5) ; symbol
472 (dolist (elm deflist)
473 (let ((chars (car elm))
474 (syntax (nth 1 elm))
475 (category (nth 2 elm)))
476 (if (consp chars)
477 (progn
478 (modify-syntax-entry chars syntax)
479 (modify-category-entry chars category))
480 (mapc #'(lambda (x)
481 (modify-syntax-entry x syntax)
482 (modify-category-entry x category))
483 chars)))))
485 ;; Bidi categories
487 (map-char-table (lambda (key val)
488 (cond
489 ((memq val '(R AL RLO RLE))
490 (modify-category-entry key ?R))
491 ((memq val '(L LRE LRO))
492 (modify-category-entry key ?L))))
493 (unicode-property-table-internal 'bidi-class))
495 ;; Latin
497 (modify-category-entry '(#x80 . #x024F) ?l)
499 (let ((tbl (standard-case-table)) c)
501 ;; Latin-1
503 ;; Fixme: Some of the non-word syntaxes here perhaps should be
504 ;; reviewed. (Note that the following all implicitly have word
505 ;; syntax: ¢£¤¥¨ª¯²³´¶¸¹º.) There should be a well-defined way of
506 ;; relating Unicode categories to Emacs syntax codes.
508 ;; NBSP isn't semantically interchangeable with other whitespace chars,
509 ;; so it's more like punctuation.
510 (set-case-syntax"." tbl)
511 (set-case-syntax"." tbl)
512 (set-case-syntax"_" tbl)
513 (set-case-syntax"." tbl)
514 (set-case-syntax"_" tbl)
515 (set-case-syntax-delims 171 187 tbl) ; « »
516 (set-case-syntax"_" tbl)
517 (set-case-syntax"_" tbl)
518 (set-case-syntax"_" tbl)
519 (set-case-syntax"_" tbl)
520 (set-case-syntax"_" tbl)
521 (set-case-syntax"_" tbl)
522 (set-case-syntax"_" tbl)
523 (set-case-syntax"_" tbl)
524 (set-case-syntax"_" tbl)
525 (set-case-syntax"_" tbl)
526 (set-case-syntax ?¿ "." tbl)
527 (let ((c 192))
528 (while (<= c 222)
529 (set-case-syntax-pair c (+ c 32) tbl)
530 (setq c (1+ c))))
531 (set-case-syntax"_" tbl)
532 (set-case-syntax"w" tbl)
533 (set-case-syntax"_" tbl)
534 ;; See below for ÿ.
536 ;; Latin Extended-A, Latin Extended-B
537 (setq c #x0100)
538 (while (<= c #x02B8)
539 (modify-category-entry c ?l)
540 (setq c (1+ c)))
542 (let ((pair-ranges '((#x0100 . #x012F)
543 (#x0132 . #x0137)
544 (#x0139 . #x0148)
545 (#x014a . #x0177)
546 (#x0179 . #x017E)
547 (#x0182 . #x0185)
548 (#x0187 . #x0188)
549 (#x018B . #x018C)
550 (#x0191 . #x0192)
551 (#x0198 . #x0199)
552 (#x01A0 . #x01A5)
553 (#x01A7 . #x01A8)
554 (#x01AC . #x01AD)
555 (#x01AF . #x01B0)
556 (#x01B3 . #x01B6)
557 (#x01B8 . #x01B9)
558 (#x01BC . #x01BD)
559 (#x01CD . #x01DC)
560 (#x01DE . #x01EF)
561 (#x01F4 . #x01F5)
562 (#x01F8 . #x021F)
563 (#x0222 . #x0233)
564 (#x023B . #x023C)
565 (#x0241 . #x0242)
566 (#x0246 . #x024F))))
567 (dolist (elt pair-ranges)
568 (let ((from (car elt)) (to (cdr elt)))
569 (while (< from to)
570 (set-case-syntax-pair from (1+ from) tbl)
571 (setq from (+ from 2))))))
573 (set-case-syntax-pair ?Ÿ ?ÿ tbl)
575 ;; In some languages, such as Turkish, U+0049 LATIN CAPITAL LETTER I
576 ;; and U+0131 LATIN SMALL LETTER DOTLESS I make a case pair, and so
577 ;; do U+0130 LATIN CAPITAL LETTER I WITH DOT ABOVE and U+0069 LATIN
578 ;; SMALL LETTER I.
580 ;; We used to set up half of those correspondence unconditionally,
581 ;; but that makes searches slow. So now we don't set up either half
582 ;; of these correspondences by default.
584 ;; (set-downcase-syntax ?İ ?i tbl)
585 ;; (set-upcase-syntax ?I ?ı tbl)
587 (set-case-syntax-pair ?Ɓ ?ɓ tbl)
588 (set-case-syntax-pair ?Ɔ ?ɔ tbl)
589 (set-case-syntax-pair ?Ɖ ?ɖ tbl)
590 (set-case-syntax-pair ?Ɗ ?ɗ tbl)
591 (set-case-syntax-pair ?Ǝ ?ǝ tbl)
592 (set-case-syntax-pair ?Ə ?ə tbl)
593 (set-case-syntax-pair ?Ɛ ?ɛ tbl)
594 (set-case-syntax-pair ?Ɠ ?ɠ tbl)
595 (set-case-syntax-pair ?Ɣ ?ɣ 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)
603 (set-case-syntax-pair ?Ʈ ?ʈ tbl)
604 (set-case-syntax-pair ?Ʊ ?ʊ tbl)
605 (set-case-syntax-pair ?Ʋ ?ʋ tbl)
606 (set-case-syntax-pair ?Ʒ ?ʒ tbl)
607 (set-case-syntax-pair ?DŽ ?dž tbl)
608 (set-case-syntax-pair ?Dž ?dž tbl)
609 (set-case-syntax-pair ?LJ ?lj tbl)
610 (set-case-syntax-pair ?Lj ?lj tbl)
611 (set-case-syntax-pair ?NJ ?nj tbl)
612 (set-case-syntax-pair ?Nj ?nj tbl)
614 ;; 01F0; F; 006A 030C; # LATIN SMALL LETTER J WITH CARON
615 (set-case-syntax-pair ?DZ ?dz tbl)
616 (set-case-syntax-pair ?Dz ?dz tbl)
617 (set-case-syntax-pair ?Ƕ ?ƕ tbl)
618 (set-case-syntax-pair ?Ƿ ?ƿ tbl)
619 (set-case-syntax-pair ?Ⱥ ?ⱥ 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)
626 ;; Latin Extended Additional
627 (modify-category-entry '(#x1e00 . #x1ef9) ?l)
628 (setq c #x1e00)
629 (while (<= c #x1ef9)
630 (and (zerop (% c 2))
631 (or (<= c #x1e94) (>= c #x1ea0))
632 (set-case-syntax-pair c (1+ c) tbl))
633 (setq c (1+ c)))
635 ;; Greek
636 (modify-category-entry '(#x0370 . #x03ff) ?g)
637 (setq c #x0370)
638 (while (<= c #x03ff)
639 (if (or (and (>= c #x0391) (<= c #x03a1))
640 (and (>= c #x03a3) (<= c #x03ab)))
641 (set-case-syntax-pair c (+ c 32) tbl))
642 (and (>= c #x03da)
643 (<= c #x03ee)
644 (zerop (% c 2))
645 (set-case-syntax-pair c (1+ c) tbl))
646 (setq c (1+ c)))
647 (set-case-syntax-pair ?Ά ?ά tbl)
648 (set-case-syntax-pair ?Έ ?έ tbl)
649 (set-case-syntax-pair ?Ή ?ή tbl)
650 (set-case-syntax-pair ?Ί ?ί tbl)
651 (set-case-syntax-pair ?Ό ?ό tbl)
652 (set-case-syntax-pair ?Ύ ?ύ tbl)
653 (set-case-syntax-pair ?Ώ ?ώ tbl)
655 ;; Armenian
656 (setq c #x531)
657 (while (<= c #x556)
658 (set-case-syntax-pair c (+ c #x30) tbl)
659 (setq c (1+ c)))
661 ;; Greek Extended
662 (modify-category-entry '(#x1f00 . #x1fff) ?g)
663 (setq c #x1f00)
664 (while (<= c #x1fff)
665 (and (<= (logand c #x000f) 7)
666 (<= c #x1fa7)
667 (not (memq c '(#x1f16 #x1f17 #x1f56 #x1f57
668 #x1f50 #x1f52 #x1f54 #x1f56)))
669 (/= (logand c #x00f0) #x70)
670 (set-case-syntax-pair (+ c 8) c tbl))
671 (setq c (1+ c)))
672 (set-case-syntax-pair ?Ᾰ ?ᾰ tbl)
673 (set-case-syntax-pair ?Ᾱ ?ᾱ tbl)
674 (set-case-syntax-pair ?Ὰ ?ὰ tbl)
675 (set-case-syntax-pair ?Ά ?ά tbl)
676 (set-case-syntax-pair ?ᾼ ?ᾳ tbl)
677 (set-case-syntax-pair ?Ὲ ?ὲ tbl)
678 (set-case-syntax-pair ?Έ ?έ tbl)
679 (set-case-syntax-pair ?Ὴ ?ὴ tbl)
680 (set-case-syntax-pair ?Ή ?ή tbl)
681 (set-case-syntax-pair ?ῌ ?ῃ tbl)
682 (set-case-syntax-pair ?Ῐ ?ῐ tbl)
683 (set-case-syntax-pair ?Ῑ ?ῑ tbl)
684 (set-case-syntax-pair ?Ὶ ?ὶ tbl)
685 (set-case-syntax-pair ?Ί ?ί tbl)
686 (set-case-syntax-pair ?Ῠ ?ῠ tbl)
687 (set-case-syntax-pair ?Ῡ ?ῡ tbl)
688 (set-case-syntax-pair ?Ὺ ?ὺ tbl)
689 (set-case-syntax-pair ?Ύ ?ύ tbl)
690 (set-case-syntax-pair ?Ῥ ?ῥ tbl)
691 (set-case-syntax-pair ?Ὸ ?ὸ tbl)
692 (set-case-syntax-pair ?Ό ?ό tbl)
693 (set-case-syntax-pair ?Ὼ ?ὼ tbl)
694 (set-case-syntax-pair ?Ώ ?ώ tbl)
695 (set-case-syntax-pair ?ῼ ?ῳ tbl)
697 ;; cyrillic
698 (modify-category-entry '(#x0400 . #x04FF) ?y)
699 (setq c #x0400)
700 (while (<= c #x04ff)
701 (and (>= c #x0400)
702 (<= c #x040f)
703 (set-case-syntax-pair c (+ c 80) tbl))
704 (and (>= c #x0410)
705 (<= c #x042f)
706 (set-case-syntax-pair c (+ c 32) tbl))
707 (and (zerop (% c 2))
708 (or (and (>= c #x0460) (<= c #x0480))
709 (and (>= c #x048c) (<= c #x04be))
710 (and (>= c #x04d0) (<= c #x04f4)))
711 (set-case-syntax-pair c (1+ c) tbl))
712 (setq c (1+ c)))
713 (set-case-syntax-pair ?Ӂ ?ӂ tbl)
714 (set-case-syntax-pair ?Ӄ ?ӄ tbl)
715 (set-case-syntax-pair ?Ӈ ?ӈ tbl)
716 (set-case-syntax-pair ?Ӌ ?ӌ tbl)
717 (set-case-syntax-pair ?Ӹ ?ӹ tbl)
719 ;; general punctuation
720 (setq c #x2000)
721 (while (<= c #x200b)
722 (set-case-syntax c " " tbl)
723 (setq c (1+ c)))
724 (while (<= c #x200F)
725 (set-case-syntax c "." tbl)
726 (setq c (1+ c)))
727 ;; Fixme: These aren't all right:
728 (setq c #x2010)
729 (while (<= c #x2016)
730 (set-case-syntax c "_" tbl)
731 (setq c (1+ c)))
732 ;; Punctuation syntax for quotation marks (like `)
733 (while (<= c #x201f)
734 (set-case-syntax c "." tbl)
735 (setq c (1+ c)))
736 ;; Fixme: These aren't all right:
737 (while (<= c #x2027)
738 (set-case-syntax c "_" tbl)
739 (setq c (1+ c)))
740 (while (<= c #x206F)
741 (set-case-syntax c "." tbl)
742 (setq c (1+ c)))
744 ;; Roman numerals
745 (setq c #x2160)
746 (while (<= c #x216f)
747 (set-case-syntax-pair c (+ c #x10) tbl)
748 (setq c (1+ c)))
750 ;; Fixme: The following blocks might be better as symbol rather than
751 ;; punctuation.
752 ;; Arrows
753 (setq c #x2190)
754 (while (<= c #x21FF)
755 (set-case-syntax c "." tbl)
756 (setq c (1+ c)))
757 ;; Mathematical Operators
758 (while (<= c #x22FF)
759 (set-case-syntax c "." tbl)
760 (setq c (1+ c)))
761 ;; Miscellaneous Technical
762 (while (<= c #x23FF)
763 (set-case-syntax c "." tbl)
764 (setq c (1+ c)))
765 ;; Control Pictures
766 (while (<= c #x243F)
767 (set-case-syntax c "_" tbl)
768 (setq c (1+ c)))
770 ;; Circled Latin
771 (setq c #x24b6)
772 (while (<= c #x24cf)
773 (set-case-syntax-pair c (+ c 26) tbl)
774 (modify-category-entry c ?l)
775 (modify-category-entry (+ c 26) ?l)
776 (setq c (1+ c)))
778 ;; Fullwidth Latin
779 (setq c #xff21)
780 (while (<= c #xff3a)
781 (set-case-syntax-pair c (+ c #x20) tbl)
782 (modify-category-entry c ?l)
783 (modify-category-entry (+ c #x20) ?l)
784 (setq c (1+ c)))
786 ;; Combining diacritics
787 (modify-category-entry '(#x300 . #x362) ?^)
788 ;; Combining marks
789 (modify-category-entry '(#x20d0 . #x20e3) ?^)
791 ;; Fixme: syntax for symbols &c
794 (let ((pairs
795 '("⁅⁆" ; U+2045 U+2046
796 "⁽⁾" ; U+207D U+207E
797 "₍₎" ; U+208D U+208E
798 "〈〉" ; U+2329 U+232A
799 "⎴⎵" ; U+23B4 U+23B5
800 "❨❩" ; U+2768 U+2769
801 "❪❫" ; U+276A U+276B
802 "❬❭" ; U+276C U+276D
803 "❰❱" ; U+2770 U+2771
804 "❲❳" ; U+2772 U+2773
805 "❴❵" ; U+2774 U+2775
806 "⟦⟧" ; U+27E6 U+27E7
807 "⟨⟩" ; U+27E8 U+27E9
808 "⟪⟫" ; U+27EA U+27EB
809 "⦃⦄" ; U+2983 U+2984
810 "⦅⦆" ; U+2985 U+2986
811 "⦇⦈" ; U+2987 U+2988
812 "⦉⦊" ; U+2989 U+298A
813 "⦋⦌" ; U+298B U+298C
814 "⦍⦎" ; U+298D U+298E
815 "⦏⦐" ; U+298F U+2990
816 "⦑⦒" ; U+2991 U+2992
817 "⦓⦔" ; U+2993 U+2994
818 "⦕⦖" ; U+2995 U+2996
819 "⦗⦘" ; U+2997 U+2998
820 "⧼⧽" ; U+29FC U+29FD
821 "〈〉" ; U+3008 U+3009
822 "《》" ; U+300A U+300B
823 "「」" ; U+300C U+300D
824 "『』" ; U+300E U+300F
825 "【】" ; U+3010 U+3011
826 "〔〕" ; U+3014 U+3015
827 "〖〗" ; U+3016 U+3017
828 "〘〙" ; U+3018 U+3019
829 "〚〛" ; U+301A U+301B
830 "﴾﴿" ; U+FD3E U+FD3F
831 "︵︶" ; U+FE35 U+FE36
832 "︷︸" ; U+FE37 U+FE38
833 "︹︺" ; U+FE39 U+FE3A
834 "︻︼" ; U+FE3B U+FE3C
835 "︽︾" ; U+FE3D U+FE3E
836 "︿﹀" ; U+FE3F U+FE40
837 "﹁﹂" ; U+FE41 U+FE42
838 "﹃﹄" ; U+FE43 U+FE44
839 "﹙﹚" ; U+FE59 U+FE5A
840 "﹛﹜" ; U+FE5B U+FE5C
841 "﹝﹞" ; U+FE5D U+FE5E
842 "()" ; U+FF08 U+FF09
843 "[]" ; U+FF3B U+FF3D
844 "{}" ; U+FF5B U+FF5D
845 "⦅⦆" ; U+FF5F U+FF60
846 "「」" ; U+FF62 U+FF63
848 (dolist (elt pairs)
849 (modify-syntax-entry (aref elt 0) (string ?\( (aref elt 1)))
850 (modify-syntax-entry (aref elt 1) (string ?\) (aref elt 0)))))
853 ;; For each character set, put the information of the most proper
854 ;; coding system to encode it by `preferred-coding-system' property.
856 ;; Fixme: should this be junked?
857 (let ((l '((latin-iso8859-1 . iso-latin-1)
858 (latin-iso8859-2 . iso-latin-2)
859 (latin-iso8859-3 . iso-latin-3)
860 (latin-iso8859-4 . iso-latin-4)
861 (thai-tis620 . thai-tis620)
862 (greek-iso8859-7 . greek-iso-8bit)
863 (arabic-iso8859-6 . iso-2022-7bit)
864 (hebrew-iso8859-8 . hebrew-iso-8bit)
865 (katakana-jisx0201 . japanese-shift-jis)
866 (latin-jisx0201 . japanese-shift-jis)
867 (cyrillic-iso8859-5 . cyrillic-iso-8bit)
868 (latin-iso8859-9 . iso-latin-5)
869 (japanese-jisx0208-1978 . iso-2022-jp)
870 (chinese-gb2312 . chinese-iso-8bit)
871 (chinese-gbk . chinese-gbk)
872 (gb18030-2-byte . chinese-gb18030)
873 (gb18030-4-byte-bmp . chinese-gb18030)
874 (gb18030-4-byte-smp . chinese-gb18030)
875 (gb18030-4-byte-ext-1 . chinese-gb18030)
876 (gb18030-4-byte-ext-2 . chinese-gb18030)
877 (japanese-jisx0208 . iso-2022-jp)
878 (korean-ksc5601 . iso-2022-kr)
879 (japanese-jisx0212 . iso-2022-jp)
880 (chinese-big5-1 . chinese-big5)
881 (chinese-big5-2 . chinese-big5)
882 (chinese-sisheng . iso-2022-7bit)
883 (ipa . iso-2022-7bit)
884 (vietnamese-viscii-lower . vietnamese-viscii)
885 (vietnamese-viscii-upper . vietnamese-viscii)
886 (arabic-digit . iso-2022-7bit)
887 (arabic-1-column . iso-2022-7bit)
888 (lao . lao)
889 (arabic-2-column . iso-2022-7bit)
890 (indian-is13194 . devanagari)
891 (indian-glyph . devanagari)
892 (tibetan-1-column . tibetan)
893 (ethiopic . iso-2022-7bit)
894 (chinese-cns11643-1 . iso-2022-cn)
895 (chinese-cns11643-2 . iso-2022-cn)
896 (chinese-cns11643-3 . iso-2022-cn)
897 (chinese-cns11643-4 . iso-2022-cn)
898 (chinese-cns11643-5 . iso-2022-cn)
899 (chinese-cns11643-6 . iso-2022-cn)
900 (chinese-cns11643-7 . iso-2022-cn)
901 (indian-2-column . devanagari)
902 (tibetan . tibetan)
903 (latin-iso8859-14 . iso-latin-8)
904 (latin-iso8859-15 . iso-latin-9))))
905 (while l
906 (put-charset-property (car (car l)) 'preferred-coding-system (cdr (car l)))
907 (setq l (cdr l))))
910 ;; Setup auto-fill-chars for charsets that should invoke auto-filling.
911 ;; SPACE and NEWLINE are already set.
913 (set-char-table-range auto-fill-chars '(#x3041 . #x30FF) t)
914 (set-char-table-range auto-fill-chars '(#x3400 . #x4DB5) t)
915 (set-char-table-range auto-fill-chars '(#x4e00 . #x9fbb) t)
916 (set-char-table-range auto-fill-chars '(#xF900 . #xFAFF) t)
917 (set-char-table-range auto-fill-chars '(#xFF00 . #xFF9F) t)
918 (set-char-table-range auto-fill-chars '(#x20000 . #x2FFFF) t)
921 ;;; Setting char-width-table. The default is 1.
923 ;; 0: non-spacing, enclosing combining, formatting, Hangul Jamo medial
924 ;; and final characters.
925 (let ((l '((#x0300 . #x036F)
926 (#x0483 . #x0489)
927 (#x0591 . #x05BD)
928 (#x05BF . #x05BF)
929 (#x05C1 . #x05C2)
930 (#x05C4 . #x05C5)
931 (#x05C7 . #x05C7)
932 (#x0600 . #x0603)
933 (#x0610 . #x0615)
934 (#x064B . #x065E)
935 (#x0670 . #x0670)
936 (#x06D6 . #x06E4)
937 (#x06E7 . #x06E8)
938 (#x06EA . #x06ED)
939 (#x070F . #x070F)
940 (#x0711 . #x0711)
941 (#x0730 . #x074A)
942 (#x07A6 . #x07B0)
943 (#x07EB . #x07F3)
944 (#x0901 . #x0902)
945 (#x093C . #x093C)
946 (#x0941 . #x0948)
947 (#x094D . #x094D)
948 (#x0951 . #x0954)
949 (#x0962 . #x0963)
950 (#x0981 . #x0981)
951 (#x09BC . #x09BC)
952 (#x09C1 . #x09C4)
953 (#x09CD . #x09CD)
954 (#x09E2 . #x09E3)
955 (#x0A01 . #x0A02)
956 (#x0A3C . #x0A3C)
957 (#x0A41 . #x0A4D)
958 (#x0A70 . #x0A71)
959 (#x0A81 . #x0A82)
960 (#x0ABC . #x0ABC)
961 (#x0AC1 . #x0AC8)
962 (#x0ACD . #x0ACD)
963 (#x0AE2 . #x0AE3)
964 (#x0B01 . #x0B01)
965 (#x0B3C . #x0B3C)
966 (#x0B3F . #x0B3F)
967 (#x0B41 . #x0B43)
968 (#x0B4D . #x0B56)
969 (#x0B82 . #x0B82)
970 (#x0BC0 . #x0BC0)
971 (#x0BCD . #x0BCD)
972 (#x0C3E . #x0C40)
973 (#x0C46 . #x0C56)
974 (#x0CBC . #x0CBC)
975 (#x0CBF . #x0CBF)
976 (#x0CC6 . #x0CC6)
977 (#x0CCC . #x0CCD)
978 (#x0CE2 . #x0CE3)
979 (#x0D41 . #x0D43)
980 (#x0D4D . #x0D4D)
981 (#x0DCA . #x0DCA)
982 (#x0DD2 . #x0DD6)
983 (#x0E31 . #x0E31)
984 (#x0E34 . #x0E3A)
985 (#x0E47 . #x0E4E)
986 (#x0EB1 . #x0EB1)
987 (#x0EB4 . #x0EBC)
988 (#x0EC8 . #x0ECD)
989 (#x0F18 . #x0F19)
990 (#x0F35 . #x0F35)
991 (#x0F37 . #x0F37)
992 (#x0F39 . #x0F39)
993 (#x0F71 . #x0F7E)
994 (#x0F80 . #x0F84)
995 (#x0F86 . #x0F87)
996 (#x0F90 . #x0FBC)
997 (#x0FC6 . #x0FC6)
998 (#x102D . #x1030)
999 (#x1032 . #x1037)
1000 (#x1039 . #x1039)
1001 (#x1058 . #x1059)
1002 (#x1160 . #x11FF)
1003 (#x135F . #x135F)
1004 (#x1712 . #x1714)
1005 (#x1732 . #x1734)
1006 (#x1752 . #x1753)
1007 (#x1772 . #x1773)
1008 (#x17B4 . #x17B5)
1009 (#x17B7 . #x17BD)
1010 (#x17C6 . #x17C6)
1011 (#x17C9 . #x17D3)
1012 (#x17DD . #x17DD)
1013 (#x180B . #x180D)
1014 (#x18A9 . #x18A9)
1015 (#x1920 . #x1922)
1016 (#x1927 . #x1928)
1017 (#x1932 . #x1932)
1018 (#x1939 . #x193B)
1019 (#x1A17 . #x1A18)
1020 (#x1B00 . #x1B03)
1021 (#x1B34 . #x1B34)
1022 (#x1B36 . #x1B3A)
1023 (#x1B3C . #x1B3C)
1024 (#x1B42 . #x1B42)
1025 (#x1B6B . #x1B73)
1026 (#x1DC0 . #x1DFF)
1027 (#x200B . #x200F)
1028 (#x202A . #x202E)
1029 (#x2060 . #x206F)
1030 (#x20D0 . #x20EF)
1031 (#x302A . #x302F)
1032 (#x3099 . #x309A)
1033 (#xA806 . #xA806)
1034 (#xA80B . #xA80B)
1035 (#xA825 . #xA826)
1036 (#xFB1E . #xFB1E)
1037 (#xFE00 . #xFE0F)
1038 (#xFE20 . #xFE23)
1039 (#xFEFF . #xFEFF)
1040 (#xFFF9 . #xFFFB)
1041 (#x10A01 . #x10A0F)
1042 (#x10A38 . #x10A3F)
1043 (#x1D167 . #x1D169)
1044 (#x1D173 . #x1D182)
1045 (#x1D185 . #x1D18B)
1046 (#x1D1AA . #x1D1AD)
1047 (#x1D242 . #x1D244)
1048 (#xE0001 . #xE01EF))))
1049 (dolist (elt l)
1050 (set-char-table-range char-width-table elt 0)))
1052 ;; 2: East Asian Wide and Full-width characters.
1053 (let ((l '((#x1100 . #x115F)
1054 (#x2329 . #x232A)
1055 (#x2E80 . #x303E)
1056 (#x3040 . #xA4CF)
1057 (#xAC00 . #xD7A3)
1058 (#xF900 . #xFAFF)
1059 (#xFE30 . #xFE6F)
1060 (#xFF01 . #xFF60)
1061 (#xFFE0 . #xFFE6)
1062 (#x20000 . #x2FFFF)
1063 (#x30000 . #x3FFFF))))
1064 (dolist (elt l)
1065 (set-char-table-range char-width-table elt 2)))
1067 ;; Other double width
1068 ;;(map-charset-chars
1069 ;; (lambda (range ignore) (set-char-table-range char-width-table range 2))
1070 ;; 'ethiopic)
1071 ;; (map-charset-chars
1072 ;; (lambda (range ignore) (set-char-table-range char-width-table range 2))
1073 ;; 'tibetan)
1074 (map-charset-chars
1075 (lambda (range ignore) (set-char-table-range char-width-table range 2))
1076 'indian-2-column)
1077 (map-charset-chars
1078 (lambda (range ignore) (set-char-table-range char-width-table range 2))
1079 'arabic-2-column)
1081 ;; Internal use only.
1082 ;; Alist of locale symbol vs charsets. In a language environment
1083 ;; corresponding to the locale, width of characters in the charsets is
1084 ;; set to 2. Each element has the form:
1085 ;; (LOCALE TABLE (CHARSET (FROM-CODE . TO-CODE) ...) ...)
1086 ;; LOCALE: locale symbol
1087 ;; TABLE: char-table used for char-width-table, initially nil.
1088 ;; CAHRSET: character set
1089 ;; FROM-CODE, TO-CODE: range of code-points in CHARSET
1091 (defvar cjk-char-width-table-list
1092 '((ja_JP nil (japanese-jisx0208 (#x2121 . #x287E))
1093 (cp932-2-byte (#x8140 . #x879F)))
1094 (zh_CN nil (chinese-gb2312 (#x2121 . #x297E)))
1095 (zh_HK nil (big5-hkscs (#xA140 . #xA3FE) (#xC6A0 . #xC8FE)))
1096 (zh_TW nil (big5 (#xA140 . #xA3FE))
1097 (chinese-cns11643-1 (#x2121 . #x427E)))
1098 (ko_KR nil (korean-ksc5601 (#x2121 . #x2C7E)))))
1100 ;; Internal use only.
1101 ;; Setup char-width-table appropriate for a language environment
1102 ;; corresponding to LOCALE-NAME (symbol).
1104 (defun use-cjk-char-width-table (locale-name)
1105 (while (char-table-parent char-width-table)
1106 (setq char-width-table (char-table-parent char-width-table)))
1107 (let ((slot (assq locale-name cjk-char-width-table-list))
1108 table)
1109 (or slot (error "Unknown locale for CJK language environment: %s"
1110 locale-name))
1111 (unless (nth 1 slot)
1112 (let ((table (make-char-table nil)))
1113 (dolist (charset-info (nthcdr 2 slot))
1114 (let ((charset (car charset-info)))
1115 (dolist (code-range (cdr charset-info))
1116 (map-charset-chars #'(lambda (range arg)
1117 (set-char-table-range table range 2))
1118 charset nil
1119 (car code-range) (cdr code-range)))))
1120 (optimize-char-table table)
1121 (set-char-table-parent table char-width-table)
1122 (setcar (cdr slot) table)))
1123 (setq char-width-table (nth 1 slot))))
1125 (defun use-default-char-width-table ()
1126 "Internal use only.
1127 Setup char-width-table appropriate for non-CJK language environment."
1128 (while (char-table-parent char-width-table)
1129 (setq char-width-table (char-table-parent char-width-table))))
1131 (optimize-char-table (standard-case-table))
1132 (optimize-char-table (standard-syntax-table))
1135 ;; Setting char-script-table.
1137 ;; The data is compiled from Blocks.txt and Scripts.txt in the
1138 ;; "Unicode Character Database", simplified to lump together all the
1139 ;; blocks belonging to the same language. E.g., "Basic Latin",
1140 ;; "Latin-1 Supplement", "Latin Extended-A", etc. are all lumped
1141 ;; together under "latin".
1143 ;; The Unicode blocks actually extend past some of these ranges with
1144 ;; undefined codepoints.
1145 (let ((script-list nil))
1146 (dolist
1147 (elt
1148 '((#x0000 #x007F latin)
1149 (#x00A0 #x024F latin)
1150 (#x0250 #x02AF phonetic)
1151 (#x02B0 #x036F latin)
1152 (#x0370 #x03E1 greek)
1153 (#x03E2 #x03EF coptic)
1154 (#x03F0 #x03F3 greek)
1155 (#x0400 #x052F cyrillic)
1156 (#x0530 #x058F armenian)
1157 (#x0590 #x05FF hebrew)
1158 (#x0600 #x06FF arabic)
1159 (#x0700 #x074F syriac)
1160 (#x0750 #x077F arabic)
1161 (#x0780 #x07BF thaana)
1162 (#x07C0 #x07FF nko)
1163 (#x0800 #x083F samaritan)
1164 (#x0840 #x085F mandaic)
1165 (#x08A0 #x08FF arabic)
1166 (#x0900 #x097F devanagari)
1167 (#x0980 #x09FF bengali)
1168 (#x0A00 #x0A7F gurmukhi)
1169 (#x0A80 #x0AFF gujarati)
1170 (#x0B00 #x0B7F oriya)
1171 (#x0B80 #x0BFF tamil)
1172 (#x0C00 #x0C7F telugu)
1173 (#x0C80 #x0CFF kannada)
1174 (#x0D00 #x0D7F malayalam)
1175 (#x0D80 #x0DFF sinhala)
1176 (#x0E00 #x0E7F thai)
1177 (#x0E80 #x0EFF lao)
1178 (#x0F00 #x0FFF tibetan)
1179 (#x1000 #x109F burmese) ; according to Unicode 6.1, should be "myanmar"
1180 (#x10A0 #x10FF georgian)
1181 (#x1100 #x11FF hangul)
1182 (#x1200 #x139F ethiopic)
1183 (#x13A0 #x13FF cherokee)
1184 (#x1400 #x167F canadian-aboriginal)
1185 (#x1680 #x169F ogham)
1186 (#x16A0 #x16FF runic)
1187 (#x1700 #x171F tagalog)
1188 (#x1720 #x173F hanunoo)
1189 (#x1740 #x175F buhid)
1190 (#x1760 #x177F tagbanwa)
1191 (#x1780 #x17FF khmer)
1192 (#x1800 #x18AF mongolian)
1193 (#x18B0 #x18FF canadian-aboriginal)
1194 (#x1900 #x194F limbu)
1195 (#x1950 #x197F tai-le)
1196 (#x1980 #x19DF tai-lue)
1197 (#x19E0 #x19FF khmer)
1198 (#x1A00 #x1A00 buginese)
1199 (#x1A20 #x1AAF tai-tham)
1200 (#x1B00 #x1B7F balinese)
1201 (#x1B80 #x1BBF sundanese)
1202 (#x1BC0 #x1BFF batak)
1203 (#x1C00 #x1C4F lepcha)
1204 (#x1C50 #x1C7F ol-chiki)
1205 (#x1CC0 #x1CCF sundanese)
1206 (#x1CD0 #x1CFF vedic)
1207 (#x1D00 #x1DBF phonetic)
1208 (#x1DC0 #x1EFF latin)
1209 (#x1F00 #x1FFF greek)
1210 (#x2000 #x27FF symbol)
1211 (#x2800 #x28FF braille)
1212 (#x2900 #x2BFF symbol)
1213 (#x2C00 #x2C5F glagolitic)
1214 (#x2C60 #x2C7F latin)
1215 (#x2C80 #x2CFF coptic)
1216 (#x2D00 #x2D2F georgian)
1217 (#x2D30 #x2D7F tifinagh)
1218 (#x2D80 #x2DDF ethiopic)
1219 (#x2DE0 #x2DFF cyrillic)
1220 (#x2E00 #x2E7F symbol)
1221 (#x2E80 #x2FDF han)
1222 (#x2FF0 #x2FFF ideographic-description)
1223 (#x3000 #x303F cjk-misc)
1224 (#x3040 #x30FF kana)
1225 (#x3100 #x312F bopomofo)
1226 (#x3130 #x318F hangul)
1227 (#x3190 #x319F kanbun)
1228 (#x31A0 #x31BF bopomofo)
1229 (#x31C0 #x31EF cjk-misc)
1230 (#x31F0 #x31FF kana)
1231 (#x3200 #x9FAF han)
1232 (#xA000 #xA4CF yi)
1233 (#xA4D0 #xA4FF lisu)
1234 (#xA500 #xA63F vai)
1235 (#xA640 #xA69F cyrillic)
1236 (#xA6A0 #xA6FF bamum)
1237 (#xA700 #xA7FF latin)
1238 (#xA800 #xA82F syloti-nagri)
1239 (#xA830 #xA83F north-indic-number)
1240 (#xA840 #xA87F phags-pa)
1241 (#xA880 #xA8DF saurashtra)
1242 (#xA8E0 #xA8FF devanagari)
1243 (#xA900 #xA92F kayah-li)
1244 (#xA930 #xA95F rejang)
1245 (#xA960 #xA97F hangul)
1246 (#xA980 #xA9DF javanese)
1247 (#xAA00 #xAA5F cham)
1248 (#xAA60 #xAA7B burmese) ; Unicode 6.1: "myanmar"
1249 (#xAA80 #xAADF tai-viet)
1250 (#xAAE0 #xAAFF meetei-mayek)
1251 (#xAB00 #xAB2F ethiopic)
1252 (#xABC0 #xABFF meetei-mayek)
1253 (#xAC00 #xD7FF hangul)
1254 (#xF900 #xFAFF han)
1255 (#xFB1D #xFB4F hebrew)
1256 (#xFB50 #xFDFF arabic)
1257 (#xFE30 #xFE4F han)
1258 (#xFE70 #xFEFF arabic)
1259 (#xFF00 #xFF5F cjk-misc)
1260 (#xFF61 #xFF9F kana)
1261 (#xFFE0 #xFFE6 cjk-misc)
1262 (#x10000 #x100FF linear-b)
1263 (#x10100 #x1013F aegean-number)
1264 (#x10140 #x1018F ancient-greek-number)
1265 (#x10190 #x101CF ancient-symbol)
1266 (#x101D0 #x101FF phaistos-disc)
1267 (#x10280 #x1029F lycian)
1268 (#x102A0 #x102DF carian)
1269 (#x10300 #x1032F olt-italic)
1270 (#x10330 #x1034F gothic)
1271 (#x10380 #x1039F ugaritic)
1272 (#x103A0 #x103DF old-persian)
1273 (#x10400 #x1044F deseret)
1274 (#x10450 #x1047F shavian)
1275 (#x10480 #x104AF osmanya)
1276 (#x10800 #x1083F cypriot-syllabary)
1277 (#x10840 #x1085F aramaic)
1278 (#x10900 #x1091F phoenician)
1279 (#x10920 #x1093F lydian)
1280 (#x10980 #x109FF meroitic)
1281 (#x10A00 #x10A5F kharoshthi)
1282 (#x10A60 #x10A7F old-south-arabian)
1283 (#x10B00 #x10B3F avestan)
1284 (#x10B40 #x10B5F inscriptional-parthian)
1285 (#x10B60 #x10B7F inscriptional-pahlavi)
1286 (#x10C00 #x10C4F old-turkic)
1287 (#x10E60 #x10E7F rumi-number)
1288 (#x11000 #x1107F brahmi)
1289 (#x11080 #x110CF kaithi)
1290 (#x110D0 #x110FF sora-sompeng)
1291 (#x11100 #x1114F chakma)
1292 (#x11180 #x111DF sharada)
1293 (#x11680 #x116CF takri)
1294 (#x12000 #x123FF cuneiform)
1295 (#x12400 #x1247F cuneiform-numbers-and-punctuation)
1296 (#x13000 #x1342F egyptian)
1297 (#x16800 #x16A3F bamum)
1298 (#x16F00 #x16F9F miao)
1299 (#x1B000 #x1B0FF kana)
1300 (#x1D000 #x1D0FF byzantine-musical-symbol)
1301 (#x1D100 #x1D1FF musical-symbol)
1302 (#x1D200 #x1D24F ancient-greek-musical-notation)
1303 (#x1D300 #x1D35F tai-xuan-jing-symbol)
1304 (#x1D360 #x1D37F counting-rod-numeral)
1305 (#x1D400 #x1D7FF mathematical)
1306 (#x1EE00 #x1EEFF arabic)
1307 (#x1F000 #x1F02F mahjong-tile)
1308 (#x1F030 #x1F09F domino-tile)
1309 (#x1F0A0 #x1F0FF playing-cards)
1310 (#x1F100 #x1F1FF symbol)
1311 (#x1F200 #x1F2FF han)
1312 (#x1F300 #x1F64F symbol)
1313 (#x1F680 #x1F77F symbol)
1314 (#x20000 #x2B81F han)
1315 (#x2F800 #x2FFFF han)))
1316 (set-char-table-range char-script-table
1317 (cons (car elt) (nth 1 elt)) (nth 2 elt))
1318 (or (memq (nth 2 elt) script-list)
1319 (setq script-list (cons (nth 2 elt) script-list))))
1320 (set-char-table-extra-slot char-script-table 0 (nreverse script-list)))
1322 (map-charset-chars
1323 #'(lambda (range ignore)
1324 (set-char-table-range char-script-table range 'tibetan))
1325 'tibetan)
1328 ;;; Setting unicode-category-table.
1330 (setq unicode-category-table
1331 (unicode-property-table-internal 'general-category))
1332 (map-char-table #'(lambda (key val)
1333 (if (and val
1334 (or (and (/= (aref (symbol-name val) 0) ?M)
1335 (/= (aref (symbol-name val) 0) ?C))
1336 (eq val 'Zs)))
1337 (modify-category-entry key ?.)))
1338 unicode-category-table)
1340 (optimize-char-table (standard-category-table))
1343 ;; Display of glyphless characters.
1345 (defvar char-acronym-table
1346 (make-char-table 'char-acronym-table nil)
1347 "Char table of acronyms for non-graphic characters.")
1349 (let ((c0-acronyms '("NUL" "SOH" "STX" "ETX" "EOT" "ENQ" "ACK" "BEL"
1350 "BS" nil nil "VT" "FF" "CR" "SO" "SI"
1351 "DLE" "DC1" "DC2" "DC3" "DC4" "NAK" "SYN" "ETB"
1352 "CAN" "EM" "SUB" "ESC" "FC" "GS" "RS" "US")))
1353 (dotimes (i 32)
1354 (aset char-acronym-table i (car c0-acronyms))
1355 (setq c0-acronyms (cdr c0-acronyms))))
1357 (let ((c1-acronyms '("XXX" "XXX" "BPH" "NBH" "IND" "NEL" "SSA" "ESA"
1358 "HTS" "HTJ" "VTS" "PLD" "PLU" "R1" "SS2" "SS1"
1359 "DCS" "PU1" "PU2" "STS" "CCH" "MW" "SPA" "EPA"
1360 "SOS" "XXX" "SC1" "CSI" "ST" "OSC" "PM" "APC")))
1361 (dotimes (i 32)
1362 (aset char-acronym-table (+ #x0080 i) (car c1-acronyms))
1363 (setq c1-acronyms (cdr c1-acronyms))))
1365 (aset char-acronym-table #x17B4 "KIVAQ") ; KHMER VOWEL INHERENT AQ
1366 (aset char-acronym-table #x17B5 "KIVAA") ; KHMER VOWEL INHERENT AA
1367 (aset char-acronym-table #x200B "ZWSP") ; ZERO WIDTH SPACE
1368 (aset char-acronym-table #x200C "ZWNJ") ; ZERO WIDTH NON-JOINER
1369 (aset char-acronym-table #x200D "ZWJ") ; ZERO WIDTH JOINER
1370 (aset char-acronym-table #x200E "LRM") ; LEFT-TO-RIGHT MARK
1371 (aset char-acronym-table #x200F "RLM") ; RIGHT-TO-LEFT MARK
1372 (aset char-acronym-table #x202A "LRE") ; LEFT-TO-RIGHT EMBEDDING
1373 (aset char-acronym-table #x202B "RLE") ; RIGHT-TO-LEFT EMBEDDING
1374 (aset char-acronym-table #x202C "PDF") ; POP DIRECTIONAL FORMATTING
1375 (aset char-acronym-table #x202D "LRO") ; LEFT-TO-RIGHT OVERRIDE
1376 (aset char-acronym-table #x202E "RLO") ; RIGHT-TO-LEFT OVERRIDE
1377 (aset char-acronym-table #x2060 "WJ") ; WORD JOINER
1378 (aset char-acronym-table #x206A "ISS") ; INHIBIT SYMMETRIC SWAPPING
1379 (aset char-acronym-table #x206B "ASS") ; ACTIVATE SYMMETRIC SWAPPING
1380 (aset char-acronym-table #x206C "IAFS") ; INHIBIT ARABIC FORM SHAPING
1381 (aset char-acronym-table #x206D "AAFS") ; ACTIVATE ARABIC FORM SHAPING
1382 (aset char-acronym-table #x206E "NADS") ; NATIONAL DIGIT SHAPES
1383 (aset char-acronym-table #x206F "NODS") ; NOMINAL DIGIT SHAPES
1384 (aset char-acronym-table #xFEFF "ZWNBSP") ; ZERO WIDTH NO-BREAK SPACE
1385 (aset char-acronym-table #xFFF9 "IAA") ; INTERLINEAR ANNOTATION ANCHOR
1386 (aset char-acronym-table #xFFFA "IAS") ; INTERLINEAR ANNOTATION SEPARATOR
1387 (aset char-acronym-table #xFFFB "IAT") ; INTERLINEAR ANNOTATION TERMINATOR
1388 (aset char-acronym-table #x1D173 "BEGBM") ; MUSICAL SYMBOL BEGIN BEAM
1389 (aset char-acronym-table #x1D174 "ENDBM") ; MUSICAL SYMBOL END BEAM
1390 (aset char-acronym-table #x1D175 "BEGTIE") ; MUSICAL SYMBOL BEGIN TIE
1391 (aset char-acronym-table #x1D176 "END") ; MUSICAL SYMBOL END TIE
1392 (aset char-acronym-table #x1D177 "BEGSLR") ; MUSICAL SYMBOL BEGIN SLUR
1393 (aset char-acronym-table #x1D178 "ENDSLR") ; MUSICAL SYMBOL END SLUR
1394 (aset char-acronym-table #x1D179 "BEGPHR") ; MUSICAL SYMBOL BEGIN PHRASE
1395 (aset char-acronym-table #x1D17A "ENDPHR") ; MUSICAL SYMBOL END PHRASE
1396 (aset char-acronym-table #xE0001 "|->TAG") ; LANGUAGE TAG
1397 (aset char-acronym-table #xE0020 "SP TAG") ; TAG SPACE
1398 (dotimes (i 94)
1399 (aset char-acronym-table (+ #xE0021 i) (format " %c TAG" (+ 33 i))))
1400 (aset char-acronym-table #xE007F "->|TAG") ; CANCEL TAG
1402 (defun update-glyphless-char-display (&optional variable value)
1403 "Make the setting of `glyphless-char-display-control' take effect.
1404 This function updates the char-table `glyphless-char-display'."
1405 (when value
1406 (set-default variable value))
1407 (dolist (elt value)
1408 (let ((target (car elt))
1409 (method (cdr elt)))
1410 (or (memq method '(zero-width thin-space empty-box acronym hex-code))
1411 (error "Invalid glyphless character display method: %s" method))
1412 (cond ((eq target 'c0-control)
1413 (set-char-table-range glyphless-char-display '(#x00 . #x1F)
1414 method)
1415 ;; Users will not expect their newlines and TABs be
1416 ;; displayed as anything but themselves, so exempt those
1417 ;; two characters from c0-control.
1418 (set-char-table-range glyphless-char-display #x9 nil)
1419 (set-char-table-range glyphless-char-display #xa nil))
1420 ((eq target 'c1-control)
1421 (set-char-table-range glyphless-char-display '(#x80 . #x9F)
1422 method))
1423 ((eq target 'format-control)
1424 (map-char-table
1425 #'(lambda (char category)
1426 (if (eq category 'Cf)
1427 (let ((this-method method)
1428 from to)
1429 (if (consp char)
1430 (setq from (car char) to (cdr char))
1431 (setq from char to char))
1432 (while (<= from to)
1433 (when (/= from #xAD)
1434 (if (eq method 'acronym)
1435 (setq this-method
1436 (aref char-acronym-table from)))
1437 (set-char-table-range glyphless-char-display
1438 from this-method))
1439 (setq from (1+ from))))))
1440 unicode-category-table))
1441 ((eq target 'no-font)
1442 (set-char-table-extra-slot glyphless-char-display 0 method))
1444 (error "Invalid glyphless character group: %s" target))))))
1446 ;;; Control of displaying glyphless characters.
1447 (defcustom glyphless-char-display-control
1448 '((format-control . thin-space)
1449 (no-font . hex-code))
1450 "List of directives to control display of glyphless characters.
1452 Each element has the form (GROUP . METHOD), where GROUP is a
1453 symbol specifying the character group, and METHOD is a symbol
1454 specifying the method of displaying characters belonging to that
1455 group.
1457 GROUP must be one of these symbols:
1458 `c0-control': U+0000..U+001F, but excluding newline and TAB.
1459 `c1-control': U+0080..U+009F.
1460 `format-control': Characters of Unicode General Category `Cf',
1461 such as U+200C (ZWNJ), U+200E (LRM), but
1462 excluding characters that have graphic images,
1463 such as U+00AD (SHY).
1464 `no-font': characters for which no suitable font is found.
1465 For character terminals, characters that cannot
1466 be encoded by `terminal-coding-system'.
1468 METHOD must be one of these symbols:
1469 `zero-width': don't display.
1470 `thin-space': display a thin (1-pixel width) space. On character
1471 terminals, display as 1-character space.
1472 `empty-box': display an empty box.
1473 `acronym': display an acronym of the character in a box. The
1474 acronym is taken from `char-acronym-table', which see.
1475 `hex-code': display the hexadecimal character code in a box."
1476 :version "24.1"
1477 :type '(alist :key-type (symbol :tag "Character Group")
1478 :value-type (symbol :tag "Display Method"))
1479 :options '((c0-control
1480 (choice (const :tag "Don't display" zero-width)
1481 (const :tag "Display as thin space" thin-space)
1482 (const :tag "Display as empty box" empty-box)
1483 (const :tag "Display acronym" acronym)
1484 (const :tag "Display hex code in a box" hex-code)))
1485 (c1-control
1486 (choice (const :tag "Don't display" zero-width)
1487 (const :tag "Display as thin space" thin-space)
1488 (const :tag "Display as empty box" empty-box)
1489 (const :tag "Display acronym" acronym)
1490 (const :tag "Display hex code in a box" hex-code)))
1491 (format-control
1492 (choice (const :tag "Don't display" zero-width)
1493 (const :tag "Display as thin space" thin-space)
1494 (const :tag "Display as empty box" empty-box)
1495 (const :tag "Display acronym" acronym)
1496 (const :tag "Display hex code in a box" hex-code)))
1497 (no-font
1498 (choice (const :tag "Don't display" zero-width)
1499 (const :tag "Display as thin space" thin-space)
1500 (const :tag "Display as empty box" empty-box)
1501 (const :tag "Display acronym" acronym)
1502 (const :tag "Display hex code in a box" hex-code))))
1503 :set 'update-glyphless-char-display
1504 :group 'display)
1507 ;;; Setting word boundary.
1509 (setq word-combining-categories
1510 '((nil . ?^)
1511 (?^ . nil)
1512 (?C . ?H)
1513 (?C . ?K)))
1515 (setq word-separating-categories ; (2-byte character sets)
1516 '((?H . ?K) ; Hiragana - Katakana
1519 ;; Local Variables:
1520 ;; coding: utf-8
1521 ;; End:
1523 ;;; characters.el ends here