diff options
| author | Daniel Mendler <mail@daniel-mendler.de> | 2025-11-04 15:28:27 +0100 |
|---|---|---|
| committer | Daniel Mendler <mail@daniel-mendler.de> | 2025-11-04 15:28:27 +0100 |
| commit | dc32703ba1dd0e0c9b135e2e3f463cde5a8c2f70 (patch) | |
| tree | 539bfba2163023ce58d14ca6b411fdad05091617 | |
| parent | 867ba4cd8825aac7b1bbee5d17146893db0051ce (diff) | |
| parent | ad6a2b82f7bc2ea698b9684501963dfa71ffdc27 (diff) | |
Merge branch 'main' into emacs-31
| -rw-r--r-- | NEWS.org | 6 | ||||
| -rw-r--r-- | compat-29.el | 24 | ||||
| -rw-r--r-- | compat-tests.el | 6 | ||||
| -rw-r--r-- | compat.texi | 15 |
4 files changed, 50 insertions, 1 deletions
@@ -2,7 +2,7 @@ #+link: compat-gh https://github.com/emacs-compat/compat/issues/ #+options: toc:nil num:nil author:nil -* Development +* Development (emacs-31 branch) - compat-28: New pcase pattern =cl-type=. - compat-31: New macros =static-when= and =static-unless=. @@ -21,6 +21,10 @@ - Drop support for Emacs 24.x. Emacs 25.1 is required now. In case Emacs 24.x support is still needed, Compat 30 can be used. +* Development + +- compat-29: Add =string-glyph-compose= and =string-glyph-decompose=. + * Release of "Compat" Version 30.1.0.1 - compat-28: Fix =named-let= tail recursion. diff --git a/compat-29.el b/compat-29.el index b6ab5f0..a2947dc 100644 --- a/compat-29.el +++ b/compat-29.el @@ -609,6 +609,30 @@ The variable list SPEC is the same as in `if-let*'." ,@body) (throw ',done nil)))))) +;;;; Defined in ucs-normalize.el + +(compat-defun string-glyph-compose (string) ;; <compat-tests:string-glyph-compose> + "Compose STRING according to the Unicode NFC. +This returns a new string obtained by canonical decomposition +of STRING (see `ucs-normalize-NFC-string') followed by canonical +composition, a.k.a. the \"Unicode Normalization Form C\" of STRING. +For instance: + + (string-glyph-compose \"Å\") => \"Å\"" + (unless (fboundp 'ucs-normalize-NFC-string) + (require 'ucs-normalize)) + (ucs-normalize-NFC-string string)) + +(compat-defun string-glyph-decompose (string) ;; <compat-tests:string-glyph-decompose> + "Decompose STRING according to the Unicode NFD. +This returns a new string that is the canonical decomposition of STRING, +a.k.a. the \"Unicode Normalization Form D\" of STRING. For instance: + + (ucs-normalize-NFD-string \"Å\") => \"Å\"" + (unless (fboundp 'ucs-normalize-NFD-string) + (require 'ucs-normalize)) + (ucs-normalize-NFD-string string)) + ;;;; Defined in files.el (compat-defun directory-abbrev-make-regexp (directory) ;; <compat-tests:directory-abbrev-make-regexp> diff --git a/compat-tests.el b/compat-tests.el index 5272576..0256c4d 100644 --- a/compat-tests.el +++ b/compat-tests.el @@ -1905,6 +1905,12 @@ (should-equal '("a" "b" "c") (split-string "a b c")) (should-equal '("a" "b" "c") (string-split "a b c"))) +(ert-deftest compat-string-glyph-decompose () + (should-equal 10 (length (string-to-list (string-glyph-decompose "àèìòù"))))) + +(ert-deftest compat-string-glyph-compose () + (should-equal "àèìòù" (string-glyph-compose (string-glyph-decompose "àèìòù")))) + (ert-deftest compat-string-equal-ignore-case () (should (string-equal-ignore-case "abc" "abc")) (should (string-equal-ignore-case "abc" "ABC")) diff --git a/compat.texi b/compat.texi index a01b250..d72f42f 100644 --- a/compat.texi +++ b/compat.texi @@ -2415,6 +2415,21 @@ you can say: @xref{Size of Displayed Text,,,elisp}. @end defun +@c copied from lisp/international/ucs-normalize.el +@defun string-glyph-compose string +Compose @var{string} according to the Unicode NFC. This returns a new +string obtained by canonical decomposition of @var{string} followed by +canonical composition, a.k.a. the "Unicode Normalization Form C" of +@var{string}. +@end defun + +@c copied from lisp/international/ucs-normalize.el +@defun string-glyph-decompose string +Decompose @var{string} according to the Unicode NFD. This returns a +new string that is the canonical decomposition of @var{string}, +a.k.a. the "Unicode Normalization Form D" of @var{string}. +@end defun + @c based on lisp/emacs-lisp/subr-x.el @defmac with-buffer-unmodified-if-unchanged &rest body@dots{} Evaluate @var{body} like @code{progn}, but change buffer-modified |
