Subject: Re: bug#54804: 29.0.50; zap-to-char: case sensitive for upper-case letter

From: Eli Zaretskii <[email-masked]>
Date: Fri, 13 May 2022 09:48:41 +0300

> From: Tino Calancha <[email-masked]>
> Cc: [email-masked],  Robert Pluim <[email-masked]>,  Eli Zaretskii
>  <[email-masked]>,  [email-masked],  [email-masked]
> 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.