Subject: bug#77718: 31.0.50; completion styles substring and flex are broken

From: Stefan Monnier <[email-masked]>
Date: Wed, 16 Apr 2025 14:29:56 -0400

>> [ Also, I'm not sure it's worth the trouble anyway: dollars in file names
>>   are fairly rare, so having to double them in those rare cases where they
>>   occur is not a big deal.  In any case, it seems orthogonal to the
>>   problem at hand.  ]
> That's fair - so you think it might be OK to, basically, not support
> completion on file names containing substrings like "$HOME"?

Of course we support it, but we require the use of `$$HOME` to state
clearly which interpretation you want.

> This TAB behavior doesn't help if I manually type $HOME though, right?

Presumably if you type `$HOME` it means you want the value of the HOME
envvar.  If you want the file named `$HOME` you need to type `$$HOME`.

When the typing is done by the completion code, it's up to the
completion code to apply that same rule.

> So here's one idea: Since this only works if I tab-complete, that means
> it only works for files which actually exist.  So, instead, I could have
> read-file-name check if the file (e.g. "~/tmp/foo$HOME.txt") exists
> before expanding environment variables; if the file exists, don't expand
> environment variables.  This avoids the need to duplicate $s.

But then we'd need to add some way for the user to say "I really want
this $HOME to be expanded even though there is also a file by that funny
name".

[ In any case, this is not a question of completion but of
  `read-file-name`.  ]

        Stefan