characters.el 49 KB

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