emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/compat ff9e597687: compat-30: Add char-to-name


From: ELPA Syncer
Subject: [elpa] externals/compat ff9e597687: compat-30: Add char-to-name
Date: Mon, 8 Jul 2024 03:57:43 -0400 (EDT)

branch: externals/compat
commit ff9e59768793a0994587ea8da9d532c9af1d8f02
Author: Daniel Mendler <mail@daniel-mendler.de>
Commit: Daniel Mendler <mail@daniel-mendler.de>

    compat-30: Add char-to-name
---
 NEWS.org        | 1 +
 compat-30.el    | 9 +++++++++
 compat-tests.el | 3 +++
 compat.texi     | 6 ++++++
 4 files changed, 19 insertions(+)

diff --git a/NEWS.org b/NEWS.org
index e3d008573e..4ac1babc2c 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -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 7b2c32be88..c41c4a0163 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 19841d8cd3..10d9a9b981 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 0efb3f759e..9501a0169f 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}.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]