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

From: Stefan Monnier <[email-masked]>
Date: Tue, 15 Apr 2025 17:04:43 -0400

> Fix various bugs, including bug#77718, by rewriting the way file
> name completion handles environment variable expansion.  Instead
> of using completion-table-with-quoting to manipulate the string
> being completed on, simply make the completion table itself
> understand substitute-in-file-name.

OK.

> The completion table first tries to complete without
> substituting environment variables; this allows completion to
> work on file names which contain things which look like
> environment variables.  If that fails, we call
> substitute-in-file-name and then complete again.

Why?  `substitute-in-file-name` presumably already takes care of that:

    (substitute-in-file-name "/foo/$NOTAVAR/bar")
    => "/foo/$NOTAVAR/bar"

> Tests are updated: we no longer duplicate $s in file names,
> since that's not necessary.

AFAIK it is still needed for the (null action) case.

> And partial-completion now
> preserves unexpanded environment variables.  However,
> partial-completion no longer works across environment variables
> containing delimiters; that's an acceptable sacrifice.

Agreed.

> * lisp/minibuffer.el (completion--replace-prefix)
> (completion--complete-on-expansion): Add.
> (completion--file-name-table): Rewrite to use
> substitute-in-file-name explicitly. (bug#77718)

I think you can also delete `completion--sifn-requote` while at it.

        Stefan