diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2024-07-08 07:01:27 +0200 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2024-07-08 07:01:27 +0200 |
| commit | ff9e59768793a0994587ea8da9d532c9af1d8f02 (patch) | |
| tree | 9ae33367d20a0dafd8a964031676a57a38084bd7 | |
| parent | e4b7ab33585b0330a3296a2e27555f5aa5ead894 (diff) | |
compat-30: Add char-to-name
| -rw-r--r-- | NEWS.org | 1 | ||||
| -rw-r--r-- | compat-30.el | 9 | ||||
| -rw-r--r-- | compat-tests.el | 3 | ||||
| -rw-r--r-- | compat.texi | 6 |
4 files changed, 19 insertions, 0 deletions
@@ -5,6 +5,7 @@ * Development - compat-28: Mark =subr-native-elisp-p= as obsolete (renamed in Emacs 30). +- compat-30: New function =char-to-name=. - compat-30: New function =obarray-clear=. - compat-30: New function =interpreted-function-p=. - compat-30: New function =primitive-function-p=. diff --git a/compat-30.el b/compat-30.el index 7b2c32b..c41c4a0 100644 --- a/compat-30.el +++ b/compat-30.el @@ -342,5 +342,14 @@ in this case, sorting is always done in-place." (apply #'vector seq)) seq))) +;;;; Defined in mule-cmds.el + +(compat-defun char-to-name (char) ;; <compat-tests:char-to-name> + "Return the Unicode name for CHAR, if it has one, else nil. +Return nil if CHAR is not a character." + (and (characterp char) + (or (get-char-code-property char 'name) + (get-char-code-property char 'old-name)))) + (provide 'compat-30) ;;; compat-30.el ends here diff --git a/compat-tests.el b/compat-tests.el index 19841d8..10d9a9b 100644 --- a/compat-tests.el +++ b/compat-tests.el @@ -1932,6 +1932,9 @@ (should-equal (replace-regexp-in-region " bar" "" (point-min) 8) 1) (should-equal (buffer-string) "foo bar")))) +(ert-deftest compat-char-to-name () + (should-equal (char-to-name ?.) "FULL STOP")) + (ert-deftest compat-char-uppercase-p () (dolist (c (list ?R ?S ?Ω ?Ψ)) (should (char-uppercase-p c))) diff --git a/compat.texi b/compat.texi index 0efb3f7..9501a01 100644 --- a/compat.texi +++ b/compat.texi @@ -3323,6 +3323,12 @@ older than 30.1. Note that due to upstream changes, it might happen that there will be the need for changes, so use these functions with care. +@c copied from lispref/nonascii.texi +@defun char-to-name char +This function returns the Unicode name of @var{char}. It returns +@code{nil} if @var{char} is not a character or has no Unicode name. +@end defun + @c copied from lispref/symbols.texi @defun obarray-clear obarray This function removes all symbols from @var{obarray}. |
