; Minor copyedits in manuals.
[emacs.git] / lisp / international / characters.el
blobe48fc83c3dff2e85de31560f870f65d6a90ef33f
1 ;;; characters.el --- set syntax and category for multibyte characters
3 ;; Copyright (C) 1997, 2000-2017 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 . #x4DB5) ?C)
145 (modify-category-entry '(#x4E00 . #x9FD5) ?C)
146 (modify-category-entry '(#x3400 . #x9FD5) ?c)
147 (modify-category-entry '(#x3400 . #x9FD5) ?|)
148 (modify-category-entry '(#xF900 . #xFAFF) ?C)
149 (modify-category-entry '(#xF900 . #xFAFF) ?c)
150 (modify-category-entry '(#xF900 . #xFAFF) ?|)
151 (modify-category-entry '(#x1B170 . #x1B2FF) ?c)
152 (modify-category-entry '(#x20000 . #x2FFFF) ?|)
153 (modify-category-entry '(#x20000 . #x2FFFF) ?C)
154 (modify-category-entry '(#x20000 . #x2FFFF) ?c)
157 ;; Chinese character set (GB2312)
159 (map-charset-chars #'modify-syntax-entry 'chinese-gb2312 "_" #x2121 #x217E)
160 (map-charset-chars #'modify-syntax-entry 'chinese-gb2312 "_" #x2221 #x227E)
161 (map-charset-chars #'modify-syntax-entry 'chinese-gb2312 "_" #x2921 #x297E)
163 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?c)
164 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?A #x2330 #x2339)
165 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?A #x2341 #x235A)
166 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?A #x2361 #x237A)
167 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?H #x2421 #x247E)
168 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?K #x2521 #x257E)
169 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?G #x2621 #x267E)
170 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?Y #x2721 #x277E)
171 (map-charset-chars #'modify-category-entry 'chinese-gb2312 ?C #x3021 #x7E7E)
173 ;; Chinese character set (BIG5)
175 (map-charset-chars #'modify-category-entry 'big5 ?c)
176 (map-charset-chars #'modify-category-entry 'big5 ?C #xA259 #xA261)
177 (map-charset-chars #'modify-category-entry 'big5 ?C #xA440 #xC67E)
178 (map-charset-chars #'modify-category-entry 'big5 ?C #xC940 #xF9DC)
180 ;; Chinese character set (CNS11643)
182 (dolist (c '(chinese-cns11643-1 chinese-cns11643-2 chinese-cns11643-3
183 chinese-cns11643-4 chinese-cns11643-5 chinese-cns11643-6
184 chinese-cns11643-7))
185 (map-charset-chars #'modify-category-entry c ?c)
186 (if (eq c 'chinese-cns11643-1)
187 (map-charset-chars #'modify-category-entry c ?C #x4421 #x7E7E)
188 (map-charset-chars #'modify-category-entry c ?C)))
190 ;; Japanese character set (JISX0201, JISX0208, JISX0212, JISX0213)
192 (map-charset-chars #'modify-category-entry 'katakana-jisx0201 ?k)
194 (map-charset-chars #'modify-category-entry 'latin-jisx0201 ?r)
196 (dolist (l '(katakana-jisx0201 japanese-jisx0208 japanese-jisx0212
197 japanese-jisx0213-1 japanese-jisx0213-2
198 japanese-jisx0213.2004-1
199 cp932-2-byte))
200 (map-charset-chars #'modify-category-entry l ?j))
202 ;; Fullwidth characters
203 (modify-category-entry '(#xff01 . #xff60) ?\|)
205 ;; Unicode equivalents of JISX0201-kana
206 (let ((range '(#xff61 . #xff9f)))
207 (modify-category-entry range ?k)
208 (modify-category-entry range ?j)
209 (modify-category-entry range ?\|))
211 ;; Katakana block
212 (modify-category-entry '(#x3099 . #x309C) ?K)
213 (modify-category-entry '(#x30A0 . #x30FF) ?K)
214 (modify-category-entry '(#x31F0 . #x31FF) ?K)
215 (modify-category-entry '(#x30A0 . #x30FA) ?\|)
216 (modify-category-entry #x30FF ?\|)
218 ;; Hiragana block
219 (modify-category-entry '(#x3040 . #x309F) ?H)
220 (modify-category-entry '(#x3040 . #x3096) ?\|)
221 (modify-category-entry #x309F ?\|)
222 (modify-category-entry #x30A0 ?H)
223 (modify-category-entry #x30FC ?H)
225 (modify-category-entry '(#x1B000 . #x1B1FF) ?j)
228 ;; JISX0208
229 (map-charset-chars #'modify-syntax-entry 'japanese-jisx0208 "_" #x2121 #x227E)
230 (map-charset-chars #'modify-syntax-entry 'japanese-jisx0208 "_" #x2821 #x287E)
231 (let ((chars '(?ー ?゛ ?゜ ?ヽ ?ヾ ?ゝ ?ゞ ?〃 ?仝 ?々 ?〆 ?〇)))
232 (dolist (elt chars)
233 (modify-syntax-entry elt "w")))
235 (map-charset-chars #'modify-category-entry 'japanese-jisx0208 ?A #x2321 #x237E)
236 (map-charset-chars #'modify-category-entry 'japanese-jisx0208 ?H #x2421 #x247E)
237 (map-charset-chars #'modify-category-entry 'japanese-jisx0208 ?K #x2521 #x257E)
238 (map-charset-chars #'modify-category-entry 'japanese-jisx0208 ?G #x2621 #x267E)
239 (map-charset-chars #'modify-category-entry 'japanese-jisx0208 ?Y #x2721 #x277E)
240 (map-charset-chars #'modify-category-entry 'japanese-jisx0208 ?C #x3021 #x7E7E)
241 (let ((chars '(?仝 ?々 ?〆 ?〇)))
242 (while chars
243 (modify-category-entry (car chars) ?C)
244 (setq chars (cdr chars))))
246 ;; JISX0212
248 (map-charset-chars #'modify-syntax-entry 'japanese-jisx0212 "_" #x2121 #x237E)
250 ;; JISX0201-Kana
252 (let ((chars '(?。 ?、 ?・)))
253 (while chars
254 (modify-syntax-entry (car chars) ".")
255 (setq chars (cdr chars))))
257 (modify-syntax-entry ?\「 "(」")
258 (modify-syntax-entry ?\」 "(「")
260 ;; Korean character set (KSC5601)
262 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?h)
264 (map-charset-chars #'modify-syntax-entry 'korean-ksc5601 "_" #x2121 #x227E)
265 (map-charset-chars #'modify-syntax-entry 'korean-ksc5601 "_" #x2621 #x277E)
266 (map-charset-chars #'modify-syntax-entry 'korean-ksc5601 "_" #x2830 #x287E)
267 (map-charset-chars #'modify-syntax-entry 'korean-ksc5601 "_" #x2930 #x297E)
268 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?A #x2330 #x2339)
269 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?A #x2341 #x235A)
270 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?A #x2361 #x237A)
271 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?G #x2521 #x257E)
272 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?H #x2A21 #x2A7E)
273 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?K #x2B21 #x2B7E)
274 (map-charset-chars #'modify-category-entry 'korean-ksc5601 ?Y #x2C21 #x2C7E)
276 ;; These are in more than one charset.
277 (let ((parens (concat "〈〉《》「」『』【】〔〕〖〗〘〙〚〛"
278 "︵︶︷︸︹︺︻︼︽︾︿﹀﹁﹂﹃﹄"
279 "()[]{}"))
280 open close)
281 (dotimes (i (/ (length parens) 2))
282 (setq open (aref parens (* i 2))
283 close (aref parens (1+ (* i 2))))
284 (modify-syntax-entry open (format "(%c" close))
285 (modify-syntax-entry close (format ")%c" open))))
287 ;; Arabic character set
289 (let ((charsets '(arabic-iso8859-6
290 arabic-digit
291 arabic-1-column
292 arabic-2-column)))
293 (while charsets
294 (map-charset-chars #'modify-category-entry (car charsets) ?b)
295 (setq charsets (cdr charsets))))
296 (modify-category-entry '(#x600 . #x6ff) ?b)
297 (modify-category-entry '(#x8a0 . #x8ff) ?b)
298 (modify-category-entry '(#xfb50 . #xfdff) ?b)
299 (modify-category-entry '(#xfe70 . #xfefe) ?b)
301 ;; Cyrillic character set (ISO-8859-5)
303 (modify-syntax-entry ?№ ".")
305 ;; Ethiopic character set
307 (modify-category-entry '(#x1200 . #x1399) ?e)
308 (modify-category-entry '(#x2d80 . #x2dde) ?e)
309 (let ((chars '(?፡ ?። ?፣ ?፤ ?፥ ?፦ ?፧ ?፨)))
310 (while chars
311 (modify-syntax-entry (car chars) ".")
312 (setq chars (cdr chars))))
313 (map-charset-chars #'modify-category-entry 'ethiopic ?e)
315 ;; Hebrew character set (ISO-8859-8)
317 (modify-syntax-entry #x5be ".") ; MAQAF
318 (modify-syntax-entry #x5c0 ".") ; PASEQ
319 (modify-syntax-entry #x5c3 ".") ; SOF PASUQ
320 (modify-syntax-entry #x5f3 ".") ; GERESH
321 (modify-syntax-entry #x5f4 ".") ; GERSHAYIM
323 ;; Indian character set (IS 13194 and other Emacs original Indian charsets)
325 (modify-category-entry '(#x901 . #x970) ?i)
326 (map-charset-chars #'modify-category-entry 'indian-is13194 ?i)
327 (map-charset-chars #'modify-category-entry 'indian-2-column ?i)
329 ;; Lao character set
331 (modify-category-entry '(#xe80 . #xeff) ?o)
332 (map-charset-chars #'modify-category-entry 'lao ?o)
334 (let ((deflist '(("ກ-ຮ" "w" ?0) ; consonant
335 ("ະາຳຽເ-ໄ" "w" ?1) ; vowel base
336 ("ັິ-ືົໍ" "w" ?2) ; vowel upper
337 ("ຸູ" "w" ?3) ; vowel lower
338 ("່-໋" "w" ?4) ; tone mark
339 ("ຼຽ" "w" ?9) ; semivowel lower
340 ("໐-໙" "w" ?6) ; digit
341 ("ຯໆ" "_" ?5) ; symbol
343 elm chars len syntax category to ch i)
344 (while deflist
345 (setq elm (car deflist))
346 (setq chars (car elm)
347 len (length chars)
348 syntax (nth 1 elm)
349 category (nth 2 elm)
350 i 0)
351 (while (< i len)
352 (if (= (aref chars i) ?-)
353 (setq i (1+ i)
354 to (aref chars i))
355 (setq ch (aref chars i)
356 to ch))
357 (while (<= ch to)
358 (unless (string-equal syntax "w")
359 (modify-syntax-entry ch syntax))
360 (modify-category-entry ch category)
361 (setq ch (1+ ch)))
362 (setq i (1+ i)))
363 (setq deflist (cdr deflist))))
365 ;; Thai character set (TIS620)
367 (modify-category-entry '(#xe00 . #xe7f) ?t)
368 (map-charset-chars #'modify-category-entry 'thai-tis620 ?t)
370 (let ((deflist '(;; chars syntax category
371 ("ก-รลว-ฮ" "w" ?0) ; consonant
372 ("ฤฦะาำเ-ๅ" "w" ?1) ; vowel base
373 ("ัิ-ื็๎" "w" ?2) ; vowel upper
374 ("ุ-ฺ" "w" ?3) ; vowel lower
375 ("่-ํ" "w" ?4) ; tone mark
376 ("๐-๙" "w" ?6) ; digit
377 ("ฯๆ฿๏๚๛" "_" ?5) ; symbol
379 elm chars len syntax category to ch i)
380 (while deflist
381 (setq elm (car deflist))
382 (setq chars (car elm)
383 len (length chars)
384 syntax (nth 1 elm)
385 category (nth 2 elm)
386 i 0)
387 (while (< i len)
388 (if (= (aref chars i) ?-)
389 (setq i (1+ i)
390 to (aref chars i))
391 (setq ch (aref chars i)
392 to ch))
393 (while (<= ch to)
394 (unless (string-equal syntax "w")
395 (modify-syntax-entry ch syntax))
396 (modify-category-entry ch category)
397 (setq ch (1+ ch)))
398 (setq i (1+ i)))
399 (setq deflist (cdr deflist))))
401 ;; Tibetan character set
403 (modify-category-entry '(#xf00 . #xfff) ?q)
404 (map-charset-chars #'modify-category-entry 'tibetan ?q)
405 (map-charset-chars #'modify-category-entry 'tibetan-1-column ?q)
407 (let ((deflist '(;; chars syntax category
408 ("ཀ-ཀྵཪ" "w" ?0) ; consonant
409 ("ྐ-ྐྵྺྻྼ" "w" ?0) ;
410 ("ིེཻོཽྀ" "w" ?2) ; upper vowel
411 ("ཾྂྃ྆྇ྈྉྊྋ" "w" ?2) ; upper modifier
412 ("྄ཱུ༙༵༷" "w" ?3) ; lower vowel/modifier
413 ("཰" "w" ?3) ; invisible vowel a
414 ("༠-༩༪-༳" "w" ?6) ; digit
415 ("་།-༒༔ཿ" "." ?|) ; line-break char
416 ("་།༏༐༑༔ཿ" "." ?|) ;
417 ("༈་།-༒༔ཿ༽༴" "." ?>) ; prohibition
418 ("་།༏༐༑༔ཿ" "." ?>) ;
419 ("ༀ-༊༼࿁࿂྅" "." ?<) ; prohibition
420 ("༓༕-༘༚-༟༶༸-༻༾༿྾྿-࿏" "." ?q) ; others
422 elm chars len syntax category to ch i)
423 (while deflist
424 (setq elm (car deflist))
425 (setq chars (car elm)
426 len (length chars)
427 syntax (nth 1 elm)
428 category (nth 2 elm)
429 i 0)
430 (while (< i len)
431 (if (= (aref chars i) ?-)
432 (setq i (1+ i)
433 to (aref chars i))
434 (setq ch (aref chars i)
435 to ch))
436 (while (<= ch to)
437 (unless (string-equal syntax "w")
438 (modify-syntax-entry ch syntax))
439 (modify-category-entry ch category)
440 (setq ch (1+ ch)))
441 (setq i (1+ i)))
442 (setq deflist (cdr deflist))))
444 ;; Vietnamese character set
446 ;; To make a word with Latin characters
447 (map-charset-chars #'modify-category-entry 'vietnamese-viscii-lower ?l)
448 (map-charset-chars #'modify-category-entry 'vietnamese-viscii-lower ?v)
450 (map-charset-chars #'modify-category-entry 'vietnamese-viscii-upper ?l)
451 (map-charset-chars #'modify-category-entry 'vietnamese-viscii-upper ?v)
453 (let ((tbl (standard-case-table))
454 (i 32))
455 (while (< i 128)
456 (let* ((char (decode-char 'vietnamese-viscii-upper i))
457 (charl (decode-char 'vietnamese-viscii-lower i))
458 (uc (encode-char char 'ucs))
459 (lc (encode-char charl 'ucs)))
460 (set-case-syntax-pair char (decode-char 'vietnamese-viscii-lower i)
461 tbl)
462 (if uc (modify-category-entry uc ?v))
463 (if lc (modify-category-entry lc ?v)))
464 (setq i (1+ i))))
466 ;; Tai Viet
467 (let ((deflist '(;; chars syntax category
468 ((?ꪀ. ?ꪯ) "w" ?0) ; consonant
469 ("ꪱꪵꪶ" "w" ?1) ; vowel base
470 ((?ꪹ . ?ꪽ) "w" ?1) ; vowel base
471 ("ꪰꪲꪳꪷꪸꪾ" "w" ?2) ; vowel upper
472 ("ꪴ" "w" ?3) ; vowel lower
473 ("ꫀꫂ" "w" ?1) ; non-combining tone-mark
474 ("꪿꫁" "w" ?4) ; combining tone-mark
475 ((?ꫛ . ?꫟) "_" ?5) ; symbol
477 (dolist (elm deflist)
478 (let ((chars (car elm))
479 (syntax (nth 1 elm))
480 (category (nth 2 elm)))
481 (if (consp chars)
482 (progn
483 (modify-syntax-entry chars syntax)
484 (modify-category-entry chars category))
485 (mapc #'(lambda (x)
486 (modify-syntax-entry x syntax)
487 (modify-category-entry x category))
488 chars)))))
490 ;; Bidi categories
492 ;; If bootstrapping without generated uni-*.el files, table not defined.
493 (let ((table (unicode-property-table-internal 'bidi-class)))
494 (when table
495 (map-char-table (lambda (key val)
496 (cond
497 ((memq val '(R AL RLO RLE))
498 (modify-category-entry key ?R))
499 ((memq val '(L LRE LRO))
500 (modify-category-entry key ?L))))
501 table)))
503 ;; Load uni-mirrored.el and uni-brackets.el if available, so that they
504 ;; get dumped into Emacs. This allows starting Emacs with
505 ;; force-load-messages in ~/.emacs, and avoid infinite recursion in
506 ;; bidi_initialize, which needs to load uni-mirrored.el and
507 ;; uni-brackets.el in order to display the "Loading" messages.
508 (unicode-property-table-internal 'mirroring)
509 (unicode-property-table-internal 'bracket-type)
511 ;; Latin
513 (modify-category-entry '(#x80 . #x024F) ?l)
515 (let ((tbl (standard-case-table)) c)
517 ;; Latin-1
519 ;; Fixme: Some of the non-word syntaxes here perhaps should be
520 ;; reviewed. (Note that the following all implicitly have word
521 ;; syntax: ¢£¤¥¨ª¯²³´¶¸¹º.) There should be a well-defined way of
522 ;; relating Unicode categories to Emacs syntax codes.
524 ;; NBSP isn't semantically interchangeable with other whitespace chars,
525 ;; so it's more like punctuation.
526 (set-case-syntax"." tbl)
527 (set-case-syntax"." tbl)
528 (set-case-syntax"_" tbl)
529 (set-case-syntax"." tbl)
530 (set-case-syntax"_" tbl)
531 ;; French wants
532 ;; (set-case-syntax-delims ?« ?» tbl)
533 ;; And German wants
534 ;; (set-case-syntax-delims ?» ?« tbl)
535 ;; So let's stay neutral and let users set these up if/when they want to.
536 (set-case-syntax"." tbl)
537 (set-case-syntax"." tbl)
538 (set-case-syntax"_" tbl)
539 (set-case-syntax"_" tbl)
540 (set-case-syntax"_" tbl)
541 (set-case-syntax"_" tbl)
542 (set-case-syntax"_" tbl)
543 (set-case-syntax"_" tbl)
544 (set-case-syntax"_" tbl)
545 (set-case-syntax"_" tbl)
546 (set-case-syntax"_" tbl)
547 (set-case-syntax"_" tbl)
548 (set-case-syntax ?¿ "." tbl)
549 (set-case-syntax"_" tbl)
550 (set-case-syntax"w" tbl)
551 (set-case-syntax"_" tbl)
552 ;; See below for ÿ.
554 ;; Latin Extended-A, Latin Extended-B
555 (setq c #x0100)
556 (while (<= c #x02B8)
557 (modify-category-entry c ?l)
558 (setq c (1+ c)))
560 ;; Latin Extended Additional
561 (modify-category-entry '(#x1e00 . #x1ef9) ?l)
563 ;; Latin Extended-C
564 (setq c #x2C60)
565 (while (<= c #x2C7F)
566 (modify-category-entry c ?l)
567 (setq c (1+ c)))
569 ;; Latin Extended-D
570 (setq c #xA720)
571 (while (<= c #xA7FF)
572 (modify-category-entry c ?l)
573 (setq c (1+ c)))
575 ;; Latin Extended-E
576 (setq c #xAB30)
577 (while (<= c #xAB64)
578 (modify-category-entry c ?l)
579 (setq c (1+ c)))
581 ;; Greek
582 (modify-category-entry '(#x0370 . #x03ff) ?g)
584 ;; Armenian
585 (setq c #x531)
587 ;; Greek Extended
588 (modify-category-entry '(#x1f00 . #x1fff) ?g)
590 ;; cyrillic
591 (modify-category-entry '(#x0400 . #x04FF) ?y)
592 (modify-category-entry '(#xA640 . #xA69F) ?y)
594 ;; Georgian
595 (setq c #x10A0)
597 ;; Cyrillic Extended-C
598 (modify-category-entry '(#x1C80 . #x1C8F) ?y)
600 ;; general punctuation
601 (setq c #x2000)
602 (while (<= c #x200b)
603 (set-case-syntax c " " tbl)
604 (setq c (1+ c)))
605 (while (<= c #x200F)
606 (set-case-syntax c "." tbl)
607 (setq c (1+ c)))
608 ;; Fixme: These aren't all right:
609 (setq c #x2010)
610 (while (<= c #x2016)
611 (set-case-syntax c "_" tbl)
612 (setq c (1+ c)))
613 ;; Punctuation syntax for quotation marks (like `)
614 (while (<= c #x201f)
615 (set-case-syntax c "." tbl)
616 (setq c (1+ c)))
617 ;; Fixme: These aren't all right:
618 (while (<= c #x2027)
619 (set-case-syntax c "_" tbl)
620 (setq c (1+ c)))
621 (while (<= c #x206F)
622 (set-case-syntax c "." tbl)
623 (setq c (1+ c)))
625 ;; Fixme: The following blocks might be better as symbol rather than
626 ;; punctuation.
627 ;; Arrows
628 (setq c #x2190)
629 (while (<= c #x21FF)
630 (set-case-syntax c "." tbl)
631 (setq c (1+ c)))
632 ;; Mathematical Operators
633 (while (<= c #x22FF)
634 (set-case-syntax c "." tbl)
635 (setq c (1+ c)))
636 ;; Miscellaneous Technical
637 (while (<= c #x23FF)
638 (set-case-syntax c "." tbl)
639 (setq c (1+ c)))
640 ;; Control Pictures
641 (while (<= c #x243F)
642 (set-case-syntax c "_" tbl)
643 (setq c (1+ c)))
645 ;; Circled Latin
646 (setq c #x24b6)
647 (while (<= c #x24cf)
648 (modify-category-entry c ?l)
649 (modify-category-entry (+ c 26) ?l)
650 (setq c (1+ c)))
652 ;; Coptic
653 ;; There's no Coptic category. However, Coptic letters that are
654 ;; part of the Greek block above get the Greek category, and those
655 ;; in this block are derived from Greek letters, so let's be
656 ;; consistent about their category.
657 (modify-category-entry '(#x2C80 . #x2CFF) ?g)
659 ;; Fullwidth Latin
660 (setq c #xff21)
661 (while (<= c #xff3a)
662 (modify-category-entry c ?l)
663 (modify-category-entry (+ c #x20) ?l)
664 (setq c (1+ c)))
666 ;; Combining diacritics
667 (modify-category-entry '(#x300 . #x362) ?^)
668 ;; Combining marks
669 (modify-category-entry '(#x20d0 . #x20ff) ?^)
671 (let ((gc (unicode-property-table-internal 'general-category))
672 (syn-table (standard-syntax-table)))
673 ;; In early bootstrapping Unicode tables are not available so we need to
674 ;; skip this step in those cases.
675 (when gc
676 ;; Set all Letter, uppercase; Letter, lowercase and Letter,
677 ;; titlecase syntax to word.
678 (map-char-table
679 (lambda (ch cat)
680 (when (memq cat '(Lu Ll Lt))
681 (modify-syntax-entry ch "w " syn-table)))
683 ;; Ⅰ through Ⅻ had word syntax in the past so set it here as well.
684 ;; The general category of those characters is Number, Letter.
685 (modify-syntax-entry '(#x2160 . #x216b) "w " syn-table)
687 ;; ⓐ through ⓩ are symbols, other according to Unicode but Emacs set
688 ;; their syntax to word in the past so keep backwards compatibility.
689 (modify-syntax-entry '(#x24D0 . #x24E9) "w " syn-table)
691 ;; Set downcase and upcase from Unicode properties
693 ;; In some languages, such as Turkish, U+0049 LATIN CAPITAL LETTER I and
694 ;; U+0131 LATIN SMALL LETTER DOTLESS I make a case pair, and so do U+0130
695 ;; LATIN CAPITAL LETTER I WITH DOT ABOVE and U+0069 LATIN SMALL LETTER I.
697 ;; We used to set up half of those correspondence unconditionally, but
698 ;; that makes searches slow. So now we don't set up either half of these
699 ;; correspondences by default.
701 ;; (set-downcase-syntax ?İ ?i tbl)
702 ;; (set-upcase-syntax ?I ?ı tbl)
704 (let ((map-unicode-property
705 (lambda (property func)
706 (map-char-table
707 (lambda (ch cased)
708 ;; ASCII characters skipped due to reasons outlined above. As
709 ;; of Unicode 9.0, this exception affects the following:
710 ;; lc(U+0130 İ) = i
711 ;; uc(U+0131 ı) = I
712 ;; uc(U+017F ſ) = S
713 ;; uc(U+212A K) = k
714 (when (> cased 127)
715 (let ((end (if (consp ch) (cdr ch) ch)))
716 (setq ch (max 128 (if (consp ch) (car ch) ch)))
717 (while (<= ch end)
718 (funcall func ch cased)
719 (setq ch (1+ ch))))))
720 (unicode-property-table-internal property))))
721 (down tbl)
722 (up (case-table-get-table tbl 'up)))
724 ;; This works on an assumption that if toUpper(x) != x then toLower(x)
725 ;; == x (and the opposite for toLower/toUpper). This doesn’t hold for
726 ;; title case characters but those incorrect mappings will be
727 ;; overwritten later.
728 (funcall map-unicode-property 'uppercase
729 (lambda (lc uc) (aset down lc lc) (aset up uc uc)))
730 (funcall map-unicode-property 'lowercase
731 (lambda (uc lc) (aset down lc lc) (aset up uc uc)))
733 ;; Now deal with the actual mapping. This will correctly assign casing
734 ;; for title-case characters.
735 (funcall map-unicode-property 'uppercase
736 (lambda (lc uc) (aset up lc uc) (aset up uc uc)))
737 (funcall map-unicode-property 'lowercase
738 (lambda (uc lc) (aset down uc lc) (aset down lc lc))))))
740 ;; Clear out the extra slots so that they will be recomputed from the main
741 ;; (downcase) table and upcase table. Since we’re side-stepping the usual
742 ;; set-case-syntax-* functions, we need to do it explicitly.
743 (set-char-table-extra-slot tbl 1 nil)
744 (set-char-table-extra-slot tbl 2 nil)
746 ;; Fixme: syntax for symbols &c
749 (let ((pairs
750 '("⁅⁆" ; U+2045 U+2046
751 "⁽⁾" ; U+207D U+207E
752 "₍₎" ; U+208D U+208E
753 "〈〉" ; U+2329 U+232A
754 "⎴⎵" ; U+23B4 U+23B5
755 "❨❩" ; U+2768 U+2769
756 "❪❫" ; U+276A U+276B
757 "❬❭" ; U+276C U+276D
758 "❰❱" ; U+2770 U+2771
759 "❲❳" ; U+2772 U+2773
760 "❴❵" ; U+2774 U+2775
761 "⟦⟧" ; U+27E6 U+27E7
762 "⟨⟩" ; U+27E8 U+27E9
763 "⟪⟫" ; U+27EA U+27EB
764 "⦃⦄" ; U+2983 U+2984
765 "⦅⦆" ; U+2985 U+2986
766 "⦇⦈" ; U+2987 U+2988
767 "⦉⦊" ; U+2989 U+298A
768 "⦋⦌" ; U+298B U+298C
769 "⦍⦎" ; U+298D U+298E
770 "⦏⦐" ; U+298F U+2990
771 "⦑⦒" ; U+2991 U+2992
772 "⦓⦔" ; U+2993 U+2994
773 "⦕⦖" ; U+2995 U+2996
774 "⦗⦘" ; U+2997 U+2998
775 "⧼⧽" ; U+29FC U+29FD
776 "〈〉" ; U+3008 U+3009
777 "《》" ; U+300A U+300B
778 "「」" ; U+300C U+300D
779 "『』" ; U+300E U+300F
780 "【】" ; U+3010 U+3011
781 "〔〕" ; U+3014 U+3015
782 "〖〗" ; U+3016 U+3017
783 "〘〙" ; U+3018 U+3019
784 "〚〛" ; U+301A U+301B
785 "﴾﴿" ; U+FD3E U+FD3F
786 "︵︶" ; U+FE35 U+FE36
787 "︷︸" ; U+FE37 U+FE38
788 "︹︺" ; U+FE39 U+FE3A
789 "︻︼" ; U+FE3B U+FE3C
790 "︽︾" ; U+FE3D U+FE3E
791 "︿﹀" ; U+FE3F U+FE40
792 "﹁﹂" ; U+FE41 U+FE42
793 "﹃﹄" ; U+FE43 U+FE44
794 "﹙﹚" ; U+FE59 U+FE5A
795 "﹛﹜" ; U+FE5B U+FE5C
796 "﹝﹞" ; U+FE5D U+FE5E
797 "()" ; U+FF08 U+FF09
798 "[]" ; U+FF3B U+FF3D
799 "{}" ; U+FF5B U+FF5D
800 "⦅⦆" ; U+FF5F U+FF60
801 "「」" ; U+FF62 U+FF63
803 (dolist (elt pairs)
804 (modify-syntax-entry (aref elt 0) (string ?\( (aref elt 1)))
805 (modify-syntax-entry (aref elt 1) (string ?\) (aref elt 0)))))
808 ;; For each character set, put the information of the most proper
809 ;; coding system to encode it by `preferred-coding-system' property.
811 ;; Fixme: should this be junked?
812 (let ((l '((latin-iso8859-1 . iso-latin-1)
813 (latin-iso8859-2 . iso-latin-2)
814 (latin-iso8859-3 . iso-latin-3)
815 (latin-iso8859-4 . iso-latin-4)
816 (thai-tis620 . thai-tis620)
817 (greek-iso8859-7 . greek-iso-8bit)
818 (arabic-iso8859-6 . iso-2022-7bit)
819 (hebrew-iso8859-8 . hebrew-iso-8bit)
820 (katakana-jisx0201 . japanese-shift-jis)
821 (latin-jisx0201 . japanese-shift-jis)
822 (cyrillic-iso8859-5 . cyrillic-iso-8bit)
823 (latin-iso8859-9 . iso-latin-5)
824 (japanese-jisx0208-1978 . iso-2022-jp)
825 (chinese-gb2312 . chinese-iso-8bit)
826 (chinese-gbk . chinese-gbk)
827 (gb18030-2-byte . chinese-gb18030)
828 (gb18030-4-byte-bmp . chinese-gb18030)
829 (gb18030-4-byte-smp . chinese-gb18030)
830 (gb18030-4-byte-ext-1 . chinese-gb18030)
831 (gb18030-4-byte-ext-2 . chinese-gb18030)
832 (japanese-jisx0208 . iso-2022-jp)
833 (korean-ksc5601 . iso-2022-kr)
834 (japanese-jisx0212 . iso-2022-jp)
835 (chinese-big5-1 . chinese-big5)
836 (chinese-big5-2 . chinese-big5)
837 (chinese-sisheng . iso-2022-7bit)
838 (ipa . iso-2022-7bit)
839 (vietnamese-viscii-lower . vietnamese-viscii)
840 (vietnamese-viscii-upper . vietnamese-viscii)
841 (arabic-digit . iso-2022-7bit)
842 (arabic-1-column . iso-2022-7bit)
843 (lao . lao)
844 (arabic-2-column . iso-2022-7bit)
845 (indian-is13194 . devanagari)
846 (indian-glyph . devanagari)
847 (tibetan-1-column . tibetan)
848 (ethiopic . iso-2022-7bit)
849 (chinese-cns11643-1 . iso-2022-cn)
850 (chinese-cns11643-2 . iso-2022-cn)
851 (chinese-cns11643-3 . iso-2022-cn)
852 (chinese-cns11643-4 . iso-2022-cn)
853 (chinese-cns11643-5 . iso-2022-cn)
854 (chinese-cns11643-6 . iso-2022-cn)
855 (chinese-cns11643-7 . iso-2022-cn)
856 (indian-2-column . devanagari)
857 (tibetan . tibetan)
858 (latin-iso8859-14 . iso-latin-8)
859 (latin-iso8859-15 . iso-latin-9))))
860 (while l
861 (put-charset-property (car (car l)) 'preferred-coding-system (cdr (car l)))
862 (setq l (cdr l))))
865 ;; Setup auto-fill-chars for charsets that should invoke auto-filling.
866 ;; SPACE and NEWLINE are already set.
868 (set-char-table-range auto-fill-chars '(#x3041 . #x30FF) t)
869 (set-char-table-range auto-fill-chars '(#x3400 . #x4DB5) t)
870 (set-char-table-range auto-fill-chars '(#x4e00 . #x9fbb) t)
871 (set-char-table-range auto-fill-chars '(#xF900 . #xFAFF) t)
872 (set-char-table-range auto-fill-chars '(#xFF00 . #xFF9F) t)
873 (set-char-table-range auto-fill-chars '(#x20000 . #x2FFFF) t)
876 ;;; Setting char-width-table. The default is 1.
878 ;; 0: non-spacing, enclosing combining, formatting, Hangul Jamo medial
879 ;; and final characters.
880 (let ((l '((#x0300 . #x036F)
881 (#x0483 . #x0489)
882 (#x0591 . #x05BD)
883 (#x05BF . #x05BF)
884 (#x05C1 . #x05C2)
885 (#x05C4 . #x05C5)
886 (#x05C7 . #x05C7)
887 (#x0600 . #x0605)
888 (#x0610 . #x061C)
889 (#x064B . #x065F)
890 (#x0670 . #x0670)
891 (#x06D6 . #x06E4)
892 (#x06E7 . #x06E8)
893 (#x06EA . #x06ED)
894 (#x070F . #x070F)
895 (#x0711 . #x0711)
896 (#x0730 . #x074A)
897 (#x07A6 . #x07B0)
898 (#x07EB . #x07F3)
899 (#x0816 . #x0823)
900 (#x0825 . #x082D)
901 (#x0859 . #x085B)
902 (#x08D4 . #x0902)
903 (#x093A . #x093A)
904 (#x093C . #x093C)
905 (#x0941 . #x0948)
906 (#x094D . #x094D)
907 (#x0951 . #x0957)
908 (#x0962 . #x0963)
909 (#x0981 . #x0981)
910 (#x09BC . #x09BC)
911 (#x09C1 . #x09C4)
912 (#x09CD . #x09CD)
913 (#x09E2 . #x09E3)
914 (#x0A01 . #x0A02)
915 (#x0A3C . #x0A3C)
916 (#x0A41 . #x0A4D)
917 (#x0A41 . #x0A42)
918 (#x0A47 . #x0A48)
919 (#x0A4B . #x0A4D)
920 (#x0A51 . #x0A51)
921 (#x0A70 . #x0A71)
922 (#x0A75 . #x0A75)
923 (#x0A81 . #x0A82)
924 (#x0ABC . #x0ABC)
925 (#x0AC1 . #x0AC8)
926 (#x0ACD . #x0ACD)
927 (#x0AE2 . #x0AE3)
928 (#x0B01 . #x0B01)
929 (#x0B3C . #x0B3C)
930 (#x0B3F . #x0B3F)
931 (#x0B41 . #x0B44)
932 (#x0B4D . #x0B56)
933 (#x0B62 . #x0B63)
934 (#x0B82 . #x0B82)
935 (#x0BC0 . #x0BC0)
936 (#x0BCD . #x0BCD)
937 (#x0C00 . #x0C00)
938 (#x0C3E . #x0C40)
939 (#x0C46 . #x0C56)
940 (#x0C62 . #x0C63)
941 (#x0C81 . #x0C81)
942 (#x0CBC . #x0CBC)
943 (#x0CCC . #x0CCD)
944 (#x0CE2 . #x0CE3)
945 (#x0D01 . #x0D01)
946 (#x0D41 . #x0D44)
947 (#x0D4D . #x0D4D)
948 (#x0D62 . #x0D63)
949 (#x0DCA . #x0DCA)
950 (#x0DD2 . #x0DD6)
951 (#x0E31 . #x0E31)
952 (#x0E34 . #x0E3A)
953 (#x0E47 . #x0E4E)
954 (#x0EB1 . #x0EB1)
955 (#x0EB4 . #x0EBC)
956 (#x0EC8 . #x0ECD)
957 (#x0F18 . #x0F19)
958 (#x0F35 . #x0F35)
959 (#x0F37 . #x0F37)
960 (#x0F39 . #x0F39)
961 (#x0F71 . #x0F7E)
962 (#x0F80 . #x0F84)
963 (#x0F86 . #x0F87)
964 (#x0F8D . #x0FBC)
965 (#x0FC6 . #x0FC6)
966 (#x102D . #x1030)
967 (#x1032 . #x1037)
968 (#x1039 . #x103A)
969 (#x103D . #x103E)
970 (#x1058 . #x1059)
971 (#x105E . #x1160)
972 (#x1171 . #x1074)
973 (#x1082 . #x1082)
974 (#x1085 . #x1086)
975 (#x108D . #x108D)
976 (#x109D . #x109D)
977 (#x135D . #x135F)
978 (#x1712 . #x1714)
979 (#x1732 . #x1734)
980 (#x1752 . #x1753)
981 (#x1772 . #x1773)
982 (#x17B4 . #x17B5)
983 (#x17B7 . #x17BD)
984 (#x17C6 . #x17C6)
985 (#x17C9 . #x17D3)
986 (#x17DD . #x17DD)
987 (#x180B . #x180E)
988 (#x18A9 . #x18A9)
989 (#x1885 . #x1886)
990 (#x18A9 . #x18A9)
991 (#x1920 . #x1922)
992 (#x1927 . #x1928)
993 (#x1932 . #x1932)
994 (#x1939 . #x193B)
995 (#x1A17 . #x1A18)
996 (#x1A1B . #x1A1B)
997 (#x1A56 . #x1A56)
998 (#x1A58 . #x1A5E)
999 (#x1A60 . #x1A60)
1000 (#x1A62 . #x1A62)
1001 (#x1A65 . #x1A6C)
1002 (#x1A73 . #x1A7C)
1003 (#x1A7F . #x1A7F)
1004 (#x1AB0 . #x1ABE)
1005 (#x1B00 . #x1B03)
1006 (#x1B34 . #x1B34)
1007 (#x1B36 . #x1B3A)
1008 (#x1B3C . #x1B3C)
1009 (#x1B42 . #x1B42)
1010 (#x1B6B . #x1B73)
1011 (#x1B80 . #x1B81)
1012 (#x1BA2 . #x1BA5)
1013 (#x1BA8 . #x1BA9)
1014 (#x1BAB . #x1BAD)
1015 (#x1BE6 . #x1BE6)
1016 (#x1BE8 . #x1BE9)
1017 (#x1BED . #x1BED)
1018 (#x1BEF . #x1BF1)
1019 (#x1C2C . #x1C33)
1020 (#x1C36 . #x1C37)
1021 (#x1CD0 . #x1CD2)
1022 (#x1CD4 . #x1CE0)
1023 (#x1CE2 . #x1CE8)
1024 (#x1CED . #x1CED)
1025 (#x1CF4 . #x1CF4)
1026 (#x1CF8 . #x1CF9)
1027 (#x1DC0 . #x1DFF)
1028 (#x200B . #x200F)
1029 (#x202A . #x202E)
1030 (#x2060 . #x206F)
1031 (#x20D0 . #x20F0)
1032 (#x2CEF . #x2CF1)
1033 (#x2D7F . #x2D7F)
1034 (#x2DE0 . #x2DFF)
1035 (#xA66F . #xA672)
1036 (#xA674 . #xA69F)
1037 (#xA6F0 . #xA6F1)
1038 (#xA802 . #xA802)
1039 (#xA806 . #xA806)
1040 (#xA80B . #xA80B)
1041 (#xA825 . #xA826)
1042 (#xA8C4 . #xA8C5)
1043 (#xA8E0 . #xA8F1)
1044 (#xA926 . #xA92D)
1045 (#xA947 . #xA951)
1046 (#xA980 . #xA9B3)
1047 (#xA9B6 . #xA9B9)
1048 (#xA9BC . #xA9BC)
1049 (#xA9E5 . #xA9E5)
1050 (#xAA29 . #xAA2E)
1051 (#xAA31 . #xAA32)
1052 (#xAA35 . #xAA36)
1053 (#xAA43 . #xAA43)
1054 (#xAA4C . #xAA4C)
1055 (#xAA7C . #xAA7C)
1056 (#xAAB0 . #xAAB0)
1057 (#xAAB2 . #xAAB4)
1058 (#xAAB7 . #xAAB8)
1059 (#xAABE . #xAABF)
1060 (#xAAC1 . #xAAC1)
1061 (#xAAEC . #xAAED)
1062 (#xAAF6 . #xAAF6)
1063 (#xABE5 . #xABE5)
1064 (#xABE8 . #xABE8)
1065 (#xABED . #xABED)
1066 (#xFB1E . #xFB1E)
1067 (#xFE00 . #xFE0F)
1068 (#xFE20 . #xFE2F)
1069 (#xFEFF . #xFEFF)
1070 (#xFFF9 . #xFFFB)
1071 (#x101FD . #x101FD)
1072 (#x102E0 . #x102E0)
1073 (#x10376 . #x1037A)
1074 (#x10A01 . #x10A0F)
1075 (#x10A38 . #x10A3F)
1076 (#x10AE5 . #x10AE6)
1077 (#x11001 . #x11001)
1078 (#x11038 . #x11046)
1079 (#x1107F . #x11081)
1080 (#x110B3 . #x110B6)
1081 (#x110B9 . #x110BA)
1082 (#x110BD . #x110BD)
1083 (#x11100 . #x11102)
1084 (#x11127 . #x1112B)
1085 (#x1112D . #x11134)
1086 (#x11173 . #x11173)
1087 (#x11180 . #x11181)
1088 (#x111B6 . #x111BE)
1089 (#x111CA . #x111CC)
1090 (#x1122F . #x11231)
1091 (#x11234 . #x11234)
1092 (#x11236 . #x11237)
1093 (#x1123E . #x1123E)
1094 (#x112DF . #x112DF)
1095 (#x112E3 . #x112EA)
1096 (#x11300 . #x11301)
1097 (#x1133C . #x1133C)
1098 (#x11340 . #x11340)
1099 (#x11366 . #x1136C)
1100 (#x11370 . #x11374)
1101 (#x11438 . #x1143F)
1102 (#x11442 . #x11444)
1103 (#x11446 . #x11446)
1104 (#x114B3 . #x114B8)
1105 (#x114BA . #x114C0)
1106 (#x114C2 . #x114C3)
1107 (#x115B2 . #x115B5)
1108 (#x115BC . #x115BD)
1109 (#x115BF . #x115C0)
1110 (#x115DC . #x115DD)
1111 (#x11633 . #x1163A)
1112 (#x1163D . #x1163D)
1113 (#x1163F . #x11640)
1114 (#x116AB . #x116AB)
1115 (#x116AD . #x116AD)
1116 (#x116B0 . #x116B5)
1117 (#x116B7 . #x116B7)
1118 (#x1171D . #x1171F)
1119 (#x11722 . #x11725)
1120 (#x11727 . #x1172B)
1121 (#x11C30 . #x11C36)
1122 (#x11C38 . #x11C3D)
1123 (#x11C92 . #x11CA7)
1124 (#x11CAA . #x11CB0)
1125 (#x11CB2 . #x11CB3)
1126 (#x11CB5 . #x11CB6)
1127 (#x16AF0 . #x16AF4)
1128 (#x16B30 . #x16B36)
1129 (#x16F8F . #x16F92)
1130 (#x1BC9D . #x1BC9E)
1131 (#x1BCA0 . #x1BCA3)
1132 (#x1D167 . #x1D169)
1133 (#x1D173 . #x1D182)
1134 (#x1D185 . #x1D18B)
1135 (#x1D1AA . #x1D1AD)
1136 (#x1D242 . #x1D244)
1137 (#x1DA00 . #x1DA36)
1138 (#x1DA3B . #x1DA6C)
1139 (#x1DA75 . #x1DA75)
1140 (#x1DA84 . #x1DA84)
1141 (#x1DA9B . #x1DA9F)
1142 (#x1DAA1 . #x1DAAF)
1143 (#x1E000 . #x1E006)
1144 (#x1E008 . #x1E018)
1145 (#x1E01B . #x1E021)
1146 (#x1E023 . #x1E024)
1147 (#x1E026 . #x1E02A)
1148 (#x1E8D0 . #x1E8D6)
1149 (#x1E944 . #x1E94A)
1150 (#xE0001 . #xE01EF))))
1151 (dolist (elt l)
1152 (set-char-table-range char-width-table elt 0)))
1154 ;; 2: East Asian Wide and Full-width characters.
1155 (let ((l '((#x1100 . #x115F)
1156 (#x231A . #x231B)
1157 (#x2329 . #x232A)
1158 (#x23E9 . #x23EC)
1159 (#x23F0 . #x23F0)
1160 (#x23F3 . #x23F3)
1161 (#x25FD . #x25FE)
1162 (#x2614 . #x2615)
1163 (#x2648 . #x2653)
1164 (#x267F . #x267F)
1165 (#x2693 . #x2693)
1166 (#x26A1 . #x26A1)
1167 (#x26AA . #x26AB)
1168 (#x26BD . #x26BE)
1169 (#x26C4 . #x26C5)
1170 (#x26CE . #x26CE)
1171 (#x26D4 . #x26D4)
1172 (#x26EA . #x26EA)
1173 (#x26F2 . #x26F3)
1174 (#x26F5 . #x26F5)
1175 (#x26FA . #x26FA)
1176 (#x26FD . #x26FD)
1177 (#x2705 . #x2705)
1178 (#x270A . #x270B)
1179 (#x2728 . #x2728)
1180 (#x274C . #x274C)
1181 (#x274E . #x274E)
1182 (#x2753 . #x2755)
1183 (#x2757 . #x2757)
1184 (#x2795 . #x2797)
1185 (#x27B0 . #x27B0)
1186 (#x27BF . #x27BF)
1187 (#x2B1B . #x2B1C)
1188 (#x2B50 . #x2B50)
1189 (#x2B55 . #x2B55)
1190 (#x2E80 . #x303E)
1191 (#x3040 . #x3247)
1192 (#x3250 . #x4DBF)
1193 (#x4E00 . #xA4CF)
1194 (#xA490 . #xA4C6)
1195 (#xA960 . #xA97F)
1196 (#xAC00 . #xD7A3)
1197 (#xF900 . #xFAFF)
1198 (#xFE10 . #xFE19)
1199 (#xFE30 . #xFE6F)
1200 (#xFF01 . #xFF60)
1201 (#xFFE0 . #xFFE6)
1202 (#x16FE0 . #x16FE1)
1203 (#x17000 . #x187EC)
1204 (#x18800 . #x18AF2)
1205 (#x1B000 . #x1B11E)
1206 (#x1B170 . #x1B2FB)
1207 (#x1F004 . #x1F004)
1208 (#x1F0CF . #x1F0CF)
1209 (#x1F18E . #x1F18E)
1210 (#x1F191 . #x1F19A)
1211 (#x1F200 . #x1F320)
1212 (#x1F32D . #x1F335)
1213 (#x1F337 . #x1F37C)
1214 (#x1F37E . #x1F393)
1215 (#x1F3A0 . #x1F3CA)
1216 (#x1F3CF . #x1F3D3)
1217 (#x1F3E0 . #x1F3F0)
1218 (#x1F3F4 . #x1F3F4)
1219 (#x1F3F8 . #x1F3FA)
1220 (#x1F3FB . #x1F3FF)
1221 (#x1F400 . #x1F43E)
1222 (#x1F440 . #x1F440)
1223 (#x1F442 . #x1F4FC)
1224 (#x1F4FF . #x1F53D)
1225 (#x1F54B . #x1F54E)
1226 (#x1F550 . #x1F567)
1227 (#x1F57A . #x1F57A)
1228 (#x1F595 . #x1F596)
1229 (#x1F5A4 . #x1F5A4)
1230 (#x1F5FB . #x1F5FF)
1231 (#x1F600 . #x1F64F)
1232 (#x1F680 . #x1F6C5)
1233 (#x1F6CC . #x1F6CC)
1234 (#x1F6D0 . #x1F6D2)
1235 (#x1F6EB . #x1F6EC)
1236 (#x1F6F4 . #x1F6F8)
1237 (#x1F910 . #x1F93E)
1238 (#x1F940 . #x1F94C)
1239 (#x1F950 . #x1F96B)
1240 (#x1F980 . #x1F997)
1241 (#x1F9C0 . #x1F9C0)
1242 (#x1F9D0 . #x1F9E6)
1243 (#x20000 . #x2FFFF)
1244 (#x30000 . #x3FFFF))))
1245 (dolist (elt l)
1246 (set-char-table-range char-width-table elt 2)))
1248 ;; Other double width
1249 ;;(map-charset-chars
1250 ;; (lambda (range ignore) (set-char-table-range char-width-table range 2))
1251 ;; 'ethiopic)
1252 ;; (map-charset-chars
1253 ;; (lambda (range ignore) (set-char-table-range char-width-table range 2))
1254 ;; 'tibetan)
1255 (map-charset-chars
1256 (lambda (range _ignore) (set-char-table-range char-width-table range 2))
1257 'indian-2-column)
1258 (map-charset-chars
1259 (lambda (range _ignore) (set-char-table-range char-width-table range 2))
1260 'arabic-2-column)
1262 ;; Internal use only.
1263 ;; Alist of locale symbol vs charsets. In a language environment
1264 ;; corresponding to the locale, width of characters in the charsets is
1265 ;; set to 2. Each element has the form:
1266 ;; (LOCALE TABLE (CHARSET (FROM-CODE . TO-CODE) ...) ...)
1267 ;; LOCALE: locale symbol
1268 ;; TABLE: char-table used for char-width-table, initially nil.
1269 ;; CHARSET: character set
1270 ;; FROM-CODE, TO-CODE: range of code-points in CHARSET
1272 (defvar cjk-char-width-table-list
1273 '((ja_JP nil (japanese-jisx0208 (#x2121 . #x287E))
1274 (cp932-2-byte (#x8140 . #x879F)))
1275 (zh_CN nil (chinese-gb2312 (#x2121 . #x297E)))
1276 (zh_HK nil (big5-hkscs (#xA140 . #xA3FE) (#xC6A0 . #xC8FE)))
1277 (zh_TW nil (big5 (#xA140 . #xA3FE))
1278 (chinese-cns11643-1 (#x2121 . #x427E)))
1279 (ko_KR nil (korean-ksc5601 (#x2121 . #x2C7E)))))
1281 ;; Internal use only.
1282 ;; Setup char-width-table appropriate for a language environment
1283 ;; corresponding to LOCALE-NAME (symbol).
1285 (defun use-cjk-char-width-table (locale-name)
1286 (while (char-table-parent char-width-table)
1287 (setq char-width-table (char-table-parent char-width-table)))
1288 (let ((slot (assq locale-name cjk-char-width-table-list)))
1289 (or slot (error "Unknown locale for CJK language environment: %s"
1290 locale-name))
1291 (unless (nth 1 slot)
1292 (let ((table (make-char-table nil)))
1293 (dolist (charset-info (nthcdr 2 slot))
1294 (let ((charset (car charset-info)))
1295 (dolist (code-range (cdr charset-info))
1296 (map-charset-chars #'(lambda (range _arg)
1297 (set-char-table-range table range 2))
1298 charset nil
1299 (car code-range) (cdr code-range)))))
1300 (optimize-char-table table)
1301 (set-char-table-parent table char-width-table)
1302 (setcar (cdr slot) table)))
1303 (setq char-width-table (nth 1 slot))))
1305 (defun use-default-char-width-table ()
1306 "Internal use only.
1307 Setup char-width-table appropriate for non-CJK language environment."
1308 (while (char-table-parent char-width-table)
1309 (setq char-width-table (char-table-parent char-width-table))))
1311 (optimize-char-table (standard-case-table))
1312 (optimize-char-table (standard-syntax-table))
1315 ;; Setting char-script-table.
1316 (if purify-flag
1317 ;; While dumping, we can't use require, and international is not
1318 ;; in load-path.
1319 (load "international/charscript")
1320 (require 'charscript))
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 (when (setq unicode-category-table
1331 (unicode-property-table-internal 'general-category))
1332 (map-char-table #'(lambda (key val)
1333 (if val
1334 (cond ((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 ((eq val 'Mn)
1339 (modify-category-entry key ?^)))))
1340 unicode-category-table))
1342 (optimize-char-table (standard-category-table))
1345 ;; Display of glyphless characters.
1347 (defvar char-acronym-table
1348 (make-char-table 'char-acronym-table nil)
1349 "Char table of acronyms for non-graphic characters.")
1351 (let ((c0-acronyms '("NUL" "SOH" "STX" "ETX" "EOT" "ENQ" "ACK" "BEL"
1352 "BS" nil nil "VT" "FF" "CR" "SO" "SI"
1353 "DLE" "DC1" "DC2" "DC3" "DC4" "NAK" "SYN" "ETB"
1354 "CAN" "EM" "SUB" "ESC" "FC" "GS" "RS" "US")))
1355 (dotimes (i 32)
1356 (aset char-acronym-table i (car c0-acronyms))
1357 (setq c0-acronyms (cdr c0-acronyms))))
1359 (let ((c1-acronyms '("PAD" "HOP" "BPH" "NBH" "IND" "NEL" "SSA" "ESA"
1360 "HTS" "HTJ" "VTS" "PLD" "PLU" "R1" "SS2" "SS1"
1361 "DCS" "PU1" "PU2" "STS" "CCH" "MW" "SPA" "EPA"
1362 "SOS" "SGCI" "SC1" "CSI" "ST" "OSC" "PM" "APC")))
1363 (dotimes (i 32)
1364 (aset char-acronym-table (+ #x0080 i) (car c1-acronyms))
1365 (setq c1-acronyms (cdr c1-acronyms))))
1367 (aset char-acronym-table #x17B4 "KIVAQ") ; KHMER VOWEL INHERENT AQ
1368 (aset char-acronym-table #x17B5 "KIVAA") ; KHMER VOWEL INHERENT AA
1369 (aset char-acronym-table #x200B "ZWSP") ; ZERO WIDTH SPACE
1370 (aset char-acronym-table #x200C "ZWNJ") ; ZERO WIDTH NON-JOINER
1371 (aset char-acronym-table #x200D "ZWJ") ; ZERO WIDTH JOINER
1372 (aset char-acronym-table #x200E "LRM") ; LEFT-TO-RIGHT MARK
1373 (aset char-acronym-table #x200F "RLM") ; RIGHT-TO-LEFT MARK
1374 (aset char-acronym-table #x202A "LRE") ; LEFT-TO-RIGHT EMBEDDING
1375 (aset char-acronym-table #x202B "RLE") ; RIGHT-TO-LEFT EMBEDDING
1376 (aset char-acronym-table #x202C "PDF") ; POP DIRECTIONAL FORMATTING
1377 (aset char-acronym-table #x202D "LRO") ; LEFT-TO-RIGHT OVERRIDE
1378 (aset char-acronym-table #x202E "RLO") ; RIGHT-TO-LEFT OVERRIDE
1379 (aset char-acronym-table #x2060 "WJ") ; WORD JOINER
1380 (aset char-acronym-table #x206A "ISS") ; INHIBIT SYMMETRIC SWAPPING
1381 (aset char-acronym-table #x206B "ASS") ; ACTIVATE SYMMETRIC SWAPPING
1382 (aset char-acronym-table #x206C "IAFS") ; INHIBIT ARABIC FORM SHAPING
1383 (aset char-acronym-table #x206D "AAFS") ; ACTIVATE ARABIC FORM SHAPING
1384 (aset char-acronym-table #x206E "NADS") ; NATIONAL DIGIT SHAPES
1385 (aset char-acronym-table #x206F "NODS") ; NOMINAL DIGIT SHAPES
1386 (aset char-acronym-table #xFEFF "ZWNBSP") ; ZERO WIDTH NO-BREAK SPACE
1387 (aset char-acronym-table #xFFF9 "IAA") ; INTERLINEAR ANNOTATION ANCHOR
1388 (aset char-acronym-table #xFFFA "IAS") ; INTERLINEAR ANNOTATION SEPARATOR
1389 (aset char-acronym-table #xFFFB "IAT") ; INTERLINEAR ANNOTATION TERMINATOR
1390 (aset char-acronym-table #x1D173 "BEGBM") ; MUSICAL SYMBOL BEGIN BEAM
1391 (aset char-acronym-table #x1D174 "ENDBM") ; MUSICAL SYMBOL END BEAM
1392 (aset char-acronym-table #x1D175 "BEGTIE") ; MUSICAL SYMBOL BEGIN TIE
1393 (aset char-acronym-table #x1D176 "END") ; MUSICAL SYMBOL END TIE
1394 (aset char-acronym-table #x1D177 "BEGSLR") ; MUSICAL SYMBOL BEGIN SLUR
1395 (aset char-acronym-table #x1D178 "ENDSLR") ; MUSICAL SYMBOL END SLUR
1396 (aset char-acronym-table #x1D179 "BEGPHR") ; MUSICAL SYMBOL BEGIN PHRASE
1397 (aset char-acronym-table #x1D17A "ENDPHR") ; MUSICAL SYMBOL END PHRASE
1398 (aset char-acronym-table #xE0001 "|->TAG") ; LANGUAGE TAG
1399 (aset char-acronym-table #xE0020 "SP TAG") ; TAG SPACE
1400 (dotimes (i 94)
1401 (aset char-acronym-table (+ #xE0021 i) (format " %c TAG" (+ 33 i))))
1402 (aset char-acronym-table #xE007F "->|TAG") ; CANCEL TAG
1404 (defun update-glyphless-char-display (&optional variable value)
1405 "Make the setting of `glyphless-char-display-control' take effect.
1406 This function updates the char-table `glyphless-char-display'."
1407 (when value
1408 (set-default variable value))
1409 (dolist (elt value)
1410 (let ((target (car elt))
1411 (method (cdr elt)))
1412 (or (memq method '(zero-width thin-space empty-box acronym hex-code))
1413 (error "Invalid glyphless character display method: %s" method))
1414 (cond ((eq target 'c0-control)
1415 (glyphless-set-char-table-range glyphless-char-display
1416 #x00 #x1F method)
1417 ;; Users will not expect their newlines and TABs be
1418 ;; displayed as anything but themselves, so exempt those
1419 ;; two characters from c0-control.
1420 (set-char-table-range glyphless-char-display #x9 nil)
1421 (set-char-table-range glyphless-char-display #xa nil))
1422 ((eq target 'c1-control)
1423 (glyphless-set-char-table-range glyphless-char-display
1424 #x80 #x9F method))
1425 ((eq target 'format-control)
1426 (when unicode-category-table
1427 (map-char-table
1428 #'(lambda (char category)
1429 (if (eq category 'Cf)
1430 (let ((this-method method)
1431 from to)
1432 (if (consp char)
1433 (setq from (car char) to (cdr char))
1434 (setq from char to char))
1435 (while (<= from to)
1436 (when (/= from #xAD)
1437 (if (eq method 'acronym)
1438 (setq this-method
1439 (aref char-acronym-table from)))
1440 (set-char-table-range glyphless-char-display
1441 from this-method))
1442 (setq from (1+ from))))))
1443 unicode-category-table)))
1444 ((eq target 'no-font)
1445 (set-char-table-extra-slot glyphless-char-display 0 method))
1447 (error "Invalid glyphless character group: %s" target))))))
1449 (defun glyphless-set-char-table-range (chartable from to method)
1450 (if (eq method 'acronym)
1451 (let ((i from))
1452 (while (<= i to)
1453 (set-char-table-range chartable i (aref char-acronym-table i))
1454 (setq i (1+ i))))
1455 (set-char-table-range chartable (cons from to) method)))
1457 ;;; Control of displaying glyphless characters.
1458 (defcustom glyphless-char-display-control
1459 '((format-control . thin-space)
1460 (no-font . hex-code))
1461 "List of directives to control display of glyphless characters.
1463 Each element has the form (GROUP . METHOD), where GROUP is a
1464 symbol specifying the character group, and METHOD is a symbol
1465 specifying the method of displaying characters belonging to that
1466 group.
1468 GROUP must be one of these symbols:
1469 `c0-control': U+0000..U+001F, but excluding newline and TAB.
1470 `c1-control': U+0080..U+009F.
1471 `format-control': Characters of Unicode General Category `Cf',
1472 such as U+200C (ZWNJ), U+200E (LRM), but
1473 excluding characters that have graphic images,
1474 such as U+00AD (SHY).
1475 `no-font': characters for which no suitable font is found.
1476 For character terminals, characters that cannot
1477 be encoded by `terminal-coding-system'.
1479 METHOD must be one of these symbols:
1480 `zero-width': don't display.
1481 `thin-space': display a thin (1-pixel width) space. On character
1482 terminals, display as 1-character space.
1483 `empty-box': display an empty box.
1484 `acronym': display an acronym of the character in a box. The
1485 acronym is taken from `char-acronym-table', which see.
1486 `hex-code': display the hexadecimal character code in a box.
1488 Do not set its value directly from Lisp; the value takes effect
1489 only via a custom `:set'
1490 function (`update-glyphless-char-display'), which updates
1491 `glyphless-char-display'."
1492 :version "24.1"
1493 :type '(alist :key-type (symbol :tag "Character Group")
1494 :value-type (symbol :tag "Display Method"))
1495 :options '((c0-control
1496 (choice (const :tag "Don't display" zero-width)
1497 (const :tag "Display as thin space" thin-space)
1498 (const :tag "Display as empty box" empty-box)
1499 (const :tag "Display acronym" acronym)
1500 (const :tag "Display hex code in a box" hex-code)))
1501 (c1-control
1502 (choice (const :tag "Don't display" zero-width)
1503 (const :tag "Display as thin space" thin-space)
1504 (const :tag "Display as empty box" empty-box)
1505 (const :tag "Display acronym" acronym)
1506 (const :tag "Display hex code in a box" hex-code)))
1507 (format-control
1508 (choice (const :tag "Don't display" zero-width)
1509 (const :tag "Display as thin space" thin-space)
1510 (const :tag "Display as empty box" empty-box)
1511 (const :tag "Display acronym" acronym)
1512 (const :tag "Display hex code in a box" hex-code)))
1513 (no-font
1514 (choice (const :tag "Don't display" zero-width)
1515 (const :tag "Display as thin space" thin-space)
1516 (const :tag "Display as empty box" empty-box)
1517 (const :tag "Display acronym" acronym)
1518 (const :tag "Display hex code in a box" hex-code))))
1519 :set 'update-glyphless-char-display
1520 :group 'display)
1523 ;;; Setting word boundary.
1525 (setq word-combining-categories
1526 '((nil . ?^)
1527 (?^ . nil)
1528 (?C . ?H)
1529 (?C . ?K)))
1531 (setq word-separating-categories ; (2-byte character sets)
1532 '((?H . ?K) ; Hiragana - Katakana
1535 ;; Local Variables:
1536 ;; coding: utf-8
1537 ;; End:
1539 ;;; characters.el ends here