Subject: bug#19031: 24.4; find-file in icomplete-mode shows completions with no input

From: Andrii Kolomoiets <[email-masked]>
Date: Tue, 08 Dec 2020 12:43:21 +0200

Juri Linkov <[email-masked]> writes:

>> I originally reported this because I found it jarring to get a bunch
>> of completions without having entered anything. In my home dir it
>> basically shows me garbage (dot files that I'm never interested in).
>>
>> Would it not be possible to make a difference between the case where
>> find-file provides some default text (current dir) and where I have
>> entered some input? The variable literally says -on-no-input.
>
> I tried to handle this case with the following patch, but it doesn't work
> because read-file-name-default resets `minibuffer-default' to nil,
> so icomplete doesn't know what was initial input in the minibuffer.

1. emacs -Q
2. M-: (setq insert-default-directory nil)
3. M-x icomplete-mode
4. C-x C-f ~/

In this case everything works as described by the docstring: user input
is here so completions are shown.  But IMO Ole's issue is not
completely solved: bunch of uninteresting dotfiles are shown.

I was thinking about some method wich will allow to tell that minibuffer
is empty even if there are some user input.  From your patch I learned
about the 'minibuffer-default' variable and looks like it can be the
method I was thinking of.

If the 'read-file-name-default' function can set the
'minibuffer-default' variable to the substring of the minibuffer content
from (minibuffer-prompt-end) to the last occurence of the path
separator, then, in addition to the patched 'icomplete-exhibit', this
can give desired result: no completions will be show until some input
after path separator.

WDYT?