GNU bug report logs - #54804
29.0.50; zap-to-char: case sensitive for upper-case letter

Previous Next

Package: emacs;

Reported by: Tino Calancha <tino.calancha <at> gmail.com>

Date: Fri, 8 Apr 2022 22:05:01 UTC

Severity: wishlist

Tags: patch

Found in version 29.0.50

Done: Tino Calancha <tino.calancha <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 54804 in the body.
You can then email your comments to 54804 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to uyennhi.qm <at> gmail.com, bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Fri, 08 Apr 2022 22:05:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tino Calancha <tino.calancha <at> gmail.com>:
New bug report received and forwarded. Copy sent to uyennhi.qm <at> gmail.com, bug-gnu-emacs <at> gnu.org. (Fri, 08 Apr 2022 22:05:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 29.0.50; zap-to-char: case sensitive for upper-case letter
Date: Sat, 09 Apr 2022 00:03:45 +0200
X-Debbugs-Cc: uyennhi.qm <at> gmail.com
Severity: wishlist
Tags: patch

A wishlist for the `zap-to-char' and `zap-up-to-char':
In interactive calls, when users input an upper-case letter then perform
a case-sensitive search.

This behavior is analog to what `isearch' does.


--8<-----------------------------cut here---------------start------------->8---
commit c55557d6eb83ac1fe3aa678cae080df979922f7c
Author: Tino Calancha <tino.calancha <at> gmail.com>
Date:   Fri Apr 8 23:00:18 2022 +0200

    zap-to-char: case sensitive for upper-case letter
    
    In interactive calls, perform a case sensitive search when the given
    char is an upper-case letter.  Same for zap-up-to-char.
    
    This is analog to what the user-level incremental search feature does.
    
    * lisp/misc.el (zap-up-to-char): Delete it.
    * lisp/simple.el (zap--to-char-region): Add helper function.
    (zap-to-char, zap-up-to-char): Add the optional argument INTERACTIVE.
    Do a case-sensitive search when CHAR is an upper-case letter and
    INTERACTIVE is non-nil.
    
    * etc/NEWS (Editing Changes in Emacs 29.1): Announce this change.
    * test/lisp/misc-tests.el (misc-test-zap-up-to-char): Delete it.
    * test/lisp/simple-tests.el (with-simple-test): Add helper macro.
    (simple-tests-zap-to-char, simple-tests-zap-up-to-char): Add tests.

diff --git a/etc/NEWS b/etc/NEWS
index 2fac893cc5..5fb9f14366 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -501,6 +501,11 @@ are met.  The conditions are given by the argument, which can be
 
 * Editing Changes in Emacs 29.1
 
+---
+** 'zap-to-char' performs a case-sensitive search in interactive calls
+when the input character is an upper-case letter.  Likewise, for
+'zap-up-to-char'.
+
 ---
 ** Indentation of 'cl-flet' and 'cl-labels' has changed.
 These forms now indent like this:
diff --git a/lisp/misc.el b/lisp/misc.el
index d85f889ffd..389b1a6ef5 100644
--- a/lisp/misc.el
+++ b/lisp/misc.el
@@ -61,25 +61,6 @@ copy-from-above-command
 				 (+ n (point)))))))
     (insert string)))
 
-;; Variation of `zap-to-char'.
-
-;;;###autoload
-(defun zap-up-to-char (arg char)
-  "Kill up to, but not including ARGth occurrence of CHAR.
-Case is ignored if `case-fold-search' is non-nil in the current buffer.
-Goes backward if ARG is negative; error if CHAR not found.
-Ignores CHAR at point."
-  (interactive (list (prefix-numeric-value current-prefix-arg)
-		     (read-char-from-minibuffer "Zap up to char: "
-						nil 'read-char-history)))
-  (let ((direction (if (>= arg 0) 1 -1)))
-    (kill-region (point)
-		 (progn
-		   (forward-char direction)
-		   (unwind-protect
-		       (search-forward (char-to-string char) nil nil arg)
-		     (backward-char direction))
-		   (point)))))
 
 ;; These were added with an eye to making possible a more CCA-compatible
 ;; command set; but that turned out not to be interesting.
diff --git a/lisp/simple.el b/lisp/simple.el
index eb65701803..50aed97680 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -6031,21 +6031,61 @@ backward-delete-char-untabify
     ;; Avoid warning about delete-backward-char
     (with-no-warnings (delete-backward-char n killp))))
 
-(defun zap-to-char (arg char)
+(defun zap--to-char-region (arg char up-to interactive)
+  "Return the region to kill with `zap-to-char'.
+
+Helper function for `zap-to-char' and `zap-up-to-char'.
+If UP-TO is non-nil then implement the later, otherwise the former.
+The rest of the arguments are described in the commands."
+  (with-no-warnings
+    (when (char-table-p translation-table-for-input)
+      (setq char (or (aref translation-table-for-input char) char))))
+  (let* ((str (char-to-string char))
+         (upper-case (let (case-fold-search)
+                       (string-match-p "[[:upper:]]" str)))
+         (case-fold-search (if (and interactive upper-case)
+                               nil
+                             case-fold-search)))
+    (list (point) (if up-to (let ((direction (if (>= arg 0) 1 -1)))
+		              (forward-char direction)
+		              (unwind-protect
+		                  (search-forward str nil nil arg)
+		                (backward-char direction))
+		              (point))
+		    (search-forward str nil nil arg)
+		    (point)))))
+
+(defun zap-to-char (arg char &optional interactive)
   "Kill up to and including ARGth occurrence of CHAR.
+Optional argument INTERACTIVE tells the function to behave as when
+it's called interactively.
 Case is ignored if `case-fold-search' is non-nil in the current buffer.
 Goes backward if ARG is negative; error if CHAR not found.
+Called interactively, do a case sensitive search if the char is an
+upper case letter.
 See also `zap-up-to-char'."
   (interactive (list (prefix-numeric-value current-prefix-arg)
 		     (read-char-from-minibuffer "Zap to char: "
-						nil 'read-char-history)))
-  ;; Avoid "obsolete" warnings for translation-table-for-input.
-  (with-no-warnings
-    (if (char-table-p translation-table-for-input)
-	(setq char (or (aref translation-table-for-input char) char))))
-  (kill-region (point) (progn
-			 (search-forward (char-to-string char) nil nil arg)
-			 (point))))
+						nil 'read-char-history)
+                     t))
+  (pcase-let ((`(,start ,end) (zap--to-char-region arg char nil interactive)))
+    (kill-region start end)))
+
+(defun zap-up-to-char (arg char &optional interactive)
+  "Kill up to, but not including ARGth occurrence of CHAR.
+Optional argument INTERACTIVE tells the function to behave as when
+it's called interactively.
+Case is ignored if `case-fold-search' is non-nil in the current buffer.
+Goes backward if ARG is negative; error if CHAR not found.
+Called interactively, do a case sensitive search if the char is an
+upper case letter.
+Ignores CHAR at point."
+  (interactive (list (prefix-numeric-value current-prefix-arg)
+		     (read-char-from-minibuffer "Zap up to char: "
+						nil 'read-char-history)
+                     t))
+  (pcase-let ((`(,start ,end) (zap--to-char-region arg char 'up-to interactive)))
+    (kill-region start end)))
 
 ;; kill-line and its subroutines.
 
diff --git a/test/lisp/misc-tests.el b/test/lisp/misc-tests.el
index 36a8726b88..bec786c8c7 100644
--- a/test/lisp/misc-tests.el
+++ b/test/lisp/misc-tests.el
@@ -38,14 +38,6 @@ misc-test-copy-from-above-command
   (with-misc-test "abc\n" "abc\nab"
     (copy-from-above-command 2)))
 
-(ert-deftest misc-test-zap-up-to-char ()
-  (with-misc-test "abcde" "cde"
-    (goto-char (point-min))
-    (zap-up-to-char 1 ?c))
-  (with-misc-test "abcde abc123" "c123"
-    (goto-char (point-min))
-    (zap-up-to-char 2 ?c)))
-
 (ert-deftest misc-test-upcase-char ()
   (with-misc-test "abcde" "aBCDe"
     (goto-char (1+ (point-min)))
diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el
index 6350bebeee..b26a4e4b83 100644
--- a/test/lisp/simple-tests.el
+++ b/test/lisp/simple-tests.el
@@ -971,5 +971,43 @@ test-undo-region
     ;;(should (= (length (delq nil (undo-make-selective-list 5 9))) 0))
     (should (= (length (delq nil (undo-make-selective-list 6 9))) 0))))
 
+(defmacro with-simple-test (original result &rest body)
+  (declare (indent 2) (debug (stringp stringp body)))
+  `(with-temp-buffer
+     (insert ,original)
+     ,@body
+     (should (equal (buffer-string) ,result))))
+
+(ert-deftest simple-tests-zap-to-char ()
+  (with-simple-test "abcde" "de"
+    (goto-char (point-min))
+    (zap-to-char 1 ?c))
+  (with-simple-test "abcde abc123" "123"
+    (goto-char (point-min))
+    (zap-to-char 2 ?c))
+  (let ((case-fold-search t))
+    (with-simple-test "abcdeCXYZ" "deCXYZ"
+      (goto-char (point-min))
+      (zap-to-char 1 ?C))
+    (with-simple-test "abcdeCXYZ" "XYZ"
+      (goto-char (point-min))
+      (zap-to-char 1 ?C 'interactive))))
+
+(ert-deftest simple-tests-zap-up-to-char ()
+  (with-simple-test "abcde" "cde"
+    (goto-char (point-min))
+    (zap-up-to-char 1 ?c))
+  (with-simple-test "abcde abc123" "c123"
+    (goto-char (point-min))
+    (zap-up-to-char 2 ?c))
+  (let ((case-fold-search t))
+    (with-simple-test "abcdeCXYZ" "cdeCXYZ"
+      (goto-char (point-min))
+      (zap-up-to-char 1 ?C))
+    (with-simple-test "abcdeCXYZ" "CXYZ"
+      (goto-char (point-min))
+      (zap-up-to-char 1 ?C 'interactive))))
+
+
 (provide 'simple-test)
 ;;; simple-tests.el ends here
--8<-----------------------------cut here---------------end--------------->8---

In GNU Emacs 29.0.50 (build 1, x86_64-pc-linux-gnu, X toolkit, cairo version 1.16.0, Xaw scroll bars)
 of 2022-04-08 built
Repository revision: 022a1f48a4e2005be7aa66b67eb2f17f8386c853
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: Debian GNU/Linux 11 (bullseye)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Sat, 09 Apr 2022 06:04:01 GMT) Full text and rfc822 format available.

Message #8 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 54804 <at> debbugs.gnu.org, uyennhi.qm <at> gmail.com
Subject: Re: bug#54804: 29.0.50;
 zap-to-char: case sensitive for upper-case letter
Date: Sat, 09 Apr 2022 09:03:38 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Date: Sat, 09 Apr 2022 00:03:45 +0200
> Cc: uyennhi.qm <at> gmail.com
> 
> A wishlist for the `zap-to-char' and `zap-up-to-char':
> In interactive calls, when users input an upper-case letter then perform
> a case-sensitive search.
> 
> This behavior is analog to what `isearch' does.

Thanks, but why does the implementation have to be so complicated?
Isn't this just about turning off case-fold-search while searching for
the character?  What am I missing?




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Sat, 16 Apr 2022 10:59:01 GMT) Full text and rfc822 format available.

Message #11 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 54804 <at> debbugs.gnu.org, uyennhi.qm <at> gmail.com
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Sat, 16 Apr 2022 12:58:06 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> A wishlist for the `zap-to-char' and `zap-up-to-char':
>> In interactive calls, when users input an upper-case letter then perform
>> a case-sensitive search.
>> 
>> This behavior is analog to what `isearch' does.
>
> but why does the implementation have to be so complicated?
> Isn't this just about turning off case-fold-search while searching for
> the character?  What am I missing?

The patch is moving the shared code in zap-to/zap-up-to in a
helper function.  This has 2 motivations:
- reduce the code duplication.
- define these two related functions close each other.
- separate the logic of the function to calculate the region to kill.

If you prefer, we can keep the functions in their current
locations (simple.el/misc.el) with a patch like this one:

--8<-----------------------------cut here---------------start------------->8---
diff --git a/lisp/misc.el b/lisp/misc.el
index d85f889ffd..e771d2b315 100644
--- a/lisp/misc.el
+++ b/lisp/misc.el
@@ -64,20 +64,32 @@ copy-from-above-command
 ;; Variation of `zap-to-char'.
 
 ;;;###autoload
-(defun zap-up-to-char (arg char)
+(defun zap-up-to-char (arg char &optional interactive)
   "Kill up to, but not including ARGth occurrence of CHAR.
 Case is ignored if `case-fold-search' is non-nil in the current buffer.
 Goes backward if ARG is negative; error if CHAR not found.
-Ignores CHAR at point."
+Ignores CHAR at point.
+Called interactively, do a case sensitive search if the char is an
+upper case letter."
   (interactive (list (prefix-numeric-value current-prefix-arg)
 		     (read-char-from-minibuffer "Zap up to char: "
-						nil 'read-char-history)))
-  (let ((direction (if (>= arg 0) 1 -1)))
+						nil 'read-char-history)
+                     t))
+  ;; Avoid "obsolete" warnings for translation-table-for-input.
+  (with-no-warnings
+    (if (char-table-p translation-table-for-input)
+	(setq char (or (aref translation-table-for-input char) char))))
+  (let* ((direction (if (>= arg 0) 1 -1))
+         (str (char-to-string char))
+         (upper-case (let (case-fold-search) (string-match-p "[[:upper:]]" str)))
+         (case-fold-search (if (and interactive upper-case)
+                               nil
+                             case-fold-search)))
     (kill-region (point)
 		 (progn
 		   (forward-char direction)
 		   (unwind-protect
-		       (search-forward (char-to-string char) nil nil arg)
+		       (search-forward str nil nil arg)
 		     (backward-char direction))
 		   (point)))))
 
diff --git a/lisp/simple.el b/lisp/simple.el
index eb65701803..2f3c43b9db 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -6031,21 +6031,27 @@ backward-delete-char-untabify
     ;; Avoid warning about delete-backward-char
     (with-no-warnings (delete-backward-char n killp))))
 
-(defun zap-to-char (arg char)
+(defun zap-to-char (arg char &optional interactive)
   "Kill up to and including ARGth occurrence of CHAR.
 Case is ignored if `case-fold-search' is non-nil in the current buffer.
 Goes backward if ARG is negative; error if CHAR not found.
-See also `zap-up-to-char'."
+See also `zap-up-to-char'.
+Called interactively, do a case sensitive search if the char is an
+upper case letter."
   (interactive (list (prefix-numeric-value current-prefix-arg)
 		     (read-char-from-minibuffer "Zap to char: "
-						nil 'read-char-history)))
+						nil 'read-char-history))
+               t)
   ;; Avoid "obsolete" warnings for translation-table-for-input.
   (with-no-warnings
     (if (char-table-p translation-table-for-input)
 	(setq char (or (aref translation-table-for-input char) char))))
-  (kill-region (point) (progn
-			 (search-forward (char-to-string char) nil nil arg)
-			 (point))))
+  (let* ((str (char-to-string char))
+         (upper-case (let (case-fold-search) (string-match-p "[[:upper:]]" str)))
+         (case-fold-search (if (and interactive upper-case)
+                               nil
+                             case-fold-search)))
+    (kill-region (point) (search-forward str nil nil arg))))
 
 ;; kill-line and its subroutines.
 

--8<-----------------------------cut here---------------end--------------->8---




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Sat, 16 Apr 2022 11:34:02 GMT) Full text and rfc822 format available.

Message #14 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 54804 <at> debbugs.gnu.org, uyennhi.qm <at> gmail.com
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Sat, 16 Apr 2022 14:33:45 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Cc: 54804 <at> debbugs.gnu.org,  uyennhi.qm <at> gmail.com
> Date: Sat, 16 Apr 2022 12:58:06 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > but why does the implementation have to be so complicated?
> > Isn't this just about turning off case-fold-search while searching for
> > the character?  What am I missing?
> 
> The patch is moving the shared code in zap-to/zap-up-to in a
> helper function.  This has 2 motivations:
> - reduce the code duplication.
> - define these two related functions close each other.
> - separate the logic of the function to calculate the region to kill.
> 
> If you prefer, we can keep the functions in their current
> locations (simple.el/misc.el) with a patch like this one:

What I'd prefer is to have a single function (in subr.el) that
determines whether a character is an upper- or lower-case, and then
use that function in a simple condition in these two commands.

The function to check whether a character is upper-case doesn't have
to make a string from the character and then use the "heavy artillery"
of string-match-p, it could instead use something like

   (characterp (get-char-code-property CHAR 'uppercase))

(But beware of the situation where the Unicode tables are not yet
available during bootstrap -- in those cases the function should IMO
punt and return nil no matter what the character is, or maybe support
just the ASCII characters.  To test whether the 'uppercase table is
available, see if unicode-property-table-internal returns non-nil.)

> +  ;; Avoid "obsolete" warnings for translation-table-for-input.
> +  (with-no-warnings
> +    (if (char-table-p translation-table-for-input)
> +	(setq char (or (aref translation-table-for-input char) char))))

translation-table-for-input is obsolete for a reason, so adding it to
a new function is not something we want to do.  If anything, we should
remove it from the old function.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Mon, 09 May 2022 16:18:01 GMT) Full text and rfc822 format available.

Message #17 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 54804 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, uyennhi.qm <at> gmail.com
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Mon, 09 May 2022 09:17:13 -0700
Hello Tino,

Any progress on this?  I would like this functionality.  Thanks.

On Sat 16 Apr 2022 at 02:33pm +03, Eli Zaretskii wrote:

>> From: Tino Calancha <tino.calancha <at> gmail.com>
>> Cc: 54804 <at> debbugs.gnu.org,  uyennhi.qm <at> gmail.com
>> Date: Sat, 16 Apr 2022 12:58:06 +0200
>> 
>> Eli Zaretskii <eliz <at> gnu.org> writes:
>> 
>> > but why does the implementation have to be so complicated?
>> > Isn't this just about turning off case-fold-search while searching for
>> > the character?  What am I missing?
>> 
>> The patch is moving the shared code in zap-to/zap-up-to in a
>> helper function.  This has 2 motivations:
>> - reduce the code duplication.
>> - define these two related functions close each other.
>> - separate the logic of the function to calculate the region to kill.
>> 
>> If you prefer, we can keep the functions in their current
>> locations (simple.el/misc.el) with a patch like this one:
>
> What I'd prefer is to have a single function (in subr.el) that
> determines whether a character is an upper- or lower-case, and then
> use that function in a simple condition in these two commands.
>
> The function to check whether a character is upper-case doesn't have
> to make a string from the character and then use the "heavy artillery"
> of string-match-p, it could instead use something like
>
>    (characterp (get-char-code-property CHAR 'uppercase))
>
> (But beware of the situation where the Unicode tables are not yet
> available during bootstrap -- in those cases the function should IMO
> punt and return nil no matter what the character is, or maybe support
> just the ASCII characters.  To test whether the 'uppercase table is
> available, see if unicode-property-table-internal returns non-nil.)
>
>> +  ;; Avoid "obsolete" warnings for translation-table-for-input.
>> +  (with-no-warnings
>> +    (if (char-table-p translation-table-for-input)
>> +	(setq char (or (aref translation-table-for-input char) char))))
>
> translation-table-for-input is obsolete for a reason, so adding it to
> a new function is not something we want to do.  If anything, we should
> remove it from the old function.
>
>
>

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Tue, 10 May 2022 21:15:01 GMT) Full text and rfc822 format available.

Message #20 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 54804 <at> debbugs.gnu.org, uyennhi.qm <at> gmail.com,
 Sean Whitton <spwhitton <at> spwhitton.name>
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Tue, 10 May 2022 23:14:20 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

> What I'd prefer is to have a single function (in subr.el) that
> determines whether a character is an upper- or lower-case

> it could instead use something like
>
>    (characterp (get-char-code-property CHAR 'uppercase))
>
> (But beware of the situation where the Unicode tables are not yet
> available during bootstrap -- in those cases the function should IMO
> punt and return nil no matter what the character is, or maybe support
> just the ASCII characters.  To test whether the 'uppercase table is
> available, see if unicode-property-table-internal returns non-nil.)

Is it the following implementation OK for such a function?

--8<-----------------------------cut here---------------start------------->8---
commit 74dd575d3ca8e5217a3c1457dbc011007ecc0800
Author: Tino Calancha <tino.calancha <at> gmail.com>
Date:   Tue May 10 23:01:34 2022 +0200

    Add char-upcase-p predicate

diff --git a/lisp/simple.el b/lisp/simple.el
index edcc226bfa..dc5e0f2ce8 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))))
 
+(defun char-upcase-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 (>= 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.
diff --git a/test/lisp/subr-tests.el b/test/lisp/subr-tests.el
index 89803e5ce2..8072cd9a61 100644
--- a/test/lisp/subr-tests.el
+++ b/test/lisp/subr-tests.el
@@ -1074,5 +1074,12 @@ test-local-set-state
       (should (= subr-test--local 2))
       (should-not (boundp 'subr-test--unexist)))))
 
+(ert-deftest test-char-upcase-p ()
+  "Tests for `char-upcase-p'."
+  (dolist (c (list ?R ?S ?Ω ?Ψ))
+    (should (char-upcase-p c)))
+  (dolist (c (list ?a ?b ?α ?β))
+    (should-not (char-upcase-p c))))
+
 (provide 'subr-tests)
 ;;; subr-tests.el ends here

--8<-----------------------------cut here---------------end--------------->8---




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Wed, 11 May 2022 11:16:02 GMT) Full text and rfc822 format available.

Message #23 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 54804 <at> debbugs.gnu.org, uyennhi.qm <at> gmail.com, spwhitton <at> spwhitton.name
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Wed, 11 May 2022 14:15:00 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Cc: 54804 <at> debbugs.gnu.org,  uyennhi.qm <at> gmail.com, Sean Whitton
>  <spwhitton <at> spwhitton.name>
> Date: Tue, 10 May 2022 23:14:20 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> > What I'd prefer is to have a single function (in subr.el) that
> > determines whether a character is an upper- or lower-case
> 
> > it could instead use something like
> >
> >    (characterp (get-char-code-property CHAR 'uppercase))
> >
> > (But beware of the situation where the Unicode tables are not yet
> > available during bootstrap -- in those cases the function should IMO
> > punt and return nil no matter what the character is, or maybe support
> > just the ASCII characters.  To test whether the 'uppercase table is
> > available, see if unicode-property-table-internal returns non-nil.)
> 
> 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).




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Wed, 11 May 2022 14:44:01 GMT) Full text and rfc822 format available.

Message #26 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 54804 <at> debbugs.gnu.org, uyennhi.qm <at> gmail.com, spwhitton <at> spwhitton.name
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Wed, 11 May 2022 16:43:06 +0200
Eli Zaretskii <eliz <at> gnu.org> 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 <tino.calancha <at> gmail.com>
Date:   Wed May 11 16:34:33 2022 +0200

    char-uppercase-p: New predicate
    
    Return non-nil if its argument is an upper-case unicode 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.

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
 
+@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 if it encounters
 these forms.
 
 
++++
+*** 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))))
 
+(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 (>= 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.
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 (= 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

--8<-----------------------------cut here---------------end--------------->8---




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Wed, 11 May 2022 14:51:01 GMT) Full text and rfc822 format available.

Message #29 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, spwhitton <at> spwhitton.name,
 54804 <at> debbugs.gnu.org, uyennhi.qm <at> gmail.com
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Wed, 11 May 2022 16:50:00 +0200
Tino Calancha <tino.calancha <at> gmail.com> writes:

> +This function returns non-nil if @var{char} is an uppercase unicode
> +character. 

Do we need to say "Unicode characters" here?  I think many will
interpret that to mean that it doesn't work on ASCII characters (which
it seems like it's doing).

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Wed, 11 May 2022 15:01:01 GMT) Full text and rfc822 format available.

Message #32 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Robert Pluim <rpluim <at> gmail.com>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, spwhitton <at> spwhitton.name,
 54804 <at> debbugs.gnu.org, uyennhi.qm <at> gmail.com
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Wed, 11 May 2022 17:00:13 +0200
>>>>> On Wed, 11 May 2022 16:43:06 +0200, Tino Calancha <tino.calancha <at> gmail.com> said:

    Tino> Eli Zaretskii <eliz <at> gnu.org> 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).

    Tino> I'd like to add this `char-uppercase-p'.
    Tino> Once merged, I will finish with the goal of the report.

    Tino> I appreciate a hand with the documentation part.

Youʼre *asking* us to nit-pick? Youʼre a brave person ☺️

    Tino> commit aa270a4b8813ac226a61d8e6919f68e9e4ed0973
    Tino> Author: Tino Calancha <tino.calancha <at> gmail.com>
    Tino> Date:   Wed May 11 16:34:33 2022 +0200

    Tino>     char-uppercase-p: New predicate
    
    Tino>     Return non-nil if its argument is an upper-case unicode character.
    
    Tino>     Suggested in Bug#54804.
    
    Tino>     * lisp/subr.el (char-uppercase-p): New defun.
    Tino>     * etc/NEWS (Lisp Changes in Emacs 29.1): Announce it
    Tino>     * doc/lispref/display.texi (Size of Displayed Text): Document it.
    Tino>     * test/lisp/subr-tests.el (test-char-uppercase-p): Add a test.

    Tino> diff --git a/doc/lispref/display.texi b/doc/lispref/display.texi
    Tino> index 9650d22790..1c32458d62 100644
    Tino> --- a/doc/lispref/display.texi
    Tino> +++ b/doc/lispref/display.texi
    Tino> @@ -2010,6 +2010,14 @@ Size of Displayed Text
    Tino>  (@pxref{Usual Display}).
    Tino>  @end defun
 
    Tino> +@defun char-uppercase-p char
    Tino> +This function returns non-nil if @var{char} is an uppercase unicode
    Tino> +character.  Be aware that if the Unicode tables are not yet available,
    Tino> +e.g. during bootstrap, then this function gives the right answer only
    Tino> +for @acronym{ASCII} characters; for other characters the function
    Tino> +unconditionally returns @code{nil}.
    Tino> +@end defun
    Tino> +

Be active: 'Return non-nil if ...'. So:

Return non-@code{nil} if @var{char} is an uppercase character
according to Unicode.  Be aware that if the Unicode tables are not yet
available, e.g. during bootstrap, this gives the correct answer only
for @acronym{ASCII} characters; for other characters it always returns
@code{nil}.


    Tino>  @defun string-width string &optional from to
    Tino>  This function returns the width in columns of the string @var{string},
    Tino>  if it were displayed in the current buffer and the selected window.
    Tino> diff --git a/etc/NEWS b/etc/NEWS
    Tino> index 991088a067..57c254bce8 100644
    Tino> --- a/etc/NEWS
    Tino> +++ b/etc/NEWS
    Tino> @@ -1794,6 +1794,10 @@ value.  The byte compiler will now issue a warning if it encounters
    Tino>  these forms.
 
 
    Tino> ++++
    Tino> +*** The new predicate 'char-uppercase-p' returns non-nil if its
    Tino> +argument its an uppercase unicode character.

The header line should fit on one line. So

*** New predicate 'char-uppercase-p'.
This returns...

    Tino> +
    Tino>  +++
    Tino>  *** 'restore-buffer-modified-p' can now alter buffer auto-save state.
    Tino>  With a FLAG value of 'autosaved', it will mark the buffer as having
    Tino> diff --git a/lisp/simple.el b/lisp/simple.el
    Tino> index 89fb0ea97e..525e636ab6 100644
    Tino> --- a/lisp/simple.el
    Tino> +++ b/lisp/simple.el
    Tino> @@ -6054,6 +6054,14 @@ backward-delete-char-untabify
    Tino>      ;; Avoid warning about delete-backward-char
    Tino>      (with-no-warnings (delete-backward-char n killp))))
 
    Tino> +(defun char-uppercase-p (char)
    Tino> +  "Return non-nil if CHAR is an upper-case unicode character.
    Tino> +If the Unicode tables are not yet available, e.g. during bootstrap,
    Tino> +then the function restricts to the ASCII character set."

Iʼd say 'gives correct answers only for ASCII characters'

Robert
-- 




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Wed, 11 May 2022 15:21:02 GMT) Full text and rfc822 format available.

Message #35 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: uyennhi.qm <at> gmail.com, Eli Zaretskii <eliz <at> gnu.org>, 54804 <at> debbugs.gnu.org,
 spwhitton <at> spwhitton.name
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Wed, 11 May 2022 17:19:55 +0200
Lars Ingebrigtsen <larsi <at> gnus.org> writes:

> Do we need to say "Unicode characters" here?  I think many will
> interpret that to mean that it doesn't work on ASCII characters (which
> it seems like it's doing).
Good point.  I have dropped Unicode.

Robert Pluim <rpluim <at> gmail.com> writes:
>     Tino> I appreciate a hand with the documentation part.
>
> Youʼre *asking* us to nit-pick? Youʼre a brave person ☺️

You know, I've never had a native english speaker gf. Sniff, sniff.
Thanks for the great suggestions.  All are in.
Now I am pushing these changes.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Wed, 11 May 2022 15:28:02 GMT) Full text and rfc822 format available.

Message #38 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Robert Pluim <rpluim <at> gmail.com>
Cc: uyennhi.qm <at> gmail.com, Eli Zaretskii <eliz <at> gnu.org>,
 spwhitton <at> spwhitton.name, 54804 <at> debbugs.gnu.org,
 Tino Calancha <tino.calancha <at> gmail.com>
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Wed, 11 May 2022 17:27:07 +0200
On Mai 11 2022, Robert Pluim wrote:

> Return non-@code{nil} if @var{char} is an uppercase character
> according to Unicode.  Be aware that if the Unicode tables are not yet
> available, e.g. during bootstrap, this gives the correct answer only
> for @acronym{ASCII} characters; for other characters it always returns
> @code{nil}.

I don't think it is necessary to talk about bootstrapping in the manual.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Wed, 11 May 2022 15:40:02 GMT) Full text and rfc822 format available.

Message #41 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: 54804 <at> debbugs.gnu.org, Tino Calancha <tino.calancha <at> gmail.com>,
 Robert Pluim <rpluim <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>,
 uyennhi.qm <at> gmail.com, spwhitton <at> spwhitton.name
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Wed, 11 May 2022 17:38:55 +0200 (CEST)

On Wed, 11 May 2022, Andreas Schwab wrote:

> On Mai 11 2022, Robert Pluim wrote:
>
>> Return non-@code{nil} if @var{char} is an uppercase character
>> according to Unicode.  Be aware that if the Unicode tables are not yet
>> available, e.g. during bootstrap, this gives the correct answer only
>> for @acronym{ASCII} characters; for other characters it always returns
>> @code{nil}.
>
> I don't think it is necessary to talk about bootstrapping in the manual.
Right... How about replacing?
"available, e.g. during bootstrap, this gives the correct answer only..."

with

"available, e.g. while compiling the Emac source code, this gives the 
correct answer only..."

PD: I am having issues pushing: my password is not working.
If I am not able to make it work, then I will post here the final
patch so that someone else can push it.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Wed, 11 May 2022 15:58:02 GMT) Full text and rfc822 format available.

Message #44 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 54804 <at> debbugs.gnu.org, uyennhi.qm <at> gmail.com, spwhitton <at> spwhitton.name
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Wed, 11 May 2022 18:57:33 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Cc: 54804 <at> debbugs.gnu.org,  uyennhi.qm <at> gmail.com,  spwhitton <at> spwhitton.name
> Date: Wed, 11 May 2022 16:43:06 +0200
> 
> +@defun char-uppercase-p char
> +This function returns non-nil if @var{char} is an uppercase unicode
                             ^^^
@code{nil}

> +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}.

This manual is not for Emacs developers, it is for Lisp programmers.
Therefore, the last sentence should be removed.

> ++++
> +*** The new predicate 'char-uppercase-p' returns non-nil if its
> +argument its an uppercase unicode character.

The first line of a NEWS entry should be a complete sentence, and end
with a period.

> +(defun char-uppercase-p (char)
> +  "Return non-nil if CHAR is an upper-case unicode character.

Just "upper-case character", no need to say "Unicode".

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Wed, 11 May 2022 16:12:01 GMT) Full text and rfc822 format available.

Message #47 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Andreas Schwab <schwab <at> linux-m68k.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: uyennhi.qm <at> gmail.com, Robert Pluim <rpluim <at> gmail.com>,
 54804 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>, spwhitton <at> spwhitton.name
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Wed, 11 May 2022 18:11:13 +0200
On Mai 11 2022, Tino Calancha wrote:

> On Wed, 11 May 2022, Andreas Schwab wrote:
>
>> On Mai 11 2022, Robert Pluim wrote:
>>
>>> Return non-@code{nil} if @var{char} is an uppercase character
>>> according to Unicode.  Be aware that if the Unicode tables are not yet
>>> available, e.g. during bootstrap, this gives the correct answer only
>>> for @acronym{ASCII} characters; for other characters it always returns
>>> @code{nil}.
>>
>> I don't think it is necessary to talk about bootstrapping in the manual.
> Right... How about replacing?
> "available, e.g. during bootstrap, this gives the correct answer only..."
>
> with
>
> "available, e.g. while compiling the Emac source code, this gives the
> correct answer only..."

I don't think there is a need for this at all in the manual.  It could
be added as a comment in the source, though.

-- 
Andreas Schwab, schwab <at> linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Wed, 11 May 2022 16:20:01 GMT) Full text and rfc822 format available.

Message #50 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: 54804 <at> debbugs.gnu.org, Tino Calancha <tino.calancha <at> gmail.com>,
 Robert Pluim <rpluim <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>,
 uyennhi.qm <at> gmail.com, spwhitton <at> spwhitton.name
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Wed, 11 May 2022 18:18:55 +0200 (CEST)

On Wed, 11 May 2022, Andreas Schwab wrote:

>> "available, e.g. while compiling the Emac source code, this gives the
>> correct answer only..."
>
> I don't think there is a need for this at all in the manual.  It could
> be added as a comment in the source, though.

I have removed completely that sentence and pushed
to the master branch.

Thank you Andreas.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Thu, 12 May 2022 15:56:01 GMT) Full text and rfc822 format available.

Message #53 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Andreas Schwab <schwab <at> linux-m68k.org>
Cc: 54804 <at> debbugs.gnu.org, spwhitton <at> spwhitton.name,
 Eli Zaretskii <eliz <at> gnu.org>, Robert Pluim <rpluim <at> gmail.com>,
 uyennhi.qm <at> gmail.com
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Thu, 12 May 2022 17:55:38 +0200
Tino Calancha <tino.calancha <at> gmail.com> writes:

> I have removed completely that sentence and pushed
> to the master branch.

The Empire Strikes Back

--8<-----------------------------cut here---------------start------------->8---
commit 86750ab021ea889766a717458ed28a54e6a40ad3
Author: Tino Calancha <tino.calancha <at> gmail.com>
Date:   Thu May 12 17:48:09 2022 +0200

    zap-to-char: case sensitive for upper-case characters
    
    In interactive calls, behave case-sensitively if the given char
    is an upper-case character.  Same for zap-up-to-char.
    
    This is analog to what the user-level incremental search feature does.
    
    * lisp/misc.el (zap-up-to-char): Add an optional arg INTERACTIVE.
    Perform a case-sensitive search when INTERACTIVE is non-nil and
    CHAR is an upper-case character.
    * lisp/simple.el (zap-to-char): Same.
    
    * etc/NEWS (Editing Changes in Emacs 29.1): Announce this change.
    * test/lisp/misc-tests.el ((misc-test-zap-up-to-char): Add test cases.
    * test/lisp/simple-tests.el (with-simple-test): Add helper macro.
    (simple-tests-zap-to-char): Add a test.

diff --git a/etc/NEWS b/etc/NEWS
index 3bdc497f18..d6493e77e5 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -672,6 +672,12 @@ recreate it anew next time 'imenu' is invoked.
 
 * Editing Changes in Emacs 29.1
 
+---
+** 'zap-to-char' case sensitivity on interactive calls.
+The command now behaves as case-sensitive for interactive calls when is
+invoked with an uppercase argument, regardless of the
+`case-fold-search' value.  Likewise, for 'zap-up-to-char'.
+
 ---
 ** 'scroll-other-window' and 'scroll-other-window-down' now respects remapping.
 These commands (bound to 'C-M-v' and 'C-M-V') used to scroll the other
diff --git a/lisp/misc.el b/lisp/misc.el
index d85f889ffd..f92debf013 100644
--- a/lisp/misc.el
+++ b/lisp/misc.el
@@ -64,15 +64,21 @@ copy-from-above-command
 ;; Variation of `zap-to-char'.
 
 ;;;###autoload
-(defun zap-up-to-char (arg char)
+(defun zap-up-to-char (arg char &optional interactive)
   "Kill up to, but not including ARGth occurrence of CHAR.
 Case is ignored if `case-fold-search' is non-nil in the current buffer.
 Goes backward if ARG is negative; error if CHAR not found.
-Ignores CHAR at point."
+Ignores CHAR at point.
+Called interactively, do a case sensitive search if CHAR
+is an upper-case character."
   (interactive (list (prefix-numeric-value current-prefix-arg)
 		     (read-char-from-minibuffer "Zap up to char: "
-						nil 'read-char-history)))
-  (let ((direction (if (>= arg 0) 1 -1)))
+						nil 'read-char-history)
+                     t))
+  (let ((direction (if (>= arg 0) 1 -1))
+        (case-fold-search (if (and interactive (char-uppercase-p char))
+                              nil
+                            case-fold-search)))
     (kill-region (point)
 		 (progn
 		   (forward-char direction)
diff --git a/lisp/simple.el b/lisp/simple.el
index 3812f6d8c6..7d6c55c190 100644
--- a/lisp/simple.el
+++ b/lisp/simple.el
@@ -6062,21 +6062,25 @@ char-uppercase-p
          (characterp (get-char-code-property char 'lowercase)))
         ((and (>= char ?A) (<= char ?Z)))))
 
-(defun zap-to-char (arg char)
+(defun zap-to-char (arg char &optional interactive)
   "Kill up to and including ARGth occurrence of CHAR.
 Case is ignored if `case-fold-search' is non-nil in the current buffer.
 Goes backward if ARG is negative; error if CHAR not found.
-See also `zap-up-to-char'."
+See also `zap-up-to-char'.
+Called interactively, do a case sensitive search if CHAR
+is an upper-case character."
   (interactive (list (prefix-numeric-value current-prefix-arg)
 		     (read-char-from-minibuffer "Zap to char: "
-						nil 'read-char-history)))
+						nil 'read-char-history))
+               t)
   ;; Avoid "obsolete" warnings for translation-table-for-input.
   (with-no-warnings
     (if (char-table-p translation-table-for-input)
 	(setq char (or (aref translation-table-for-input char) char))))
-  (kill-region (point) (progn
-			 (search-forward (char-to-string char) nil nil arg)
-			 (point))))
+  (let ((case-fold-search (if (and interactive (char-uppercase-p char))
+                              nil
+                            case-fold-search)))
+    (kill-region (point) (search-forward (char-to-string char) nil nil arg))))
 
 ;; kill-line and its subroutines.
 
diff --git a/test/lisp/misc-tests.el b/test/lisp/misc-tests.el
index 36a8726b88..236223ef49 100644
--- a/test/lisp/misc-tests.el
+++ b/test/lisp/misc-tests.el
@@ -44,7 +44,14 @@ misc-test-zap-up-to-char
     (zap-up-to-char 1 ?c))
   (with-misc-test "abcde abc123" "c123"
     (goto-char (point-min))
-    (zap-up-to-char 2 ?c)))
+    (zap-up-to-char 2 ?c))
+  (let ((case-fold-search t))
+    (with-misc-test "abcdeCXYZ" "cdeCXYZ"
+      (goto-char (point-min))
+      (zap-up-to-char 1 ?C))
+    (with-misc-test "abcdeCXYZ" "CXYZ"
+      (goto-char (point-min))
+      (zap-up-to-char 1 ?C 'interactive))))
 
 (ert-deftest misc-test-upcase-char ()
   (with-misc-test "abcde" "aBCDe"
diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el
index dcab811bb5..2baf7124d7 100644
--- a/test/lisp/simple-tests.el
+++ b/test/lisp/simple-tests.el
@@ -971,5 +971,27 @@ test-undo-region
     ;;(should (= (length (delq nil (undo-make-selective-list 5 9))) 0))
     (should (= (length (delq nil (undo-make-selective-list 6 9))) 0))))
 
+
+;;; Tests for `zap-to-char'
+
+(defmacro with-simple-test (original result &rest body)
+  (declare (indent 2) (debug (stringp stringp body)))
+  `(with-temp-buffer
+     (insert ,original)
+     (goto-char (point-min))
+     ,@body
+     (should (equal (buffer-string) ,result))))
+
+(ert-deftest simple-tests-zap-to-char ()
+  (with-simple-test "abcde" "de"
+    (zap-to-char 1 ?c))
+  (with-simple-test "abcde abc123" "123"
+    (zap-to-char 2 ?c))
+  (let ((case-fold-search t))
+    (with-simple-test "abcdeCXYZ" "deCXYZ"
+      (zap-to-char 1 ?C))
+    (with-simple-test "abcdeCXYZ" "XYZ"
+      (zap-to-char 1 ?C 'interactive))))
+
 (provide 'simple-test)
 ;;; simple-tests.el ends here

--8<-----------------------------cut here---------------end--------------->8---




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Fri, 13 May 2022 06:49:02 GMT) Full text and rfc822 format available.

Message #56 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 54804 <at> debbugs.gnu.org, spwhitton <at> spwhitton.name, schwab <at> linux-m68k.org,
 rpluim <at> gmail.com, uyennhi.qm <at> gmail.com
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Fri, 13 May 2022 09:48:41 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Cc: 54804 <at> debbugs.gnu.org,  Robert Pluim <rpluim <at> gmail.com>,  Eli Zaretskii
>  <eliz <at> gnu.org>,  uyennhi.qm <at> gmail.com,  spwhitton <at> spwhitton.name
> Date: Thu, 12 May 2022 17:55:38 +0200
> 
>     * lisp/misc.el (zap-up-to-char): Add an optional arg INTERACTIVE.
>     Perform a case-sensitive search when INTERACTIVE is non-nil and
>     CHAR is an upper-case character.

I don't understand why the need for the new INTERACTIVE argument.  It
is also undocumented in the doc strings.

> --- a/etc/NEWS
> +++ b/etc/NEWS
> @@ -672,6 +672,12 @@ recreate it anew next time 'imenu' is invoked.
>  
>  * Editing Changes in Emacs 29.1
>  
> +---
> +** 'zap-to-char' case sensitivity on interactive calls.

NEWS is read in Outline mode, and its text should make sense when only
the headings are visible.  The above heading doesn't have enough
information to be useful without the body, because it says almost
nothing about the change.  Here's a better heading:

  ** 'zap-to-char' and 'zap-up-to-char' are case-sensitive for upper-case chars

> +The command now behaves as case-sensitive for interactive calls when is
> +invoked with an uppercase argument, regardless of the
> +`case-fold-search' value.  Likewise, for 'zap-up-to-char'.

The body should describe both commands equally.

> -(defun zap-up-to-char (arg char)
> +(defun zap-up-to-char (arg char &optional interactive)
>    "Kill up to, but not including ARGth occurrence of CHAR.
>  Case is ignored if `case-fold-search' is non-nil in the current buffer.
>  Goes backward if ARG is negative; error if CHAR not found.
> -Ignores CHAR at point."
> +Ignores CHAR at point.
> +Called interactively, do a case sensitive search if CHAR

"If called interactively, ..."

And, as mentioned above, I don't think I understand why we need to do
this only in interactive calls.  Non-interactive invocations already
have a way to request case-sensitivity, by let-binding
case-fold-search, right?

> diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el
> index dcab811bb5..2baf7124d7 100644
> --- a/test/lisp/simple-tests.el
> +++ b/test/lisp/simple-tests.el
> @@ -971,5 +971,27 @@ test-undo-region
>      ;;(should (= (length (delq nil (undo-make-selective-list 5 9))) 0))
>      (should (= (length (delq nil (undo-make-selective-list 6 9))) 0))))
>  
> +
> +;;; Tests for `zap-to-char'

Should we have the tests for zap-* functions in one place, rather than
two?

> +(defmacro with-simple-test (original result &rest body)
> +  (declare (indent 2) (debug (stringp stringp body)))
> +  `(with-temp-buffer
> +     (insert ,original)
> +     (goto-char (point-min))
> +     ,@body
> +     (should (equal (buffer-string) ,result))))

This macro is specific to zap-* functions, I think.  So its name
should reflect that fact.

Thanks.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Tue, 17 May 2022 12:35:02 GMT) Full text and rfc822 format available.

Message #59 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 54804 <at> debbugs.gnu.org, juri <at> linkov.net, uyennhi.qm <at> gmail.com,
 monnier <at> iro.umontreal.ca, spwhitton <at> spwhitton.name
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Tue, 17 May 2022 14:34:06 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

I have added Stefan, who suggests using the interactive arg (see
explanation below).
I have also added Juri, who is expert on isearch.

>> From: Tino Calancha <tino.calancha <at> gmail.com>
>>     * lisp/misc.el (zap-up-to-char): Add an optional arg INTERACTIVE.
>>     Perform a case-sensitive search when INTERACTIVE is non-nil and
>>     CHAR is an upper-case character.
>
> I don't understand why the need for the new INTERACTIVE argument.

> And, as mentioned above, I don't think I understand why we need to do
> this only in interactive calls.  Non-interactive invocations already
> have a way to request case-sensitivity, by let-binding
> case-fold-search, right?

I'll try to explain this.

This is what Emacs does for isearch/search.

If you go to the *scratch* buffer, and you do
C-s T C-s C-s
you only jump on 'T', that is, you skip the 't'. This is regardless
on the `case-fold-search' value.

Calling from Lisp:
(search-forward "T" nil t)
we'll also jump on the 't' if `case-fold-search' is non-nil.

I want the analog behavior for zap-to... commands: automatic
case sensitivity when the char is uppercase.
I want this behavior on interactive calls only, for instance when users
do `M-z'.

How to detect that the users are calling these commands interactively?
I got inspired from this comment found at the docstring of
`called-interactively-p' (Stefan wrote that):

"Instead of using this function, it is cleaner and more reliable to give your
function an extra optional argument whose ‘interactive’ spec specifies
non-nil unconditionally ("p" is a good way to do this), or via
(not (or executing-kbd-macro noninteractive))."





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Tue, 17 May 2022 12:43:01 GMT) Full text and rfc822 format available.

Message #62 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 54804 <at> debbugs.gnu.org, juri <at> linkov.net, uyennhi.qm <at> gmail.com,
 monnier <at> iro.umontreal.ca, spwhitton <at> spwhitton.name
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Tue, 17 May 2022 15:41:53 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Cc: 54804 <at> debbugs.gnu.org,  spwhitton <at> spwhitton.name,uyennhi.qm <at> gmail.com,
>  <monnier <at> iro.umontreal.ca>, juri <at> linkov.net
> Date: Tue, 17 May 2022 14:34:06 +0200
> 
> Eli Zaretskii <eliz <at> gnu.org> writes:
> 
> I have added Stefan, who suggests using the interactive arg (see
> explanation below).
> I have also added Juri, who is expert on isearch.
> 
> >> From: Tino Calancha <tino.calancha <at> gmail.com>
> >>     * lisp/misc.el (zap-up-to-char): Add an optional arg INTERACTIVE.
> >>     Perform a case-sensitive search when INTERACTIVE is non-nil and
> >>     CHAR is an upper-case character.
> >
> > I don't understand why the need for the new INTERACTIVE argument.
> 
> > And, as mentioned above, I don't think I understand why we need to do
> > this only in interactive calls.  Non-interactive invocations already
> > have a way to request case-sensitivity, by let-binding
> > case-fold-search, right?
> 
> I'll try to explain this.
> 
> This is what Emacs does for isearch/search.

Search is a much more complex set of features and commands in Emacs.
These two commands are much simpler, and I see no reason to try to be
compatible with search commands, since these two commands don't search
anything.

> I want the analog behavior for zap-to... commands: automatic
> case sensitivity when the char is uppercase.
> I want this behavior on interactive calls only, for instance when users
> do `M-z'.

As I said I disagree: these are DWIMish features that are best
reserved for interactive invocation.  In calls from Lisp, it is
confusing to have the behavior change so drastically depending on the
letter-case of an argument.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Tue, 17 May 2022 12:52:02 GMT) Full text and rfc822 format available.

Message #65 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: juri <at> linkov.net, 54804 <at> debbugs.gnu.org, spwhitton <at> spwhitton.name,
 uyennhi.qm <at> gmail.com, Tino Calancha <tino.calancha <at> gmail.com>
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Tue, 17 May 2022 08:51:22 -0400
>> I want the analog behavior for zap-to... commands: automatic
>> case sensitivity when the char is uppercase.
>> I want this behavior on interactive calls only, for instance when users
>> do `M-z'.
>
> As I said I disagree: these are DWIMish features that are best
> reserved for interactive invocation.  In calls from Lisp, it is
> confusing to have the behavior change so drastically depending on the
> letter-case of an argument.

Am I misunderstanding something or are you two violently agreeing?


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Tue, 17 May 2022 12:55:02 GMT) Full text and rfc822 format available.

Message #68 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 54804 <at> debbugs.gnu.org, Tino Calancha <tino.calancha <at> gmail.com>,
 juri <at> linkov.net, Eli Zaretskii <eliz <at> gnu.org>, uyennhi.qm <at> gmail.com,
 spwhitton <at> spwhitton.name
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Tue, 17 May 2022 14:53:41 +0200 (CEST)

On Tue, 17 May 2022, Stefan Monnier wrote:

>>> I want the analog behavior for zap-to... commands: automatic
>>> case sensitivity when the char is uppercase.
>>> I want this behavior on interactive calls only, for instance when users
>>> do `M-z'.
>>
>> As I said I disagree: these are DWIMish features that are best
>> reserved for interactive invocation.  In calls from Lisp, it is
>> confusing to have the behavior change so drastically depending on the
>> letter-case of an argument.
>
> Am I misunderstanding something or are you two violently agreeing?

We both agree with a sword in a hand.

I don't want to change the behavior on Lisp call!
Just let me know the nice way to detect that the call is interactive and 
then I will inject the feature :-)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Tue, 17 May 2022 13:40:02 GMT) Full text and rfc822 format available.

Message #71 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: 54804 <at> debbugs.gnu.org, tino.calancha <at> gmail.com, juri <at> linkov.net,
 monnier <at> iro.umontreal.ca, uyennhi.qm <at> gmail.com, spwhitton <at> spwhitton.name
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Tue, 17 May 2022 16:38:43 +0300
> From: Tino Calancha <tino.calancha <at> gmail.com>
> Date: Tue, 17 May 2022 14:53:41 +0200 (CEST)
> cc: Eli Zaretskii <eliz <at> gnu.org>, Tino Calancha <tino.calancha <at> gmail.com>, 
>     54804 <at> debbugs.gnu.org, spwhitton <at> spwhitton.name, uyennhi.qm <at> gmail.com, 
>     juri <at> linkov.net
> 
> 
> 
> On Tue, 17 May 2022, Stefan Monnier wrote:
> 
> >>> I want the analog behavior for zap-to... commands: automatic
> >>> case sensitivity when the char is uppercase.
> >>> I want this behavior on interactive calls only, for instance when users
> >>> do `M-z'.
> >>
> >> As I said I disagree: these are DWIMish features that are best
> >> reserved for interactive invocation.  In calls from Lisp, it is
> >> confusing to have the behavior change so drastically depending on the
> >> letter-case of an argument.
> >
> > Am I misunderstanding something or are you two violently agreeing?
> 
> We both agree with a sword in a hand.
> 
> I don't want to change the behavior on Lisp call!
> Just let me know the nice way to detect that the call is interactive and 
> then I will inject the feature :-)

If you only make the search case-sensitive in the 'interactive' form,
that happens automagically.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Tue, 17 May 2022 14:32:02 GMT) Full text and rfc822 format available.

Message #74 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: spwhitton <at> spwhitton.name, 54804 <at> debbugs.gnu.org, juri <at> linkov.net,
 uyennhi.qm <at> gmail.com, Tino Calancha <tino.calancha <at> gmail.com>
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Tue, 17 May 2022 10:31:19 -0400
> If you only make the search case-sensitive in the 'interactive' form,
> that happens automagically.

I don't understand what you mean by that: the search doesn't take place
inside the interactive form, so he can't really control the
case-sensitivity from the interactive form, except (as he does) by using
the interactive form to pass extra info (in the form of the
`interactive` arg) to tell the search code that the call was made
interactively and should hence use the "fancier" form of
case sensitivity.


        Stefan





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Tue, 17 May 2022 19:45:01 GMT) Full text and rfc822 format available.

Message #77 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Juri Linkov <juri <at> linkov.net>
To: Tino Calancha <tino.calancha <at> gmail.com>
Cc: uyennhi.qm <at> gmail.com, Eli Zaretskii <eliz <at> gnu.org>, 54804 <at> debbugs.gnu.org,
 monnier <at> iro.umontreal.ca, spwhitton <at> spwhitton.name
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Tue, 17 May 2022 22:32:27 +0300
> This is what Emacs does for isearch/search.
>
> If you go to the *scratch* buffer, and you do
> C-s T C-s C-s
> you only jump on 'T', that is, you skip the 't'. This is regardless
> on the `case-fold-search' value.

Isearch has an additional option 'search-upper-case', although
I'm not sure if such complexity is worthy to add to zap-to.
Maybe only for interactive use.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Wed, 18 May 2022 07:26:01 GMT) Full text and rfc822 format available.

Message #80 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: uyennhi.qm <at> gmail.com, 54804 <at> debbugs.gnu.org, schwab <at> linux-m68k.org,
 rpluim <at> gmail.com, spwhitton <at> spwhitton.name
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Wed, 18 May 2022 09:25:46 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> diff --git a/test/lisp/simple-tests.el b/test/lisp/simple-tests.el
>> index dcab811bb5..2baf7124d7 100644
>> --- a/test/lisp/simple-tests.el
>> +++ b/test/lisp/simple-tests.el
>> @@ -971,5 +971,27 @@ test-undo-region
>>      ;;(should (= (length (delq nil (undo-make-selective-list 5 9))) 0))
>>      (should (= (length (delq nil (undo-make-selective-list 6 9))) 0))))
>>  
>> +
>> +;;; Tests for `zap-to-char'
>
> Should we have the tests for zap-* functions in one place, rather than
> two?

My understanding is that we only test in `foo-tests.el' functions
beloging to `foo.el'.
For historical reasons:
`zap-to-char' is defined in simple.el
`zap-up-to-char' is defined in misc.el

We can move the latter to simple.el, then test the functions in the same file.
Some people dislike that because it affects the Git history.
I am OK with whatever the people prefer here.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Fri, 20 May 2022 23:00:03 GMT) Full text and rfc822 format available.

Message #83 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Tino Calancha <tino.calancha <at> gmail.com>, Andreas Schwab
 <schwab <at> linux-m68k.org>
Cc: 54804 <at> debbugs.gnu.org, Eli Zaretskii <eliz <at> gnu.org>,
 Robert Pluim <rpluim <at> gmail.com>, uyennhi.qm <at> gmail.com
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Fri, 20 May 2022 15:59:45 -0700
Hello Tino,

On Thu 12 May 2022 at 05:55pm +02, Tino Calancha wrote:

> commit 86750ab021ea889766a717458ed28a54e6a40ad3
> Author: Tino Calancha <tino.calancha <at> gmail.com>
> Date:   Thu May 12 17:48:09 2022 +0200
>
>     zap-to-char: case sensitive for upper-case characters
>
>     In interactive calls, behave case-sensitively if the given char
>     is an upper-case character.  Same for zap-up-to-char.
>
>     This is analog to what the user-level incremental search feature does.

Could we have a defcustom to always be case-sensitive, please?

I like the way C-s works by default but for zap-* I'd prefer case
sensitivity in every case.

Thanks.

-- 
Sean Whitton




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Sat, 21 May 2022 05:39:01 GMT) Full text and rfc822 format available.

Message #86 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Sean Whitton <spwhitton <at> spwhitton.name>
Cc: uyennhi.qm <at> gmail.com, 54804 <at> debbugs.gnu.org, rpluim <at> gmail.com,
 tino.calancha <at> gmail.com
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Sat, 21 May 2022 08:38:44 +0300
> From: Sean Whitton <spwhitton <at> spwhitton.name>
> Cc: 54804 <at> debbugs.gnu.org, Robert Pluim <rpluim <at> gmail.com>, Eli Zaretskii
>  <eliz <at> gnu.org>, uyennhi.qm <at> gmail.com
> Date: Fri, 20 May 2022 15:59:45 -0700
> 
> > commit 86750ab021ea889766a717458ed28a54e6a40ad3
> > Author: Tino Calancha <tino.calancha <at> gmail.com>
> > Date:   Thu May 12 17:48:09 2022 +0200
> >
> >     zap-to-char: case sensitive for upper-case characters
> >
> >     In interactive calls, behave case-sensitively if the given char
> >     is an upper-case character.  Same for zap-up-to-char.
> >
> >     This is analog to what the user-level incremental search feature does.
> 
> Could we have a defcustom to always be case-sensitive, please?

We already have: case-fold-search.

> I like the way C-s works by default but for zap-* I'd prefer case
> sensitivity in every case.

Why?

It is a slippery slope to have a separate case-sensitivity option for
each command or a couple of commands.  If that is what you want, you
can always write your own one-line wrapper around each of these
commands, but I don't see any reason that Emacs should provide that
for everyone.

So I don't think we should provide such a defcustom for these two
commands.




Reply sent to Tino Calancha <tino.calancha <at> gmail.com>:
You have taken responsibility. (Sat, 21 May 2022 09:32:01 GMT) Full text and rfc822 format available.

Notification sent to Tino Calancha <tino.calancha <at> gmail.com>:
bug acknowledged by developer. (Sat, 21 May 2022 09:32:01 GMT) Full text and rfc822 format available.

Message #91 received at 54804-done <at> debbugs.gnu.org (full text, mbox):

From: Tino Calancha <tino.calancha <at> gmail.com>
To: 54804-done <at> debbugs.gnu.org
Cc: uyennhi.qm <at> gmail.com
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Sat, 21 May 2022 11:30:53 +0200
Eli Zaretskii <eliz <at> gnu.org> writes:

>> From: Sean Whitton <spwhitton <at> spwhitton.name>
>> Could we have a defcustom to always be case-sensitive, please?
>
> We already have: case-fold-search.
> So I don't think we should provide such a defcustom for these two
> commands.

I agree with Eli's point.

Pushed into master branch as commit:
zap-to-char: case sensitive for upper-case characters
(212aea97f9c9fdabdf7e8a47e64c8243953a7690)





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#54804; Package emacs. (Sat, 21 May 2022 18:54:01 GMT) Full text and rfc822 format available.

Message #94 received at 54804 <at> debbugs.gnu.org (full text, mbox):

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: uyennhi.qm <at> gmail.com, 54804 <at> debbugs.gnu.org, rpluim <at> gmail.com,
 tino.calancha <at> gmail.com
Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case
 letter
Date: Sat, 21 May 2022 11:53:44 -0700
Hello,

On Sat 21 May 2022 at 08:38am +03, Eli Zaretskii wrote:

>> Could we have a defcustom to always be case-sensitive, please?
>
> We already have: case-fold-search.
>
>> I like the way C-s works by default but for zap-* I'd prefer case
>> sensitivity in every case.
>
> Why?

Hard to say -- C-s never surprises me but when 'M-z a' jumps to an A it
does :)

> It is a slippery slope to have a separate case-sensitivity option for
> each command or a couple of commands.  If that is what you want, you
> can always write your own one-line wrapper around each of these
> commands, but I don't see any reason that Emacs should provide that
> for everyone.
>
> So I don't think we should provide such a defcustom for these two
> commands.

I agree, adding a wrapper of my own is better.

Thanks for the commit, Tino, and to the reviewers.

-- 
Sean Whitton




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 19 Jun 2022 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 58 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.