GNU bug report logs -
#66187
read-file-name unexpected behavior when MUSTMATCH is a function
Previous Next
Full log
View this message in rfc822 format
> Cc: philipk <at> posteo.net, 66187 <at> debbugs.gnu.org
> Date: Tue, 03 Oct 2023 14:18:42 -0700
> From: Joseph Turner via "Bug reports for GNU Emacs,
> the Swiss army knife of text editors" <bug-gnu-emacs <at> gnu.org>
>
> I dug a little more and realized that the IMO unexpected behavior
> resides in completing-read itself. According to the completing-read
> docstring, its REQUIRE-MATCH argument can be
>
> - a function, which will be called with the input as the
> argument. If the function returns a non-nil value, the
> minibuffer is exited with that argument as the value.
>
> I incorrectly assumed that this function would prevent matching items
> inside COLLECTION for which the function returns nil. What it actually
> does it accept input which is not part of COLLECTION if the
> REQUIRE-MATCH function returns non-nil. IOW, it doesn't narrow the
> potential completion options; it widens them.
>
> 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?
I don't think I see how your proposed change clarifies this issue.
Adding Stefan for possibly more comments and ideas.
This bug report was last modified 1 year and 173 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.