diff options
Diffstat (limited to 'admin/unidata/unidata-gen.el')
-rw-r--r-- | admin/unidata/unidata-gen.el | 77 |
1 files changed, 68 insertions, 9 deletions
diff --git a/admin/unidata/unidata-gen.el b/admin/unidata/unidata-gen.el index fb9b6dccc72..d10b260b470 100644 --- a/admin/unidata/unidata-gen.el +++ b/admin/unidata/unidata-gen.el @@ -88,6 +88,8 @@ ;; CHAR-or-RANGE: a character code or a cons of character codes ;; PROPn: string representing the nth property value +(eval-when-compile (require 'cl-lib)) + (defvar unidata-list nil) ;; Name of the directory containing files of Unicode Character Database. @@ -152,7 +154,8 @@ ;; PROP: character property ;; INDEX: index to each element of unidata-list for PROP. ;; It may be a function that generates an alist of character codes -;; vs. the corresponding property values. +;; vs. the corresponding property values. Currently, only character +;; codepoints or symbol values are supported in this case. ;; GENERATOR: function to generate a char-table ;; FILENAME: filename to store the char-table ;; DOCSTRING: docstring for the property @@ -271,7 +274,23 @@ is the character itself." "Unicode bidi-mirroring characters. Property value is a character that has the corresponding mirroring image or nil. The value nil means that the actual property value of a character -is the character itself."))) +is the character itself.") + (paired-bracket + unidata-gen-brackets-list unidata-gen-table-character "uni-brackets.el" + "Unicode bidi paired-bracket characters. +Property value is the paired bracket character, or nil. +The value nil means that the character is neither an opening nor +a closing paired bracket." + string) + (bracket-type + unidata-gen-bracket-type-list unidata-gen-table-symbol "uni-brackets.el" + "Unicode bidi paired-bracket type. +Property value is a symbol `o' (Open), `c' (Close), or `n' (None)." + unidata-describe-bidi-bracket-type + n + ;; The order of elements must be in sync with bidi_bracket_type_t + ;; in src/dispextern.h. + (n o c)))) ;; Functions to access the above data. (defsubst unidata-prop-index (prop) (nth 1 (assq prop unidata-prop-alist))) @@ -449,7 +468,10 @@ is the character itself."))) (unidata-encode-val val-list (nth 2 elm))) (set-char-table-range table (cons (car elm) (nth 1 elm)) (nth 2 elm))) - (setq tail unidata-list) + (if (functionp prop-idx) + (setq tail (funcall prop-idx) + prop-idx 1) + (setq tail unidata-list)) (while tail (setq elt (car tail) tail (cdr tail)) (setq range (car elt) @@ -923,11 +945,7 @@ is the character itself."))) (dotimes (i (length vec)) (dolist (elt (aref vec i)) (if (symbolp elt) - (let ((slot (assq elt word-list))) - (if slot - (setcdr slot (1+ (cdr slot))) - (setcdr word-list - (cons (cons elt 1) (cdr word-list)))))))) + (cl-incf (alist-get elt (cdr word-list) 0))))) (set-char-table-range table (cons start limit) vec)))))) (setq word-list (sort (cdr word-list) #'(lambda (x y) (> (cdr x) (cdr y))))) @@ -1159,6 +1177,12 @@ is the character itself."))) (string ?')))) val " ")) +(defun unidata-describe-bidi-bracket-type (val) + (cdr (assq val + '((n . "Not a paired bracket character.") + (o . "Opening paired bracket character.") + (c . "Closing paired bracket character."))))) + (defun unidata-gen-mirroring-list () (let ((head (list nil)) tail) @@ -1172,6 +1196,36 @@ is the character itself."))) (setq tail (setcdr tail (list (list char mirror))))))) (cdr head))) +(defun unidata-gen-brackets-list () + (let ((head (list nil)) + tail) + (with-temp-buffer + (insert-file-contents (expand-file-name "BidiBrackets.txt" unidata-dir)) + (goto-char (point-min)) + (setq tail head) + (while (re-search-forward + "^\\([0-9A-F]+\\);\\s +\\([0-9A-F]+\\);\\s +\\([oc]\\)" + nil t) + (let ((char (string-to-number (match-string 1) 16)) + (paired (match-string 2))) + (setq tail (setcdr tail (list (list char paired))))))) + (cdr head))) + +(defun unidata-gen-bracket-type-list () + (let ((head (list nil)) + tail) + (with-temp-buffer + (insert-file-contents (expand-file-name "BidiBrackets.txt" unidata-dir)) + (goto-char (point-min)) + (setq tail head) + (while (re-search-forward + "^\\([0-9A-F]+\\);\\s +\\([0-9A-F]+\\);\\s +\\([oc]\\)" + nil t) + (let ((char (string-to-number (match-string 1) 16)) + (type (match-string 3))) + (setq tail (setcdr tail (list (list char type))))))) + (cdr head))) + ;; Verify if we can retrieve correct values from the generated ;; char-tables. ;; @@ -1220,7 +1274,9 @@ is the character itself."))) ((eq generator 'unidata-gen-table-decomposition) (setq val1 (unidata-split-decomposition val1)))) (cond ((eq prop 'decomposition) - (setq val1 (list char))))) + (setq val1 (list char))) + ((eq prop 'bracket-type) + (setq val1 'n)))) (when (>= char check) (message "%S %04X" prop check) (setq check (+ check #x400))) @@ -1263,6 +1319,9 @@ is the character itself."))) (describer (unidata-prop-describer prop)) (default-value (unidata-prop-default prop)) (val-list (unidata-prop-val-list prop)) + ;; Avoid creating backup files for those uni-*.el files + ;; that hold more than one table. + (backup-inhibited t) table) ;; Filename in this comment line is extracted by sed in ;; Makefile. |