1 ;; unidata-gen.el -- Create files containing character property data.
3 ;; Copyright (C) 2008-2015 Free Software Foundation, Inc.
5 ;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
6 ;; National Institute of Advanced Industrial Science and Technology (AIST)
7 ;; Registration Number H13PRO009
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (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.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28 ;; This file must be byte-compilable/loadable by `temacs' and also
29 ;; the entry function `unidata-gen-files' must be runnable by `temacs'.
31 ;; FILES TO BE GENERATED
33 ;; The entry function `unidata-gen-files' generates these files in
34 ;; in directory specified by its dest-dir argument.
37 ;; It contains a series of forms of this format:
38 ;; (define-char-code-property PROP FILE)
39 ;; where PROP is a symbol representing a character property
40 ;; (name, general-category, etc), and FILE is a name of one of
41 ;; the following files.
43 ;; uni-name.el, uni-category.el, uni-combining.el, uni-bidi.el,
44 ;; uni-decomposition.el, uni-decimal.el, uni-digit.el, uni-numeric.el,
45 ;; uni-mirrored.el, uni-old-name.el, uni-comment.el, uni-uppercase.el,
46 ;; uni-lowercase.el, uni-titlecase.el
47 ;; They contain one or more forms of this format:
48 ;; (define-char-code-property PROP CHAR-TABLE)
49 ;; where PROP is the same as above, and CHAR-TABLE is a
50 ;; char-table containing property values in a compressed format.
52 ;; When they are installed in .../lisp/international/, the file
53 ;; "charprop.el" is preloaded in loadup.el. The other files are
54 ;; automatically loaded when the Lisp functions
55 ;; `get-char-code-property' and `put-char-code-property', and C
56 ;; function uniprop_table are called.
58 ;; FORMAT OF A CHAR TABLE
60 ;; We want to make a file size containing a char-table small. We
61 ;; also want to load the file and get a property value fast. We
62 ;; also want to reduce the used memory after loading it. So,
63 ;; instead of naively storing a property value for each character in
64 ;; a char-table (and write it out into a file), we store compressed
65 ;; data in a char-table as below.
67 ;; If succeeding 128*N characters have the same property value, we
68 ;; store that value (or the encoded one) for them. Otherwise,
69 ;; compress values (or the encoded ones) for succeeding 128
70 ;; characters into a single string and store it for those
71 ;; characters. The way of compression depends on a property. See
72 ;; the section "SIMPLE TABLE", "RUN-LENGTH TABLE", and "WORD-LIST
75 ;; The char table has five extra slots:
76 ;; 1st: property symbol
77 ;; 2nd: function to call to get a property value,
78 ;; or an index number of C function to decode the value,
79 ;; or nil if the value can be directly got from the table.
80 ;; 3nd: function to call to put a property value,
81 ;; or an index number of C function to encode the value,
82 ;; or nil if the value can be directly stored in the table.
83 ;; 4th: function to call to get a description of a property value, or nil
84 ;; 5th: data referred by the above functions
86 ;; List of elements of this form:
87 ;; (CHAR-or-RANGE PROP1 PROP2 ... PROPn)
88 ;; CHAR-or-RANGE: a character code or a cons of character codes
89 ;; PROPn: string representing the nth property value
91 (eval-when-compile (require 'cl-lib
))
93 (defvar unidata-list nil
)
95 ;; Name of the directory containing files of Unicode Character Database.
97 ;; Dynamically bound in unidata-gen-files.
98 (defvar unidata-dir nil
)
100 (defun unidata-setup-list (unidata-text-file)
101 (let* ((table (list nil
))
103 (block-names '(("^<CJK Ideograph" . CJK\ IDEOGRAPH
)
104 ("^<Hangul Syllable" . HANGUL\ SYLLABLE
)
105 ("^<.*High Surrogate" . HIGH\ SURROGATE
)
106 ("^<.*Low Surrogate" . LOW\ SURROGATE
)
107 ("^<.*Private Use" . PRIVATE\ USE
)))
109 (setq unidata-text-file
(expand-file-name unidata-text-file unidata-dir
))
110 (or (file-readable-p unidata-text-file
)
111 (error "File not readable: %s" unidata-text-file
))
113 ;; Insert a file of this format:
114 ;; (CHAR NAME CATEGORY ...)
115 ;; where CHAR is a character code, the following elements are strings
116 ;; representing character properties.
117 (insert-file-contents unidata-text-file
)
118 (goto-char (point-min))
121 (setq val
(read (current-buffer))
125 ;; Check this kind of block.
126 ;; 4E00;<CJK Ideograph, First>;Lo;0;L;;;;;N;;;;;
127 ;; 9FCB;<CJK Ideograph, Last>;Lo;0;L;;;;;N;;;;;
128 (if (and (= (aref name
0) ?
<)
129 (string-match ", First>$" name
))
133 (setq val
(read (current-buffer))
135 block-name
(cadr val
)
138 (if (string-match (caar l
) block-name
)
139 (setq name
(cdar l
) l nil
)
141 (setcar val
(cons first char
))
142 (setcar (cdr val
) name
)))
145 (setcdr tail
(list val
))
146 (setq tail
(cdr tail
))))
148 (setq unidata-list
(cdr table
))))
150 ;; Alist of this form:
151 ;; (PROP INDEX GENERATOR FILENAME DOCSTRING DESCRIBER DEFAULT VAL-LIST)
152 ;; PROP: character property
153 ;; INDEX: index to each element of unidata-list for PROP.
154 ;; It may be a function that generates an alist of character codes
155 ;; vs. the corresponding property values. Currently, only character
156 ;; codepoints or symbol values are supported in this case.
157 ;; GENERATOR: function to generate a char-table
158 ;; FILENAME: filename to store the char-table
159 ;; DOCSTRING: docstring for the property
160 ;; DESCRIBER: function to call to get a description string of property value
161 ;; DEFAULT: the default value of the property. It may have the form
162 ;; (VAL0 (FROM1 TO1 VAL1) ...) which indicates that the default
163 ;; value is VAL0 except for characters in the ranges specified by
164 ;; FROMn and TOn (inclusive). The default value of characters
165 ;; between FROMn and TOn is VALn.
166 ;; VAL-LIST: list of specially ordered property values
168 (defconst unidata-prop-alist
170 1 unidata-gen-table-name
"uni-name.el"
171 "Unicode character name.
172 Property value is a string or nil.
173 The value nil stands for the default value \"null string\")."
177 2 unidata-gen-table-symbol
"uni-category.el"
178 "Unicode general category.
179 Property value is one of the following symbols:
180 Lu, Ll, Lt, Lm, Lo, Mn, Mc, Me, Nd, Nl, No, Pc, Pd, Ps, Pe, Pi, Pf, Po,
181 Sm, Sc, Sk, So, Zs, Zl, Zp, Cc, Cf, Cs, Co, Cn"
182 unidata-describe-general-category
184 ;; The order of elements must be in sync with unicode_category_t
185 ;; in src/character.h.
186 (Lu Ll Lt Lm Lo Mn Mc Me Nd Nl No Pc Pd Ps Pe Pi Pf Po
187 Sm Sc Sk So Zs Zl Zp Cc Cf Cs Co Cn
))
188 (canonical-combining-class
189 3 unidata-gen-table-integer
"uni-combining.el"
190 "Unicode canonical combining class.
191 Property value is an integer."
192 unidata-describe-canonical-combining-class
195 4 unidata-gen-table-symbol
"uni-bidi.el"
197 Property value is one of the following symbols:
198 L, LRE, LRO, LRI, R, AL, RLE, RLO, RLI, FSI, PDF, PDI,
199 EN, ES, ET, AN, CS, NSM, BN, B, S, WS, ON"
200 unidata-describe-bidi-class
201 ;; The assignment of default values to blocks of code points
202 ;; follows the file DerivedBidiClass.txt from the Unicode
203 ;; Character Database (UCD).
204 (L (#x0600
#x06FF AL
) (#xFB50
#xFDFF AL
) (#xFE70
#xFEFF AL
)
205 (#x0590
#x05FF R
) (#x07C0
#x08FF R
)
206 (#xFB1D
#xFB4F R
) (#x10800
#x10FFF R
) (#x1E800
#x1EFFF R
))
207 ;; The order of elements must be in sync with bidi_type_t in
209 (L R EN AN BN B AL LRE LRO RLE RLO PDF LRI RLI FSI PDI
210 ES ET CS NSM S WS ON
))
212 5 unidata-gen-table-decomposition
"uni-decomposition.el"
213 "Unicode decomposition mapping.
214 Property value is a list of characters. The first element may be
215 one of these symbols representing compatibility formatting tag:
216 font, noBreak, initial, medial, final, isolated, circle, super,
217 sub, vertical, wide, narrow, small, square, fraction, compat"
218 unidata-describe-decomposition
)
220 6 unidata-gen-table-integer
"uni-decimal.el"
221 "Unicode numeric value (decimal digit).
222 Property value is an integer 0..9, or nil.
223 The value nil stands for NaN \"Numeric_Value\".")
225 7 unidata-gen-table-integer
"uni-digit.el"
226 "Unicode numeric value (digit).
227 Property value is an integer 0..9, or nil.
228 The value nil stands for NaN \"Numeric_Value\".")
230 8 unidata-gen-table-numeric
"uni-numeric.el"
231 "Unicode numeric value (numeric).
232 Property value is an integer, a floating point, or nil.
233 The value nil stands for NaN \"Numeric_Value\".")
235 9 unidata-gen-table-symbol
"uni-mirrored.el"
236 "Unicode bidi mirrored flag.
237 Property value is a symbol `Y' or `N'. See also the property `mirroring'."
241 10 unidata-gen-table-name
"uni-old-name.el"
242 "Unicode old names as published in Unicode 1.0.
243 Property value is a string or nil.
244 The value nil stands for the default value \"null string\").")
246 11 unidata-gen-table-name
"uni-comment.el"
247 "Unicode ISO 10646 comment.
248 Property value is a string.")
250 12 unidata-gen-table-character
"uni-uppercase.el"
251 "Unicode simple uppercase mapping.
252 Property value is a character or nil.
253 The value nil means that the actual property value of a character
254 is the character itself."
257 13 unidata-gen-table-character
"uni-lowercase.el"
258 "Unicode simple lowercase mapping.
259 Property value is a character or nil.
260 The value nil means that the actual property value of a character
261 is the character itself."
264 14 unidata-gen-table-character
"uni-titlecase.el"
265 "Unicode simple titlecase mapping.
266 Property value is a character or nil.
267 The value nil means that the actual property value of a character
268 is the character itself."
271 unidata-gen-mirroring-list unidata-gen-table-character
"uni-mirrored.el"
272 "Unicode bidi-mirroring characters.
273 Property value is a character that has the corresponding mirroring image or nil.
274 The value nil means that the actual property value of a character
275 is the character itself.")
277 unidata-gen-brackets-list unidata-gen-table-character
"uni-brackets.el"
278 "Unicode bidi paired-bracket characters.
279 Property value is the paired bracket character, or nil.
280 The value nil means that the character is neither an opening nor
281 a closing paired bracket."
284 unidata-gen-bracket-type-list unidata-gen-table-symbol
"uni-brackets.el"
285 "Unicode bidi paired-bracket type.
286 Property value is a symbol `o' (Open), `c' (Close), or `n' (None)."
287 unidata-describe-bidi-bracket-type
289 ;; The order of elements must be in sync with bidi_bracket_type_t
290 ;; in src/dispextern.h.
293 ;; Functions to access the above data.
294 (defsubst unidata-prop-index
(prop) (nth 1 (assq prop unidata-prop-alist
)))
295 (defsubst unidata-prop-generator
(prop) (nth 2 (assq prop unidata-prop-alist
)))
296 (defsubst unidata-prop-file
(prop) (nth 3 (assq prop unidata-prop-alist
)))
297 (defsubst unidata-prop-docstring
(prop) (nth 4 (assq prop unidata-prop-alist
)))
298 (defsubst unidata-prop-describer
(prop) (nth 5 (assq prop unidata-prop-alist
)))
299 (defsubst unidata-prop-default
(prop) (nth 6 (assq prop unidata-prop-alist
)))
300 (defsubst unidata-prop-val-list
(prop) (nth 7 (assq prop unidata-prop-alist
)))
305 ;; If the type of character property value is character, and the
306 ;; values of succeeding character codes are usually different, we use
307 ;; a char-table described here to store such values.
309 ;; A char-table divides character code space (#x0..#x3FFFFF) into
310 ;; #x8000 blocks (each block contains 128 characters).
312 ;; If all characters of a block have no property, a char-table has the
313 ;; symbol nil for that block. Otherwise a char-table has a string of
314 ;; the following format for it.
316 ;; The first character of the string is ?\001.
317 ;; The second character of the string is FIRST-INDEX.
318 ;; The Nth (N > 1) character of the string is a property value of the
319 ;; character (BLOCK-HEAD + FIRST-INDEX + N - 2), where BLOCK-HEAD is
320 ;; the first character of the block.
322 ;; This kind of char-table has these extra slots:
323 ;; 1st: the property symbol
325 ;; 3rd: 0 (corresponding to uniprop_encode_character in chartab.c)
328 (defun unidata-gen-table-character (prop &rest ignore
)
329 (let ((table (make-char-table 'char-code-property-table
))
330 (prop-idx (unidata-prop-index prop
))
331 (vec (make-vector 128 0))
333 elt range val idx slot
)
334 (if (functionp prop-idx
)
335 (setq tail
(funcall prop-idx
)
338 (setq elt
(car tail
) tail
(cdr tail
))
339 (setq range
(car elt
)
340 val
(nth prop-idx elt
))
341 (if (= (length val
) 0)
343 (setq val
(string-to-number val
16)))
346 (set-char-table-range table range val
))
347 (let* ((start (lsh (lsh range -
7) 7))
348 (limit (+ start
127))
349 first-index last-index
)
352 (aset vec
(setq last-index
(setq first-index
(- range start
)))
354 (while (and (setq elt
(car tail
) range
(car elt
))
357 (setq val
(nth prop-idx elt
))
358 (when (> (length val
) 0)
359 (aset vec
(setq last-index
(- range start
))
360 (string-to-number val
16))
362 (setq first-index last-index
)))
363 (setq tail
(cdr tail
)))
365 (let ((str (string 1 first-index
))
367 (while (<= first-index last-index
)
368 (setq str
(format "%s%c" str
(or (aref vec first-index
) 0))
369 first-index
(1+ first-index
)))
370 (set-char-table-range table
(cons start limit
) str
))))))
372 (set-char-table-extra-slot table
0 prop
)
373 (set-char-table-extra-slot table
2 0)
380 ;; If many characters of successive character codes have the same
381 ;; property value, we use a char-table described here to store the
384 ;; At first, instead of a value itself, we store an index number to
385 ;; the VAL-TABLE (5th extra slot) in the table. We call that index
386 ;; number as VAL-CODE here after.
388 ;; A char-table divides character code space (#x0..#x3FFFFF) into
389 ;; #x8000 blocks (each block contains 128 characters).
391 ;; If all characters of a block have the same value, a char-table has
392 ;; VAL-CODE for that block. Otherwise a char-table has a string of
393 ;; the following format for that block.
395 ;; The first character of the string is ?\002.
396 ;; The following characters has this form:
397 ;; ( VAL-CODE RUN-LENGTH ? ) +
399 ;; VAL-CODE (0..127): index into VAL-TABLE.
400 ;; RUN-LENGTH (130..255):
401 ;; (RUN-LENGTH - 128) specifies how many characters have the same
402 ;; value. If omitted, it means 1.
404 ;; This kind of char-table has these extra slots:
405 ;; 1st: the property symbol
406 ;; 2nd: 0 (corresponding to uniprop_decode_value in chartab.c)
407 ;; 3rd: 1..3 (corresponding to uniprop_encode_xxx in chartab.c)
408 ;; 4th: function or nil
411 ;; Encode the character property value VAL into an integer value by
412 ;; VAL-LIST. By side effect, VAL-LIST is modified.
413 ;; VAL-LIST has this form:
414 ;; ((nil . 0) (VAL1 . 1) (VAL2 . 2) ...)
415 ;; If VAL is one of VALn, just return n.
416 ;; Otherwise, VAL-LIST is modified to this:
417 ;; ((nil . 0) (VAL1 . 1) (VAL2 . 2) ... (VAL . n+1))
419 ;; WARN is an optional warning to display when the value list is
420 ;; extended, for property values that need to be in sync with other
421 ;; parts of Emacs; currently only used for bidi-class.
423 (defun unidata-encode-val (val-list val
&optional warn
)
424 (let ((slot (assoc val val-list
))
428 (if warn
(message warn val
))
429 (setq val-code
(length val-list
))
430 (nconc val-list
(list (cons val val-code
)))
433 ;; Generate a char-table for the character property PROP.
435 (defun unidata-gen-table (prop val-func default-value val-list
)
436 (let ((table (make-char-table 'char-code-property-table
))
437 (prop-idx (unidata-prop-index prop
))
438 (vec (make-vector 128 0))
439 ;; When this warning is printed, there's a need to make the
440 ;; following changes:
441 ;; (1) update unidata-prop-alist with the new bidi-class values;
442 ;; (2) extend bidi_type_t enumeration on src/dispextern.h to
443 ;; include the new classes;
444 ;; (3) possibly update the assertion in bidi.c:bidi_check_type; and
445 ;; (4) possibly update the switch cases in
446 ;; bidi.c:bidi_get_type and bidi.c:bidi_get_category.
448 ** Found new bidi-class '%s', please update bidi.c and dispextern.h")
449 tail elt range val val-code idx slot
451 (setq val-list
(cons nil
(copy-sequence val-list
)))
452 (setq tail val-list val-code
0)
453 ;; Convert (nil A B ...) to ((nil . 0) (A . 1) (B . 2) ...)
455 (setcar tail
(cons (car tail
) val-code
))
456 (setq tail
(cdr tail
) val-code
(1+ val-code
)))
457 (if (consp default-value
)
458 (setq default-value
(copy-sequence default-value
))
459 (setq default-value
(list default-value
)))
460 (setcar default-value
461 (unidata-encode-val val-list
(car default-value
)))
462 (set-char-table-range table t
(car default-value
))
463 (set-char-table-range table nil
(car default-value
))
464 (dolist (elm (cdr default-value
))
465 (setcar (nthcdr 2 elm
)
466 (unidata-encode-val val-list
(nth 2 elm
)))
467 (set-char-table-range table
(cons (car elm
) (nth 1 elm
)) (nth 2 elm
)))
469 (if (functionp prop-idx
)
470 (setq tail
(funcall prop-idx
)
472 (setq tail unidata-list
))
474 (setq elt
(car tail
) tail
(cdr tail
))
475 (setq range
(car elt
)
476 val
(funcall val-func
(nth prop-idx elt
)))
477 (setq val-code
(if val
(unidata-encode-val val-list val
478 (and (eq prop
'bidi-class
)
482 (set-char-table-range table range val-code
)
483 (let ((from (car range
)) (to (cdr range
)))
484 ;; If RANGE doesn't end at the char-table boundary (each
485 ;; 128 characters), we may have to carry over the data
486 ;; for the last several characters (at most 127 chars)
487 ;; to the next loop. In that case, set PREV-RANGE-DATA
488 ;; to ((FROM . TO) . VAL-CODE) where (FROM . TO)
489 ;; specifies the range of characters handled in the next
491 (when (< (logand to
#x7F
) #x7F
)
492 (if (< from
(logand to
#x1FFF80
))
493 (setq from
(logand to
#x1FFF80
)))
494 (setq prev-range-data
(cons (cons from to
) val-code
)))))
495 (let* ((start (lsh (lsh range -
7) 7))
496 (limit (+ start
127))
497 str count new-val from to vcode
)
498 (fillarray vec
(car default-value
))
499 (dolist (elm (cdr default-value
))
500 (setq from
(car elm
) to
(nth 1 elm
))
501 (when (and (<= from limit
)
502 (or (>= from start
) (>= to start
)))
503 (setq from
(max from start
)
507 (aset vec
(- from start
) vcode
)
508 (setq from
(1+ from
)))))
509 ;; See the comment above.
510 (when (and prev-range-data
511 (>= (cdr (car prev-range-data
)) start
))
512 (setq from
(car (car prev-range-data
))
513 to
(cdr (car prev-range-data
))
514 vcode
(cdr prev-range-data
))
516 (aset vec
(- from start
) vcode
)
517 (setq from
(1+ from
))))
518 (setq prev-range-data nil
)
520 (aset vec
(- range start
) val-code
))
521 (while (and (setq elt
(car tail
) range
(car elt
))
524 (setq new-val
(funcall val-func
(nth prop-idx elt
)))
525 (if (not (eq val new-val
))
527 val-code
(if val
(unidata-encode-val
528 val-list val
(and (eq prop
'bidi-class
)
531 (aset vec
(- range start
) val-code
))
532 (setq tail
(cdr tail
)))
533 (setq str
"\002" val-code -
1 count
0)
536 (setq count
(1+ count
))
538 (setq str
(concat str
(string val-code
541 (setq str
(concat str
(string val-code val-code
)))
543 (setq str
(concat str
(string val-code
))))))
544 (setq val-code x count
1)))
548 (set-char-table-range table
(cons start limit
) val-code
))
550 (set-char-table-range table
(cons start limit
) str
)
552 (setq str
(concat str
(string val-code
(+ count
128))))
554 (setq str
(concat str
(string val-code val-code
)))
555 (setq str
(concat str
(string val-code
)))))
556 (set-char-table-range table
(cons start limit
) str
))))))
558 (set-char-table-extra-slot table
0 prop
)
559 (set-char-table-extra-slot table
4 (vconcat (mapcar 'car val-list
)))
562 (defun unidata-gen-table-symbol (prop default-value val-list
)
563 (let ((table (unidata-gen-table prop
564 #'(lambda (x) (and (> (length x
) 0)
566 default-value val-list
)))
567 (set-char-table-extra-slot table
1 0)
568 (set-char-table-extra-slot table
2 1)
571 (defun unidata-gen-table-integer (prop default-value val-list
)
572 (let ((table (unidata-gen-table prop
573 #'(lambda (x) (and (> (length x
) 0)
574 (string-to-number x
)))
575 default-value val-list
)))
576 (set-char-table-extra-slot table
1 0)
577 (set-char-table-extra-slot table
2 1)
580 (defun unidata-gen-table-numeric (prop default-value val-list
)
581 (let ((table (unidata-gen-table prop
583 (if (string-match "/" x
)
584 (/ (float (string-to-number x
))
586 (substring x
(match-end 0))))
588 (string-to-number x
))))
589 default-value val-list
)))
590 (set-char-table-extra-slot table
1 0)
591 (set-char-table-extra-slot table
2 2)
597 ;; If the table is for `name' property, each character in the string
599 ;; DIFF-HEAD-CODE (0, 1, or 2):
600 ;; specifies how to decode the following characters.
601 ;; WORD-CODE (3..#x7FF excluding '-', '0'..'9', 'A'..'Z'):
602 ;; specifies an index number into WORD-TABLE (see below)
603 ;; Otherwise (' ', '-', '0'..'9', 'A'..'Z'):
604 ;; specifies a literal word.
606 ;; The 4th slots is a vector:
607 ;; [ WORD-TABLE BLOCK-NAME HANGUL-JAMO-TABLE ]
608 ;; WORD-TABLE is a vector of word symbols.
609 ;; BLOCK-NAME is a vector of name symbols for a block of characters.
610 ;; HANGUL-JAMO-TABLE is `unidata-name-jamo-name-table'.
612 ;; Return the difference of symbol list L1 and L2 in this form:
613 ;; (DIFF-HEAD SYM1 SYM2 ...)
614 ;; DIFF-HEAD is ((SAME-HEAD-LENGTH * 16) + SAME-TAIL-LENGTH).
615 ;; Ex: If L1 is (a b c d e f) and L2 is (a g h e f), this function
616 ;; returns ((+ (* 1 16) 2) g h).
617 ;; It means that we can get L2 from L1 by prepending the first element
618 ;; of L1 and appending the last 2 elements of L1 to the list (g h).
619 ;; If L1 and L2 don't have common elements at the head and tail,
620 ;; set DIFF-HEAD to -1 and SYM1 ... to the elements of L2.
622 (defun unidata-word-list-diff (l1 l2
)
629 (while (and l1
(eq (car l1
) (car l2
)))
631 l1
(cdr l1
) len1
(1- len1
) l2
(cdr l2
) len2
(1- len2
)))
632 (while (and (< end len1
) (< end len2
)
633 (eq (nth (- len1 end
1) l1
) (nth (- len2 end
1) l2
)))
634 (setq end
(1+ end
))))
635 (if (= (+ beg end
) 0)
636 (setq result
(list -
1))
637 (setq result
(list (+ (* beg
16) (+ beg
(- len1 end
))))))
639 (setcdr result
(cons (nth (- len2 end
1) l2
) (cdr result
)))
643 ;; Return a compressed form of the vector VEC. Each element of VEC is
644 ;; a list of symbols of which names can be concatenated to form a
645 ;; character name. This function changes those elements into
646 ;; compressed forms by utilizing the fact that diff of consecutive
647 ;; elements is usually small.
649 (defun unidata-word-list-compress (vec)
650 (let (last-elt last-idx diff-head tail elt val
)
652 (setq elt
(aref vec i
))
657 (setq val
(unidata-word-list-diff last-elt elt
))
660 val
(cons 0 (cdr val
)))
661 (if (eq diff-head
(car val
))
662 (setq val
(cons 2 (cdr val
)))
663 (setq diff-head
(car val
))
665 (setq val
(cons 1 val
))))))
667 (setq last-idx i last-elt elt
)))
671 (let ((shorter (make-vector (1+ last-idx
) nil
)))
672 (dotimes (i (1+ last-idx
))
673 (aset shorter i
(aref vec i
)))
674 (setq vec shorter
))))
677 ;; Encode the word index IDX into a characters code that can be
678 ;; embedded in a string.
680 (defsubst unidata-encode-word
(idx)
684 ;; Decode the character code CODE (that is embedded in a string) into
685 ;; the corresponding word name by looking up WORD-TABLE.
687 (defsubst unidata-decode-word
(code word-table
)
688 (setq code
(- code
3))
689 (if (< code
(length word-table
))
690 (aref word-table code
)))
692 ;; Table of short transliterated name symbols of Hangul Jamo divided
693 ;; into Choseong, Jungseong, and Jongseong.
695 (defconst unidata-name-jamo-name-table
696 [[G GG N D DD R M B BB S SS nil J JJ C K T P H
]
697 [A AE YA YAE EO E YEO YE O WA WAE OE YO U WEO WE WI YU EU YI I
]
698 [G GG GS N NJ NH D L LG LM LB LS LT LP LH M B BS S SS NG J C K T P H
]])
700 ;; Return a name of CHAR. VAL is the current value of (aref TABLE
703 (defun unidata-get-name (char val table
)
706 (if (> (aref val
0) 0)
708 (let* ((first-char (lsh (lsh char -
7) 7))
709 (word-table (aref (char-table-extra-slot table
4) 0))
712 (vec (make-vector 128 nil
))
714 (case-fold-search nil
)
715 c word-list tail-list last-list word diff-head
)
717 (setq c
(aref val i
))
720 (if (or word-list tail-list
)
722 (setq last-list
(nconc word-list tail-list
))))
723 (setq i
(1+ i
) idx
(1+ idx
)
724 word-list nil tail-list nil
)
729 (prog1 (aref val i
) (setq i
(1+ i
)))))
730 (setq tail-list
(nthcdr (% diff-head
16) last-list
))
731 (dotimes (i (/ diff-head
16))
732 (setq word-list
(nconc word-list
(list (car l
)))
737 (unidata-decode-word c word-table
))))
739 (if (or word-list tail-list
)
740 (aset vec idx
(nconc word-list tail-list
)))
743 (setq c
(+ first-char i
))
744 (let ((name (aref vec i
)))
746 (let ((tail (cdr (setq name
(copy-sequence name
))))
749 (setq elt
(car tail
))
750 (or (string= elt
"-")
752 (setcdr tail
(cons elt
(cdr tail
)))
754 (setq tail
(cddr tail
)))
755 (setq name
(apply 'concat name
))))
761 ((and (integerp val
) (> val
0))
762 (let* ((symbol-table (aref (char-table-extra-slot table
4) 1))
763 (sym (aref symbol-table
(1- val
))))
764 (cond ((eq sym
'HANGUL\ SYLLABLE
)
765 (let ((jamo-name-table (aref (char-table-extra-slot table
4) 2)))
766 ;; SIndex = S - SBase
767 (setq char
(- char
#xAC00
))
768 (let ( ;; LIndex = SIndex / NCount
770 ;; VIndex = (SIndex % NCount) * TCount
771 (V (/ (% char
588) 28))
772 ;; TIndex = SIndex % TCount
774 (format "HANGUL SYLLABLE %s%s%s"
775 ;; U+110B is nil in this table.
776 (or (aref (aref jamo-name-table
0) L
) "")
777 (aref (aref jamo-name-table
1) V
)
779 (aref (aref jamo-name-table
2) (1- T
)))))))
780 ((eq sym
'CJK\ IDEOGRAPH
)
781 (format "%s-%04X" sym char
))
782 ((eq sym
'CJK\ COMPATIBILITY\ IDEOGRAPH
)
783 (format "%s-%04X" sym char
))
784 ((eq sym
'HIGH\ SURROGATE
)
785 (format "%s-%04X" sym char
))
786 ((eq sym
'LOW\ SURROGATE
)
787 (format "%s-%04X" sym char
))
788 ((eq sym
'VARIATION\ SELECTOR
)
789 (format "%s-%d" sym
(+ (- char
#xe0100
) 17))))))))
791 ;; Store VAL as the name of CHAR in TABLE.
793 (defun unidata-put-name (char val table
)
794 (let ((current-val (aref table char
)))
795 (if (and (stringp current-val
) (= (aref current-val
0) 0))
796 (funcall (char-table-extra-slot table
1) char current-val table
))
797 (aset table char val
)))
799 (defun unidata-get-decomposition (char val table
)
808 (if (> (aref val
0) 0)
810 (let* ((first-char (lsh (lsh char -
7) 7))
811 (word-table (char-table-extra-slot table
4))
814 (vec (make-vector 128 nil
))
816 (case-fold-search nil
)
817 c word-list tail-list last-list word diff-head
)
819 (setq c
(aref val i
))
822 (if (or word-list tail-list
)
824 (setq last-list
(nconc word-list tail-list
))))
825 (setq i
(1+ i
) idx
(1+ idx
)
826 word-list nil tail-list nil
)
831 (prog1 (aref val i
) (setq i
(1+ i
)))))
832 (setq tail-list
(nthcdr (% diff-head
16) last-list
))
833 (dotimes (i (/ diff-head
16))
834 (setq word-list
(nconc word-list
(list (car l
)))
838 (list (or (unidata-decode-word c word-table
) c
)))
840 (if (or word-list tail-list
)
841 (aset vec idx
(nconc word-list tail-list
)))
843 (aset table
(+ first-char i
) (aref vec i
)))
844 (setq val
(aref vec
(- char first-char
)))
845 (or val
(list char
)))))
848 ((and (eq val
0) (>= char
#xAC00
) (<= char
#xD7A3
))
849 ;; SIndex = S (char) - SBase (#xAC00)
850 (setq char
(- char
#xAC00
))
851 (let (;; L = LBase + SIndex / NCount
852 (L (+ #x1100
(/ char
588)))
853 ;; V = VBase + (SIndex % NCount) * TCount
854 (V (+ #x1161
(/ (% char
588) 28)))
855 ;; LV = SBase + (SIndex / TCount) * TCount
856 (LV (+ #xAC00
(* (/ char
28) 28)))
857 ;; T = TBase + SIndex % TCount
858 (T (+ #x11A7
(% char
28))))
865 ;; Store VAL as the decomposition information of CHAR in TABLE.
867 (defun unidata-put-decomposition (char val table
)
868 (let ((current-val (aref table char
)))
869 (if (and (stringp current-val
) (= (aref current-val
0) 0))
870 (funcall (char-table-extra-slot table
1) char current-val table
))
871 (aset table char val
)))
873 ;; UnicodeData.txt contains these lines:
874 ;; 0000;<control>;Cc;0;BN;;;;;N;NULL;;;;
876 ;; 0020;SPACE;Zs;0;WS;;;;;N;;;;;
878 ;; The following command yields a file of about 96K bytes.
879 ;; % gawk -F ';' '{print $1,$2;}' < UnicodeData.txt | gzip > temp.gz
880 ;; With the following function, we can get a file of almost the same
883 ;; Generate a char-table for character names.
885 (defun unidata-gen-table-word-list (prop val-func
)
886 (let ((table (make-char-table 'char-code-property-table
))
887 (prop-idx (unidata-prop-index prop
))
888 (word-list (list nil
))
890 block-list block-word-table block-end
891 tail elt range val idx slot
)
892 (setq tail unidata-list
)
895 (setq elt
(car tail
) tail
(cdr tail
))
896 (setq range
(car elt
)
897 val
(funcall val-func
(nth prop-idx elt
)))
898 ;; Treat the sequence of "CJK COMPATIBILITY IDEOGRAPH-XXXX" and
899 ;; "VARIATION SELECTOR-XXX" as a block.
900 (if (and (consp val
) (eq prop
'name
)
901 (or (and (eq (car val
) 'CJK
)
902 (eq (nth 1 val
) 'COMPATIBILITY
))
903 (and (>= range
#xe0100
)
904 (eq (car val
) 'VARIATION
)
905 (eq (nth 1 val
) 'SELECTOR
))))
906 (let ((first (car val
))
909 (while (and (setq elt
(car tail
) range
(car elt
)
910 val
(funcall val-func
(nth prop-idx elt
)))
913 (eq second
(nth 1 val
)))
914 (setq block-end range
916 (setq range
(cons start block-end
)
917 val
(if (eq first
'CJK
) 'CJK\ COMPATIBILITY\ IDEOGRAPH
918 'VARIATION\ SELECTOR
))))
922 (let ((slot (assq val block-list
)))
923 (setq range
(cons (car range
) (cdr range
)))
924 (setq block-end
(cdr range
))
926 (nconc slot
(list range
))
927 (push (list val range
) block-list
))))
928 (let* ((start (lsh (lsh range -
7) 7))
929 (limit (+ start
127))
931 (vec (make-vector 128 nil
))
933 (if (<= start block-end
)
934 ;; START overlap with the previous block.
935 (aset table range
(nth prop-idx elt
))
937 (aset vec
(- range start
) val
))
938 (while (and (setq elt
(car tail
) range
(car elt
))
941 (setq val
(funcall val-func
(nth prop-idx elt
)))
943 (aset vec
(- range start
) val
))
944 (setq tail
(cdr tail
)))
945 (setq vec
(unidata-word-list-compress vec
))
947 (dotimes (i (length vec
))
948 (dolist (elt (aref vec i
))
950 (cl-incf (alist-get elt
(cdr word-list
) 0)))))
951 (set-char-table-range table
(cons start limit
) vec
))))))
952 (setq word-list
(sort (cdr word-list
)
953 #'(lambda (x y
) (> (cdr x
) (cdr y
)))))
954 (setq tail word-list idx
0)
956 (setcdr (car tail
) (unidata-encode-word idx
))
957 (setq idx
(1+ idx
) tail
(cdr tail
)))
958 (setq word-table
(make-vector (length word-list
) nil
))
960 (dolist (elt word-list
)
961 (aset word-table idx
(car elt
))
964 (if (and (eq prop
'decomposition
)
966 (error "Too many symbols in decomposition data"))
968 (dotimes (i (/ #x110000
128))
969 (let* ((idx (* i
128))
970 (vec (aref table idx
)))
972 (dotimes (i (length vec
))
973 (let ((tail (aref vec i
))
979 code
(if (integerp elt
) elt
980 (cdr (assq elt word-list
))))
981 (setcar tail
(string code
))
982 (setq tail
(cdr tail
)))
983 (aset vec i
(mapconcat 'identity
(aref vec i
) "")))))
984 (set-char-table-range
985 table
(cons idx
(+ idx
127))
986 (mapconcat 'identity vec
"")))))
988 (setq block-word-table
(make-vector (length block-list
) nil
))
990 (dolist (elt block-list
)
991 (dolist (e (cdr elt
))
992 (set-char-table-range table e
(1+ idx
)))
993 (aset block-word-table idx
(car elt
))
996 (set-char-table-extra-slot table
0 prop
)
997 (set-char-table-extra-slot table
4 (cons word-table block-word-table
))
1000 (defun unidata-split-name (str)
1003 (let ((len (length str
))
1008 ;; Unicode Standard, paragraph 4.8: "For all other
1009 ;; Unicode code points of all other types (Control,
1010 ;; Private-Use, Surrogate, Noncharacter, and Reserved),
1011 ;; the value of the Name property is the null string."
1012 ;; We already handle elsewhere all the characters except
1013 ;; Cc, Control characters, which are handled here.
1014 (string= str
"<control>"))
1017 (setq c
(aref str i
))
1019 (setq l
(cons (intern (substring str idx i
)) l
)
1021 (if (and (= c ?-
) (< idx i
)
1022 (< (1+ i
) len
) (/= (aref str
(1+ i
)) 32))
1023 (setq l
(cons '-
(cons (intern (substring str idx i
)) l
))
1025 (nreverse (cons (intern (substring str idx
)) l
))))))
1027 (defun unidata--ensure-compiled (&rest funcs
)
1029 (or (byte-code-function-p (symbol-function fun
))
1030 (byte-compile fun
))))
1032 (defun unidata-gen-table-name (prop &rest ignore
)
1033 (let* ((table (unidata-gen-table-word-list prop
'unidata-split-name
))
1034 (word-tables (char-table-extra-slot table
4)))
1035 (unidata--ensure-compiled 'unidata-get-name
'unidata-put-name
)
1036 (set-char-table-extra-slot table
1 (symbol-function 'unidata-get-name
))
1037 (set-char-table-extra-slot table
2 (symbol-function 'unidata-put-name
))
1040 (set-char-table-extra-slot table
4
1041 (vector (car word-tables
)
1043 unidata-name-jamo-name-table
))
1044 (set-char-table-extra-slot table
4
1045 (vector (car word-tables
))))
1048 (defun unidata-split-decomposition (str)
1051 (let ((len (length str
))
1058 (setq c
(aref str i
))
1060 (setq l
(if (= (aref str idx
) ?
<)
1061 (cons (intern (substring str
(1+ idx
) (1- i
))) l
)
1062 (cons (string-to-number (substring str idx i
) 16) l
))
1064 (if (= (aref str idx
) ?
<)
1065 (setq l
(cons (intern (substring str
(1+ idx
) (1- len
))) l
))
1066 (setq l
(cons (string-to-number (substring str idx len
) 16) l
)))
1070 (defun unidata-gen-table-decomposition (prop &rest ignore
)
1071 (let* ((table (unidata-gen-table-word-list prop
'unidata-split-decomposition
))
1072 (word-tables (char-table-extra-slot table
4)))
1073 (unidata--ensure-compiled 'unidata-get-decomposition
1074 'unidata-put-decomposition
)
1075 (set-char-table-extra-slot table
1
1076 (symbol-function 'unidata-get-decomposition
))
1077 (set-char-table-extra-slot table
2
1078 (symbol-function 'unidata-put-decomposition
))
1079 (set-char-table-extra-slot table
4 (car word-tables
))
1084 (defun unidata-describe-general-category (val)
1087 (Lu .
"Letter, Uppercase")
1088 (Ll .
"Letter, Lowercase")
1089 (Lt .
"Letter, Titlecase")
1090 (Lm .
"Letter, Modifier")
1091 (Lo .
"Letter, Other")
1092 (Mn .
"Mark, Nonspacing")
1093 (Mc .
"Mark, Spacing Combining")
1094 (Me .
"Mark, Enclosing")
1095 (Nd .
"Number, Decimal Digit")
1096 (Nl .
"Number, Letter")
1097 (No .
"Number, Other")
1098 (Pc .
"Punctuation, Connector")
1099 (Pd .
"Punctuation, Dash")
1100 (Ps .
"Punctuation, Open")
1101 (Pe .
"Punctuation, Close")
1102 (Pi .
"Punctuation, Initial quote")
1103 (Pf .
"Punctuation, Final quote")
1104 (Po .
"Punctuation, Other")
1105 (Sm .
"Symbol, Math")
1106 (Sc .
"Symbol, Currency")
1107 (Sk .
"Symbol, Modifier")
1108 (So .
"Symbol, Other")
1109 (Zs .
"Separator, Space")
1110 (Zl .
"Separator, Line")
1111 (Zp .
"Separator, Paragraph")
1112 (Cc .
"Other, Control")
1113 (Cf .
"Other, Format")
1114 (Cs .
"Other, Surrogate")
1115 (Co .
"Other, Private Use")
1116 (Cn .
"Other, Not Assigned")))))
1118 (defun unidata-describe-canonical-combining-class (val)
1120 '((0 .
"Spacing, split, enclosing, reordrant, and Tibetan subjoined")
1121 (1 .
"Overlays and interior")
1123 (8 .
"Hiragana/Katakana voicing marks")
1125 (10 .
"Start of fixed position classes")
1126 (199 .
"End of fixed position classes")
1127 (200 .
"Below left attached")
1128 (202 .
"Below attached")
1129 (204 .
"Below right attached")
1130 (208 .
"Left attached (reordrant around single base character)")
1131 (210 .
"Right attached")
1132 (212 .
"Above left attached")
1133 (214 .
"Above attached")
1134 (216 .
"Above right attached")
1135 (218 .
"Below left")
1137 (222 .
"Below right")
1138 (224 .
"Left (reordrant around single base character)")
1140 (228 .
"Above left")
1142 (232 .
"Above right")
1143 (233 .
"Double below")
1144 (234 .
"Double above")
1145 (240 .
"Below (iota subscript)")))))
1147 (defun unidata-describe-bidi-class (val)
1149 '((L .
"Left-to-Right")
1150 (LRE .
"Left-to-Right Embedding")
1151 (LRO .
"Left-to-Right Override")
1152 (R .
"Right-to-Left")
1153 (AL .
"Right-to-Left Arabic")
1154 (RLE .
"Right-to-Left Embedding")
1155 (RLO .
"Right-to-Left Override")
1156 (PDF .
"Pop Directional Format")
1157 (LRI .
"Left-to-Right Isolate")
1158 (RLI .
"Right-to-Left Isolate")
1159 (FSI .
"First Strong Isolate")
1160 (PDI .
"Pop Directional Isolate")
1161 (EN .
"European Number")
1162 (ES .
"European Number Separator")
1163 (ET .
"European Number Terminator")
1164 (AN .
"Arabic Number")
1165 (CS .
"Common Number Separator")
1166 (NSM .
"Non-Spacing Mark")
1167 (BN .
"Boundary Neutral")
1168 (B .
"Paragraph Separator")
1169 (S .
"Segment Separator")
1171 (ON .
"Other Neutrals")))))
1173 (defun unidata-describe-decomposition (val)
1176 (if (symbolp x
) (symbol-name x
)
1178 (compose-string (string x
) 0 1 (string ?
\t x ?
\t))
1182 (defun unidata-describe-bidi-bracket-type (val)
1184 '((n .
"Not a paired bracket character.")
1185 (o .
"Opening paired bracket character.")
1186 (c .
"Closing paired bracket character.")))))
1188 (defun unidata-gen-mirroring-list ()
1189 (let ((head (list nil
))
1192 (insert-file-contents (expand-file-name "BidiMirroring.txt" unidata-dir
))
1193 (goto-char (point-min))
1195 (while (re-search-forward "^\\([0-9A-F]+\\);\\s +\\([0-9A-F]+\\)" nil t
)
1196 (let ((char (string-to-number (match-string 1) 16))
1197 (mirror (match-string 2)))
1198 (setq tail
(setcdr tail
(list (list char mirror
)))))))
1201 (defun unidata-gen-brackets-list ()
1202 (let ((head (list nil
))
1205 (insert-file-contents (expand-file-name "BidiBrackets.txt" unidata-dir
))
1206 (goto-char (point-min))
1208 (while (re-search-forward
1209 "^\\([0-9A-F]+\\);\\s +\\([0-9A-F]+\\);\\s +\\([oc]\\)"
1211 (let ((char (string-to-number (match-string 1) 16))
1212 (paired (match-string 2)))
1213 (setq tail
(setcdr tail
(list (list char paired
)))))))
1216 (defun unidata-gen-bracket-type-list ()
1217 (let ((head (list nil
))
1220 (insert-file-contents (expand-file-name "BidiBrackets.txt" unidata-dir
))
1221 (goto-char (point-min))
1223 (while (re-search-forward
1224 "^\\([0-9A-F]+\\);\\s +\\([0-9A-F]+\\);\\s +\\([oc]\\)"
1226 (let ((char (string-to-number (match-string 1) 16))
1227 (type (match-string 3)))
1228 (setq tail
(setcdr tail
(list (list char type
)))))))
1231 ;; Verify if we can retrieve correct values from the generated
1236 ;; (let ((unidata-dir "/path/to/admin/unidata"))
1237 ;; (unidata-setup-list "unidata.txt")
1240 (defun unidata-check ()
1241 (dolist (elt unidata-prop-alist
)
1242 (let* ((prop (car elt
))
1243 (index (unidata-prop-index prop
))
1244 (generator (unidata-prop-generator prop
))
1245 (default-value (unidata-prop-default prop
))
1246 (val-list (unidata-prop-val-list prop
))
1248 (message "Generating %S table..." prop
)
1249 (funcall generator prop default-value val-list
)))
1250 (decoder (char-table-extra-slot table
1))
1251 (alist (and (functionp index
)
1254 (dolist (e unidata-list
)
1255 (let* ((char (car e
))
1257 (if alist
(nth 1 (assoc char alist
))
1260 (if (and (stringp val1
) (= (length val1
) 0))
1262 (unless (or (consp char
)
1265 (cond ((functionp decoder
)
1266 (funcall decoder char
(aref table char
) table
))
1268 (aref table char
))))
1270 (cond ((eq generator
'unidata-gen-table-symbol
)
1271 (setq val1
(intern val1
)))
1272 ((eq generator
'unidata-gen-table-integer
)
1273 (setq val1
(string-to-number val1
)))
1274 ((eq generator
'unidata-gen-table-character
)
1275 (setq val1
(string-to-number val1
16)))
1276 ((eq generator
'unidata-gen-table-decomposition
)
1277 (setq val1
(unidata-split-decomposition val1
))))
1278 (cond ((eq prop
'decomposition
)
1279 (setq val1
(list char
)))
1280 ((eq prop
'bracket-type
)
1282 (when (>= char check
)
1283 (message "%S %04X" prop check
)
1284 (setq check
(+ check
#x400
)))
1285 (or (equal val1 val2
)
1286 ;; <control> characters get a 'name' property of nil
1287 (and (eq prop
'name
) (string= val1
"<control>") (null val2
))
1288 (insert (format "> %04X %S\n< %04X %S\n"
1289 char val1 char val2
)))
1292 ;; The entry function. It generates files described in the header
1293 ;; comment of this file.
1295 ;; Write files (charprop.el, uni-*.el) to dest-dir (default PWD),
1296 ;; using as input files from data-dir, and
1297 ;; unidata-text-file (default "unidata.txt" in PWD).
1298 (defun unidata-gen-files (&optional data-dir dest-dir unidata-text-file
)
1300 (setq data-dir
(pop command-line-args-left
)
1301 dest-dir
(or (pop command-line-args-left
) default-directory
)
1302 unidata-text-file
(or (pop command-line-args-left
)
1303 (expand-file-name "unidata.txt"))))
1304 (let ((coding-system-for-write 'utf-8-unix
)
1305 (charprop-file (expand-file-name "charprop.el" dest-dir
))
1306 (unidata-dir data-dir
))
1307 (dolist (elt unidata-prop-alist
)
1308 (let* ((prop (car elt
))
1309 (file (expand-file-name (unidata-prop-file prop
) dest-dir
)))
1310 (if (file-exists-p file
)
1311 (delete-file file
))))
1312 (unidata-setup-list unidata-text-file
)
1313 (with-temp-file charprop-file
1314 (insert ";; Automatically generated by unidata-gen.el.\n")
1315 (dolist (elt unidata-prop-alist
)
1316 (let* ((prop (car elt
))
1317 (generator (unidata-prop-generator prop
))
1318 (file (expand-file-name (unidata-prop-file prop
) dest-dir
))
1319 (basename (file-name-nondirectory file
))
1320 (docstring (unidata-prop-docstring prop
))
1321 (describer (unidata-prop-describer prop
))
1322 (default-value (unidata-prop-default prop
))
1323 (val-list (unidata-prop-val-list prop
))
1324 ;; Avoid creating backup files for those uni-*.el files
1325 ;; that hold more than one table.
1326 (backup-inhibited t
)
1328 ;; Filename in this comment line is extracted by sed in
1330 (insert (format ";; FILE: %s\n" basename
))
1331 (insert (format "(define-char-code-property '%S %S\n %S)\n"
1332 prop basename docstring
))
1334 (or noninteractive
(message "Generating %s..." file
))
1335 (when (file-exists-p file
)
1336 (insert-file-contents file
)
1337 (goto-char (point-max))
1338 (search-backward ";; Local Variables:"))
1339 (setq table
(funcall generator prop default-value val-list
))
1341 (unless (subrp (symbol-function describer
))
1342 (unidata--ensure-compiled describer
)
1343 (setq describer
(symbol-function describer
)))
1344 (set-char-table-extra-slot table
3 describer
))
1346 (insert ";; Copyright (C) 1991-2014 Unicode, Inc.
1347 ;; This file was generated from the Unicode data files at
1348 ;; http://www.unicode.org/Public/UNIDATA/.
1349 ;; See lisp/international/README for the copyright and permission notice.\n"))
1350 (insert (format "(define-char-code-property '%S\n %S\n %S)\n"
1351 prop table docstring
))
1353 (insert ";; Local Variables:\n"
1354 ";; coding: utf-8\n"
1355 ";; version-control: never\n"
1356 ";; no-byte-compile: t\n"
1357 ";; no-update-autoloads: t\n"
1359 (format ";; %s ends here\n" basename
)))
1361 (or noninteractive
(message "Generating %s...done" file
)))))
1362 (message "Writing %s..." charprop-file
)
1363 (insert ";; Local Variables:\n"
1364 ";; coding: utf-8\n"
1365 ";; version-control: never\n"
1366 ";; no-byte-compile: t\n"
1367 ";; no-update-autoloads: t\n"
1369 (format ";; %s ends here\n"
1370 (file-name-nondirectory charprop-file
))))))
1374 ;;; unidata-gen.el ends here