]> code.delx.au - gnu-emacs/blobdiff - admin/unidata/unidata-gen.el
Update copyright year to 2015
[gnu-emacs] / admin / unidata / unidata-gen.el
index ec4f9d154d28b7b1e7110f4a6d2f2439db3b7510..ca3bae1070a2c8a12368a99d2e2b9a4cc8389e39 100644 (file)
@@ -1,6 +1,6 @@
 ;; unidata-gen.el -- Create files containing character property data.
 
-;; Copyright (C) 2008-2014 Free Software Foundation, Inc.
+;; Copyright (C) 2008-2015 Free Software Foundation, Inc.
 
 ;; Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011
 ;;   National Institute of Advanced Industrial Science and Technology (AIST)
 ;; 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
@@ -273,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)))
@@ -451,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)
@@ -1157,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)
@@ -1170,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.
 ;;
@@ -1218,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)))
@@ -1261,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.