Mercurial > emacs
annotate lisp/nxml/nxml-uchnm.el @ 94533:4bc924044f22
Remove unneeded TODO item in comment.
author | Eric S. Raymond <esr@snark.thyrsus.com> |
---|---|
date | Fri, 02 May 2008 03:23:53 +0000 |
parents | 2c349cf3a783 |
children | d495d4d5452f |
rev | line source |
---|---|
86361 | 1 ;;; nxml-uchnm.el --- support for Unicode standard cha names in nxml-mode |
2 | |
87665 | 3 ;; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc. |
86361 | 4 |
5 ;; Author: James Clark | |
6 ;; Keywords: XML | |
7 | |
86543 | 8 ;; This file is part of GNU Emacs. |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 3, or (at your option) | |
13 ;; any later version. | |
86361 | 14 |
86543 | 15 ;; GNU Emacs is distributed in the hope that it will be useful, |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
86361 | 19 |
86543 | 20 ;; You should have received a copy of the GNU General Public License |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
23 ;; Boston, MA 02110-1301, USA. | |
86361 | 24 |
25 ;;; Commentary: | |
26 | |
27 ;; This enables the use of the character names defined in the Unicode | |
28 ;; Standard. The use of the names can be controlled on a per-block | |
29 ;; basis, so as both to reduce memory usage and loading time, | |
30 ;; and to make completion work better. | |
31 | |
32 ;;; Code: | |
33 | |
34 (require 'nxml-mode) | |
35 | |
36 (defconst nxml-unicode-blocks | |
37 '(("Basic Latin" #x0000 #x007F) | |
38 ("Latin-1 Supplement" #x0080 #x00FF) | |
39 ("Latin Extended-A" #x0100 #x017F) | |
40 ("Latin Extended-B" #x0180 #x024F) | |
41 ("IPA Extensions" #x0250 #x02AF) | |
42 ("Spacing Modifier Letters" #x02B0 #x02FF) | |
43 ("Combining Diacritical Marks" #x0300 #x036F) | |
44 ("Greek and Coptic" #x0370 #x03FF) | |
45 ("Cyrillic" #x0400 #x04FF) | |
46 ("Cyrillic Supplementary" #x0500 #x052F) | |
47 ("Armenian" #x0530 #x058F) | |
48 ("Hebrew" #x0590 #x05FF) | |
49 ("Arabic" #x0600 #x06FF) | |
50 ("Syriac" #x0700 #x074F) | |
51 ("Thaana" #x0780 #x07BF) | |
52 ("Devanagari" #x0900 #x097F) | |
53 ("Bengali" #x0980 #x09FF) | |
54 ("Gurmukhi" #x0A00 #x0A7F) | |
55 ("Gujarati" #x0A80 #x0AFF) | |
56 ("Oriya" #x0B00 #x0B7F) | |
57 ("Tamil" #x0B80 #x0BFF) | |
58 ("Telugu" #x0C00 #x0C7F) | |
59 ("Kannada" #x0C80 #x0CFF) | |
60 ("Malayalam" #x0D00 #x0D7F) | |
61 ("Sinhala" #x0D80 #x0DFF) | |
62 ("Thai" #x0E00 #x0E7F) | |
63 ("Lao" #x0E80 #x0EFF) | |
64 ("Tibetan" #x0F00 #x0FFF) | |
65 ("Myanmar" #x1000 #x109F) | |
66 ("Georgian" #x10A0 #x10FF) | |
67 ("Hangul Jamo" #x1100 #x11FF) | |
68 ("Ethiopic" #x1200 #x137F) | |
69 ("Cherokee" #x13A0 #x13FF) | |
70 ("Unified Canadian Aboriginal Syllabics" #x1400 #x167F) | |
71 ("Ogham" #x1680 #x169F) | |
72 ("Runic" #x16A0 #x16FF) | |
73 ("Tagalog" #x1700 #x171F) | |
74 ("Hanunoo" #x1720 #x173F) | |
75 ("Buhid" #x1740 #x175F) | |
76 ("Tagbanwa" #x1760 #x177F) | |
77 ("Khmer" #x1780 #x17FF) | |
78 ("Mongolian" #x1800 #x18AF) | |
79 ("Latin Extended Additional" #x1E00 #x1EFF) | |
80 ("Greek Extended" #x1F00 #x1FFF) | |
81 ("General Punctuation" #x2000 #x206F) | |
82 ("Superscripts and Subscripts" #x2070 #x209F) | |
83 ("Currency Symbols" #x20A0 #x20CF) | |
84 ("Combining Diacritical Marks for Symbols" #x20D0 #x20FF) | |
85 ("Letterlike Symbols" #x2100 #x214F) | |
86 ("Number Forms" #x2150 #x218F) | |
87 ("Arrows" #x2190 #x21FF) | |
88 ("Mathematical Operators" #x2200 #x22FF) | |
89 ("Miscellaneous Technical" #x2300 #x23FF) | |
90 ("Control Pictures" #x2400 #x243F) | |
91 ("Optical Character Recognition" #x2440 #x245F) | |
92 ("Enclosed Alphanumerics" #x2460 #x24FF) | |
93 ("Box Drawing" #x2500 #x257F) | |
94 ("Block Elements" #x2580 #x259F) | |
95 ("Geometric Shapes" #x25A0 #x25FF) | |
96 ("Miscellaneous Symbols" #x2600 #x26FF) | |
97 ("Dingbats" #x2700 #x27BF) | |
98 ("Miscellaneous Mathematical Symbols-A" #x27C0 #x27EF) | |
99 ("Supplemental Arrows-A" #x27F0 #x27FF) | |
100 ("Braille Patterns" #x2800 #x28FF) | |
101 ("Supplemental Arrows-B" #x2900 #x297F) | |
102 ("Miscellaneous Mathematical Symbols-B" #x2980 #x29FF) | |
103 ("Supplemental Mathematical Operators" #x2A00 #x2AFF) | |
104 ("CJK Radicals Supplement" #x2E80 #x2EFF) | |
105 ("Kangxi Radicals" #x2F00 #x2FDF) | |
106 ("Ideographic Description Characters" #x2FF0 #x2FFF) | |
107 ("CJK Symbols and Punctuation" #x3000 #x303F) | |
108 ("Hiragana" #x3040 #x309F) | |
109 ("Katakana" #x30A0 #x30FF) | |
110 ("Bopomofo" #x3100 #x312F) | |
111 ("Hangul Compatibility Jamo" #x3130 #x318F) | |
112 ("Kanbun" #x3190 #x319F) | |
113 ("Bopomofo Extended" #x31A0 #x31BF) | |
114 ("Katakana Phonetic Extensions" #x31F0 #x31FF) | |
115 ("Enclosed CJK Letters and Months" #x3200 #x32FF) | |
116 ("CJK Compatibility" #x3300 #x33FF) | |
117 ("CJK Unified Ideographs Extension A" #x3400 #x4DBF) | |
118 ;;("CJK Unified Ideographs" #x4E00 #x9FFF) | |
119 ("Yi Syllables" #xA000 #xA48F) | |
120 ("Yi Radicals" #xA490 #xA4CF) | |
121 ;;("Hangul Syllables" #xAC00 #xD7AF) | |
122 ;;("High Surrogates" #xD800 #xDB7F) | |
123 ;;("High Private Use Surrogates" #xDB80 #xDBFF) | |
124 ;;("Low Surrogates" #xDC00 #xDFFF) | |
125 ;;("Private Use Area" #xE000 #xF8FF) | |
126 ;;("CJK Compatibility Ideographs" #xF900 #xFAFF) | |
127 ("Alphabetic Presentation Forms" #xFB00 #xFB4F) | |
128 ("Arabic Presentation Forms-A" #xFB50 #xFDFF) | |
129 ("Variation Selectors" #xFE00 #xFE0F) | |
130 ("Combining Half Marks" #xFE20 #xFE2F) | |
131 ("CJK Compatibility Forms" #xFE30 #xFE4F) | |
132 ("Small Form Variants" #xFE50 #xFE6F) | |
133 ("Arabic Presentation Forms-B" #xFE70 #xFEFF) | |
134 ("Halfwidth and Fullwidth Forms" #xFF00 #xFFEF) | |
135 ("Specials" #xFFF0 #xFFFF) | |
136 ("Old Italic" #x10300 #x1032F) | |
137 ("Gothic" #x10330 #x1034F) | |
138 ("Deseret" #x10400 #x1044F) | |
139 ("Byzantine Musical Symbols" #x1D000 #x1D0FF) | |
140 ("Musical Symbols" #x1D100 #x1D1FF) | |
141 ("Mathematical Alphanumeric Symbols" #x1D400 #x1D7FF) | |
142 ;;("CJK Unified Ideographs Extension B" #x20000 #x2A6DF) | |
143 ;;("CJK Compatibility Ideographs Supplement" #x2F800 #x2FA1F) | |
144 ("Tags" #xE0000 #xE007F) | |
145 ;;("Supplementary Private Use Area-A" #xF0000 #xFFFFF) | |
146 ;;("Supplementary Private Use Area-B" #x100000 #x10FFFF) | |
147 ) | |
148 "List of Unicode blocks. | |
149 For each block there is a list (NAME FIRST LAST), where | |
150 NAME is a string giving the offical name of the block, | |
151 FIRST is the first code-point and LAST is the last code-point. | |
152 Blocks containing only characters with algorithmic names or no names | |
153 are omitted.") | |
154 | |
155 (defun nxml-unicode-block-char-name-set (name) | |
156 "Return a symbol for a block whose offical Unicode name is NAME. | |
157 The symbol is generated by downcasing and replacing each space | |
158 by a hyphen." | |
159 (intern (replace-regexp-in-string " " "-" (downcase name)))) | |
160 | |
161 ;; This is intended to be a superset of the coverage | |
162 ;; of existing standard entity sets. | |
163 (defvar nxml-enabled-unicode-blocks-default | |
164 '(basic-latin | |
165 latin-1-supplement | |
166 latin-extended-a | |
167 latin-extended-b | |
168 ipa-extensions | |
169 spacing-modifier-letters | |
170 combining-diacritical-marks | |
171 greek-and-coptic | |
172 cyrillic | |
173 general-punctuation | |
174 superscripts-and-subscripts | |
175 currency-symbols | |
176 combining-diacritical-marks-for-symbols | |
177 letterlike-symbols | |
178 number-forms | |
179 arrows | |
180 mathematical-operators | |
181 miscellaneous-technical | |
182 control-pictures | |
183 optical-character-recognition | |
184 enclosed-alphanumerics | |
185 box-drawing | |
186 block-elements | |
187 geometric-shapes | |
188 miscellaneous-symbols | |
189 dingbats | |
190 miscellaneous-mathematical-symbols-a | |
191 supplemental-arrows-a | |
192 supplemental-arrows-b | |
193 miscellaneous-mathematical-symbols-b | |
194 supplemental-mathematical-operators | |
195 cjk-symbols-and-punctuation | |
196 alphabetic-presentation-forms | |
197 variation-selectors | |
198 small-form-variants | |
199 specials | |
200 mathematical-alphanumeric-symbols) | |
201 "Default value for `nxml-enabled-unicode-blocks'.") | |
202 | |
86565
1f32aa6d8ea7
(top-level): Adapt for moved unicode files.
Glenn Morris <rgm@gnu.org>
parents:
86543
diff
changeset
|
203 (mapc (lambda (block) |
1f32aa6d8ea7
(top-level): Adapt for moved unicode files.
Glenn Morris <rgm@gnu.org>
parents:
86543
diff
changeset
|
204 (nxml-autoload-char-name-set |
1f32aa6d8ea7
(top-level): Adapt for moved unicode files.
Glenn Morris <rgm@gnu.org>
parents:
86543
diff
changeset
|
205 (nxml-unicode-block-char-name-set (car block)) |
1f32aa6d8ea7
(top-level): Adapt for moved unicode files.
Glenn Morris <rgm@gnu.org>
parents:
86543
diff
changeset
|
206 (expand-file-name |
1f32aa6d8ea7
(top-level): Adapt for moved unicode files.
Glenn Morris <rgm@gnu.org>
parents:
86543
diff
changeset
|
207 (format "nxml/%05X-%05X" |
1f32aa6d8ea7
(top-level): Adapt for moved unicode files.
Glenn Morris <rgm@gnu.org>
parents:
86543
diff
changeset
|
208 (nth 1 block) |
1f32aa6d8ea7
(top-level): Adapt for moved unicode files.
Glenn Morris <rgm@gnu.org>
parents:
86543
diff
changeset
|
209 (nth 2 block)) |
1f32aa6d8ea7
(top-level): Adapt for moved unicode files.
Glenn Morris <rgm@gnu.org>
parents:
86543
diff
changeset
|
210 data-directory))) |
1f32aa6d8ea7
(top-level): Adapt for moved unicode files.
Glenn Morris <rgm@gnu.org>
parents:
86543
diff
changeset
|
211 nxml-unicode-blocks) |
86361 | 212 |
87714
2c349cf3a783
(nxml-internal-unicode-char-name-sets-enabled): Rename from
Jason Rumney <jasonr@gnu.org>
parents:
87665
diff
changeset
|
213 ;; Internal flag to control whether customize reloads the character tables. |
2c349cf3a783
(nxml-internal-unicode-char-name-sets-enabled): Rename from
Jason Rumney <jasonr@gnu.org>
parents:
87665
diff
changeset
|
214 ;; Should be set the first time the |
2c349cf3a783
(nxml-internal-unicode-char-name-sets-enabled): Rename from
Jason Rumney <jasonr@gnu.org>
parents:
87665
diff
changeset
|
215 (defvar nxml-internal-unicode-char-name-sets-enabled nil) |
86361 | 216 |
217 (defcustom nxml-enabled-unicode-blocks nxml-enabled-unicode-blocks-default | |
218 "List of Unicode blocks for which Unicode character names are enabled. | |
219 Each block is identified by a symbol derived from the name | |
220 of the block by downcasing and replacing each space by a hyphen." | |
86543 | 221 :group 'nxml |
86361 | 222 :set (lambda (sym value) |
223 (set-default 'nxml-enabled-unicode-blocks value) | |
87714
2c349cf3a783
(nxml-internal-unicode-char-name-sets-enabled): Rename from
Jason Rumney <jasonr@gnu.org>
parents:
87665
diff
changeset
|
224 (when nxml-internal-unicode-char-name-sets-enabled |
2c349cf3a783
(nxml-internal-unicode-char-name-sets-enabled): Rename from
Jason Rumney <jasonr@gnu.org>
parents:
87665
diff
changeset
|
225 (nxml-enable-unicode-char-name-sets))) |
86361 | 226 :type (cons 'set |
227 (mapcar (lambda (block) | |
228 `(const :tag ,(format "%s (%04X-%04X)" | |
229 (nth 0 block) | |
230 (nth 1 block) | |
231 (nth 2 block)) | |
232 ,(nxml-unicode-block-char-name-set | |
233 (nth 0 block)))) | |
234 nxml-unicode-blocks))) | |
235 | |
236 ;;;###autoload | |
237 (defun nxml-enable-unicode-char-name-sets () | |
238 "Enable the use of Unicode standard names for characters. | |
239 The Unicode blocks for which names are enabled is controlled by | |
240 the variable `nxml-enabled-unicode-blocks'." | |
241 (interactive) | |
87714
2c349cf3a783
(nxml-internal-unicode-char-name-sets-enabled): Rename from
Jason Rumney <jasonr@gnu.org>
parents:
87665
diff
changeset
|
242 (setq nxml-internal-unicode-char-name-sets-enabled t) |
86543 | 243 (mapc (lambda (block) |
244 (nxml-disable-char-name-set | |
245 (nxml-unicode-block-char-name-set (car block)))) | |
246 nxml-unicode-blocks) | |
247 (mapc (lambda (nameset) | |
248 (nxml-enable-char-name-set nameset)) | |
249 nxml-enabled-unicode-blocks)) | |
86361 | 250 |
251 (provide 'nxml-uchnm) | |
252 | |
86379 | 253 ;; arch-tag: 440248c3-b604-467c-8b50-e83662c659a3 |
86361 | 254 ;;; nxml-uchnm.el ends here |