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