Subject: bug#66187: read-file-name unexpected behavior when MUSTMATCH is a function

From: Stefan Monnier <[email-masked]>
Date: Fri, 06 Oct 2023 09:01:23 -0400

>> >> For example, given:
>> >> 
>> >> (completing-read "Prompt: " '("a" "b") nil
>> >>                  (lambda (input)
>> >>                    (string= "a" input)))
>> >> 
>> >> I expected that the prompt would refuse to complete "b". I was wrong.
>> >> 
>> >> Since completing-read is such a fundamental part of Emacs, I doubt it
>> >> will be possible to change this behavior.  What do you think about the
>> >> attached patch to clarify the completing-read docstring?
>> 
>> The use of a function as `require-match` is brand new in Emacs-29, so
>> I think it's not too late to fix it.  I think rather than fixing the doc
>> we should fix the behavior, e.g. with the patch below.
>
> What change in behavior (wrt Emacs 29.1) does this patch cause?

In the example he gave above it makes it so completion can be used to
insert "b" but when you try to exit it refuses to exit.

IOW it gives primacy to the `require-match` function over the
completion-table w.r.t deciding when the minibuffer's content is
acceptable or not.

Code which wants the 29.1 behavior can easily get it by modifying their
`require-match` function accordingly (and such code then works
correctly both with Emacs-29.1 and with the new behavior).

        Stefan