Subject: Re: bug#71078: rgrep accepts wildcard, then throws it away

From: Stefan Monnier <[email-masked]>
Date: Tue, 21 May 2024 11:30:59 -0400

>     (read-directory-name "Base directory: "
>                          nil default-directory t)
>
> If I give an input like "/tmp* RET" at the prompt, it returns "/tmp/".
>
> What's confusing to me is this part in the docstring of
> `read-directory-name':
>
>     Fourth arg MUSTMATCH non-nil means require existing directory’s name.
>     Non-nil and non-t means also require confirmation after completion.
>
> I think "require existing directory’s name" should be clarified to say:
> "require the user to input an existing directory's name", if that is
> indeed the intention here.

That's indeed the intention (and the way I read it, that's what it says).

> That it removes the "*" character seems to be undocumented, but if
> that's the intended behaviour perhaps it should be clarified too.  Hmm.

It does not remove the *.  What you're seeing is the effect of
completion (and `partial-completion` treats the * as a wildcard for
completion purposes) so you can also just type `/tm` and it should
return the same thing (provided `/tmp/` is the sole completion).

> I think this is expected, and not a bug, due to this part in grep.el:
>
>      (unless (and dir (file-accessible-directory-p dir))
>        (setq dir default-directory))
>
> I'd rather it would signal an error in this case, to be honest, because

Agreed.  The above can only make sense when `dir` doesn't matter.

        Stefan