]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve accuracy of character categories
authorEli Zaretskii <eliz@gnu.org>
Fri, 13 Sep 2024 11:31:28 +0000 (14:31 +0300)
committerEshel Yaron <me@eshelyaron.com>
Sat, 14 Sep 2024 20:29:52 +0000 (22:29 +0200)
* lisp/international/characters.el: Assign 'digit' category to all
the characters whose Unicode 'general-category' is Nd.

* admin/unidata/blocks.awk: Add code to assign 'symbol' category
to all characters belonging to the 'symbol' script.

* etc/NEWS: Announce the above changes

(cherry picked from commit 7376623a244a91d1de5245645b4b3e8c9469d422)

admin/unidata/blocks.awk
etc/NEWS
lisp/international/characters.el

index 6393b7bdc63af976299f4682ee2cda21cebe2151..5126c0d3ff31a50aaef59615a25ddfebf4dbbe35 100755 (executable)
@@ -278,6 +278,10 @@ END {
     print "    (or (memq (nth 2 elt) script-list)"
     print "    (setq script-list (cons (nth 2 elt) script-list))))"
     print "  (set-char-table-extra-slot char-script-table 0 (nreverse script-list)))"
-    print "\n"
-    print "(provide 'charscript)"
+    print "\n(map-char-table"
+    print " (lambda (ch script)"
+    print "   (and (eq script 'symbol)"
+    print "    (modify-category-entry ch ?5)))"
+    print " char-script-table)"
+    print "\n(provide 'charscript)"
 }
index 6beddd6cffa8bd4847dfd6535b7a4d8644e86bb5..9766e30deb72d1141aef7e78d8e4d31b51f28d87 100644 (file)
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -293,6 +293,18 @@ That convention was: '(error &rest ARGS)'.
 ** The 'rx' category name 'chinese-two-byte' must now be spelled correctly.
 An old alternative name (without the first 'e') has been removed.
 
+---
+** All the digit characters now have the 'digit' category.
+All the characters whose Unicode general-category is Nd now have the
+'digit' category, whose mnemonic is '6'.  This includes both ASCII and
+non-ASCII digit characters.
+
+---
+** All the symbol characters now have the 'symbol' category.
+All the characters that belong to the 'symbol' script (according to
+'char-script-table') now have the 'symbol' category, whose mnemonic is
+'5'.
+
 \f
 * Lisp Changes in Emacs 31.1
 
index b13d5f9d7a3374ead6d5adf22f41e50390b12b7c..44293b033c7dac10bffa9999c0d9ec6d9f9bfa19 100644 (file)
@@ -849,6 +849,19 @@ with L, LRE, or LRO Unicode bidi character type.")
   ;; Fixme: syntax for symbols &c
   )
 
+
+;; Symbols and digits
+;;; Each character whose script is 'symbol' gets the symbol category,
+;;; see charscript.el.
+;;; Each character whose Unicode general-category is Nd gets the digit
+;;; category:
+(let ((table (unicode-property-table-internal 'general-category)))
+  (when table
+    (map-char-table (lambda (key val)
+                      (if (eq val 'Nd)
+                         (modify-category-entry key ?6)))
+                   table)))
+
 (let ((pairs
        '("⁅⁆"                              ; U+2045 U+2046
         "⁽⁾"                               ; U+207D U+207E