Return non-nil if its argument is an uppercase character.
Suggested in Bug#54804.
* lisp/subr.el (char-uppercase-p): New defun.
* etc/NEWS (Lisp Changes in Emacs 29.1): Announce it
* doc/lispref/display.texi (Size of Displayed Text): Document it.
* test/lisp/subr-tests.el (test-char-uppercase-p): Add a test.
(@pxref{Usual Display}).
@end defun
+@defun char-uppercase-p char
+Return non-@code{nil} if @var{char} is an uppercase character
+according to Unicode.
+@end defun
+
@defun string-width string &optional from to
This function returns the width in columns of the string @var{string},
if it were displayed in the current buffer and the selected window.
\f
* Lisp Changes in Emacs 29.1
++++
+** New predicate 'char-uppercase-p'.
+This returns non-nil if its argument its an uppercase character.
+
** Byte compilation
---
value. The byte compiler will now issue a warning if it encounters
these forms.
-
+++
*** 'restore-buffer-modified-p' can now alter buffer auto-save state.
With a FLAG value of 'autosaved', it will mark the buffer as having
;; Avoid warning about delete-backward-char
(with-no-warnings (delete-backward-char n killp))))
+(defun char-uppercase-p (char)
+ "Return non-nil if CHAR is an upper-case character.
+If the Unicode tables are not yet available, e.g. during bootstrap,
+then gives correct answers only for ASCII characters."
+ (cond ((unicode-property-table-internal 'lowercase)
+ (characterp (get-char-code-property char 'lowercase)))
+ ((and (>= char ?A) (<= char ?Z)))))
+
(defun zap-to-char (arg char)
"Kill up to and including ARGth occurrence of CHAR.
Case is ignored if `case-fold-search' is non-nil in the current buffer.
(should (= subr-test--local 2))
(should-not (boundp 'subr-test--unexist)))))
+(ert-deftest test-char-uppercase-p ()
+ "Tests for `char-uppercase-p'."
+ (dolist (c (list ?R ?S ?Ω ?Ψ))
+ (should (char-uppercase-p c)))
+ (dolist (c (list ?a ?b ?α ?β))
+ (should-not (char-uppercase-p c))))
+
(provide 'subr-tests)
;;; subr-tests.el ends here