From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.bugs Subject: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case letter Date: Wed, 11 May 2022 16:43:06 +0200 Message-ID: <87fslgnn9h.fsf@gmail.com> References: <87ee27fd1a.fsf@gmail.com> <83bkxaaj45.fsf@gnu.org> <878rs55m81.fsf@gmail.com> <834k2t1cva.fsf@gnu.org> <87ilqdnl8z.fsf@gmail.com> <83bkw4s4ln.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21909"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: 54804@debbugs.gnu.org, uyennhi.qm@gmail.com, spwhitton@spwhitton.name To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Wed May 11 16:44:29 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nonZk-0005Xb-BT for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 11 May 2022 16:44:28 +0200 Original-Received: from localhost ([::1]:53330 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nonZj-00009V-6g for geb-bug-gnu-emacs@m.gmane-mx.org; Wed, 11 May 2022 10:44:27 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48130) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nonZK-000090-Ci for bug-gnu-emacs@gnu.org; Wed, 11 May 2022 10:44:05 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:44181) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nonZK-0000iw-3e for bug-gnu-emacs@gnu.org; Wed, 11 May 2022 10:44:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nonZJ-00050T-Vc for bug-gnu-emacs@gnu.org; Wed, 11 May 2022 10:44:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 11 May 2022 14:44:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54804 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 54804-submit@debbugs.gnu.org id=B54804.165228019719174 (code B ref 54804); Wed, 11 May 2022 14:44:01 +0000 Original-Received: (at 54804) by debbugs.gnu.org; 11 May 2022 14:43:17 +0000 Original-Received: from localhost ([127.0.0.1]:38078 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nonYb-0004zB-5p for submit@debbugs.gnu.org; Wed, 11 May 2022 10:43:17 -0400 Original-Received: from mail-wm1-f51.google.com ([209.85.128.51]:40948) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nonYZ-0004yt-59 for 54804@debbugs.gnu.org; Wed, 11 May 2022 10:43:15 -0400 Original-Received: by mail-wm1-f51.google.com with SMTP id v64-20020a1cac43000000b0038cfd1b3a6dso3370576wme.5 for <54804@debbugs.gnu.org>; Wed, 11 May 2022 07:43:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version:content-transfer-encoding; bh=upv3XSTTi+blyBLGVcJVNbQO2jDf8du7vEBV/j4568k=; b=Mg++I1IkSv5anlwPJF4CTdDdQrnbCwDFCUfLgseSY82f6NIJ+dgdWpNEK90Tbzejln 5T/dR+MhmUiqt3h9DSRhdzdeXot8UH0GO1hozjBuvGYPtEhepJ++IzGiiAaCiA8vKJIa UcZY3Xw30ctngFyq4xzDMxdlYU9T9uP+HArPuhDY/encFRc+mid6EM7mJcUrNq0NoSSw xBRmFmf/4dA1onzxVIoi7jxH8UIKTquwA0x2LACAp2MhDXwsZT4Qdwni479T+hxMHdi4 VWeQj9csWliOxX7LcT1+6TVW5Rat4WUAPiKJgVkrAIbqctv3KXuqqjljdoWsQYsbyTNU HK3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version:content-transfer-encoding; bh=upv3XSTTi+blyBLGVcJVNbQO2jDf8du7vEBV/j4568k=; b=5+3V64O/pYCC7C4OseNHYDCInmOPx1nj6DXJYmJ15ElX9NvHqRMVuZAL39x655ubPC qMBRlSmLkgYuYoxCZAVpoijiOUY8BGwPuep+eICeH7ah8uVWpdT6bA1PnraGkSydvb8P R5MBlgrRdQqqhWdH33KTM3RiwBstjpFRa/JpJvY+zCLCuDgJfpz4G2F6sgXExAU2PXka JkIKnv+zr9tsKKxJ8Ja0AQ6hMSNeTlM/8TQkUNdoG7NhPAfYftQvZaXrH9ulL35Xob/o VKS0aCmqhB25MhSh6SWIrED9P3WNtYL3s05lw/fB5Rv1V+3TuLZHO7uvcsuf/nSvTGq9 RV4w== X-Gm-Message-State: AOAM532U5TtgDYN1FvhkvffLDJ8GXL4GKhVji8kKAQyYtKdZ6Tj9JFUa 4cHt1DwR5VN30m+SsQG50QY= X-Google-Smtp-Source: ABdhPJwpbi34g3oNlH4qmMot9tIJ+emPqBPuSpzo2DkAnGKptA7kxbK1k43Lh2TiP7EXy6xlhRNqGw== X-Received: by 2002:a1c:6a01:0:b0:37f:1b18:6b17 with SMTP id f1-20020a1c6a01000000b0037f1b186b17mr5215060wmc.146.1652280189124; Wed, 11 May 2022 07:43:09 -0700 (PDT) Original-Received: from eprince ([193.118.249.171]) by smtp.gmail.com with ESMTPSA id w17-20020a05600018d100b0020c5253d90asm1905836wrq.86.2022.05.11.07.43.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 May 2022 07:43:08 -0700 (PDT) In-Reply-To: <83bkw4s4ln.fsf@gnu.org> (Eli Zaretskii's message of "Wed, 11 May 2022 14:15:00 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:231943 Archived-At: Eli Zaretskii writes: >> Is it the following implementation OK for such a function? > > Yes, thanks. But please call it char-uppercase-p ("upcase" has the > meaning of making a character upper-case). I'd like to add this `char-uppercase-p'. Once merged, I will finish with the goal of the report. I appreciate a hand with the documentation part. --8<-----------------------------cut here---------------start------------->= 8--- commit aa270a4b8813ac226a61d8e6919f68e9e4ed0973 Author: Tino Calancha Date: Wed May 11 16:34:33 2022 +0200 char-uppercase-p: New predicate =20=20=20=20 Return non-nil if its argument is an upper-case unicode character. =20=20=20=20 Suggested in Bug#54804. =20=20=20=20 * 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. diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi index 9650d22790..1c32458d62 100644 --- a/doc/lispref/display.texi +++ b/doc/lispref/display.texi @@ -2010,6 +2010,14 @@ Size of Displayed Text (@pxref{Usual Display}). @end defun =20 +@defun char-uppercase-p char +This function returns non-nil if @var{char} is an uppercase unicode +character. Be aware that if the Unicode tables are not yet available, +e.g. during bootstrap, then this function gives the right answer only +for @acronym{ASCII} characters; for other characters the function +unconditionally returns @code{nil}. +@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. diff --git a/etc/NEWS b/etc/NEWS index 991088a067..57c254bce8 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -1794,6 +1794,10 @@ value. The byte compiler will now issue a warning i= f it encounters these forms. =20 =20 ++++ +*** The new predicate 'char-uppercase-p' returns non-nil if its +argument its an uppercase unicode character. + +++ *** 'restore-buffer-modified-p' can now alter buffer auto-save state. With a FLAG value of 'autosaved', it will mark the buffer as having diff --git a/lisp/simple.el b/lisp/simple.el index 89fb0ea97e..525e636ab6 100644 --- a/lisp/simple.el +++ b/lisp/simple.el @@ -6054,6 +6054,14 @@ backward-delete-char-untabify ;; Avoid warning about delete-backward-char (with-no-warnings (delete-backward-char n killp)))) =20 +(defun char-uppercase-p (char) + "Return non-nil if CHAR is an upper-case unicode character. +If the Unicode tables are not yet available, e.g. during bootstrap, +then the function restricts to the ASCII character set." + (cond ((unicode-property-table-internal 'lowercase) + (characterp (get-char-code-property char 'lowercase))) + ((and (>=3D char ?A) (<=3D 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. diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el index 89803e5ce2..a25eb363b0 100644 --- a/test/lisp/subr-tests.el +++ b/test/lisp/subr-tests.el @@ -1074,5 +1074,12 @@ test-local-set-state (should (=3D subr-test--local 2)) (should-not (boundp 'subr-test--unexist))))) =20 +(ert-deftest test-char-uppercase-p () + "Tests for `char-uppercase-p'." + (dolist (c (list ?R ?S ?=CE=A9 ?=CE=A8)) + (should (char-uppercase-p c))) + (dolist (c (list ?a ?b ?=CE=B1 ?=CE=B2)) + (should-not (char-uppercase-p c)))) + (provide 'subr-tests) ;;; subr-tests.el ends here --8<-----------------------------cut here---------------end--------------->= 8---