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