summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2022-09-03 13:45:53 +0300
committerEli Zaretskii <eliz@gnu.org>2022-09-03 13:45:53 +0300
commitdcfe3314cd78e95d992fe00f757ce906d49586cd (patch)
treea3b1a37f04592b6db2dd696f3a5df3be6ccb2676
parentdb2f8b8415b538ccb43f11a2142567ec6c5451d9 (diff)
downloademacs-dcfe3314cd78e95d992fe00f757ce906d49586cd.tar.gz
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'.
-rw-r--r--doc/lispref/nonascii.texi7
-rw-r--r--etc/NEWS6
-rw-r--r--lisp/emacs-lisp/comp.el2
-rw-r--r--src/character.c10
4 files changed, 18 insertions, 7 deletions
diff --git a/doc/lispref/nonascii.texi b/doc/lispref/nonascii.texi
index 6dc23637a79..71fee45c4a5 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 8269d3e7bf3..cc4714e71ce 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 e10443588e4..306ec918b1a 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 968daccafa7..dc21649b226 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,