emacs-diffs
[Top][All Lists]
Advanced

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

master dcfe3314cd: Teach 'max-char' about the Unicode code range


From: Eli Zaretskii
Subject: master dcfe3314cd: Teach 'max-char' about the Unicode code range
Date: Sat, 3 Sep 2022 06:47:33 -0400 (EDT)

branch: master
commit dcfe3314cd78e95d992fe00f757ce906d49586cd
Author: Eli Zaretskii <eliz@gnu.org>
Commit: Eli Zaretskii <eliz@gnu.org>

    Teach 'max-char' about the Unicode code range
    
    * src/character.c (Fmax_char): Accept an optional argument
    UNICODE, and, if non-nil, return the maximum codepoint defined by
    Unicode.
    
    * lisp/emacs-lisp/comp.el (comp-known-type-specifiers): Update the
    signature of 'max-char'.
    
    * etc/NEWS:
    * doc/lispref/nonascii.texi (Character Codes): Update the
    documentation of 'max-char'.
---
 doc/lispref/nonascii.texi |  7 +++++--
 etc/NEWS                  |  6 ++++++
 lisp/emacs-lisp/comp.el   |  2 +-
 src/character.c           | 10 ++++++----
 4 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/doc/lispref/nonascii.texi b/doc/lispref/nonascii.texi
index 6dc23637a7..71fee45c4a 100644
--- a/doc/lispref/nonascii.texi
+++ b/doc/lispref/nonascii.texi
@@ -404,9 +404,12 @@ This returns @code{t} if @var{charcode} is a valid 
character, and
 
 @cindex maximum value of character codepoint
 @cindex codepoint, largest value
-@defun max-char
+@defun max-char &optional unicode
 This function returns the largest value that a valid character
-codepoint can have.
+codepoint can have in Emacs.  If the optional argument @var{unicode}
+is non-@code{nil}, it returns the largest character codepoint defined
+by the Unicode Standard (which is smaller than the maximum codepoint
+supported by Emacs).
 
 @example
 @group
diff --git a/etc/NEWS b/etc/NEWS
index 8269d3e7bf..cc4714e71c 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -2789,6 +2789,12 @@ request the name of the ".eln" file which defined a 
given symbol.
 +++
 ** New macro 'with-memoization' provides a very primitive form of memoization.
 
++++
+** 'max-char' can now report the maximum codepoint according to Unicode.
+When called with a new optional argument UNICODE non-nil, 'max-char'
+will now report the maximum valid codepoint defined by the Unicode
+Standard.
+
 ** Themes
 
 ---
diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el
index e10443588e..306ec918b1 100644
--- a/lisp/emacs-lisp/comp.el
+++ b/lisp/emacs-lisp/comp.el
@@ -462,7 +462,7 @@ Useful to hook into pass checkers.")
     (marker-buffer (function (marker) (or buffer null)))
     (markerp (function (t) boolean))
     (max (function ((or number marker) &rest (or number marker)) number))
-    (max-char (function () fixnum))
+    (max-char (function (&optional t) fixnum))
     (member (function (t list) list))
     (memory-limit (function () integer))
     (memq (function (t list) list))
diff --git a/src/character.c b/src/character.c
index 968daccafa..dc21649b22 100644
--- a/src/character.c
+++ b/src/character.c
@@ -178,12 +178,14 @@ usage: (characterp OBJECT)  */
   return (CHARACTERP (object) ? Qt : Qnil);
 }
 
-DEFUN ("max-char", Fmax_char, Smax_char, 0, 0, 0,
-       doc: /* Return the character of the maximum code.  */
+DEFUN ("max-char", Fmax_char, Smax_char, 0, 1, 0,
+       doc: /* Return the maximum character code.
+If UNICODE is non-nil, return the maximum character code defined
+by the Unicode Standard.  */
        attributes: const)
-  (void)
+  (Lisp_Object unicode)
 {
-  return make_fixnum (MAX_CHAR);
+  return unicode ? make_fixnum (MAX_UNICODE_CHAR) : make_fixnum (MAX_CHAR);
 }
 
 DEFUN ("unibyte-char-to-multibyte", Funibyte_char_to_multibyte,



reply via email to

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