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

From: Stephen Berman <[email-masked]>
Date: Tue, 15 Apr 2025 10:22:15 +0200

On Mon, 14 Apr 2025 16:30:09 -0400 Spencer Baugh <[email-masked]> wrote:

> Stefan Monnier <[email-masked]> writes:
>
>>> Stefan, a related question: do you think it would be reasonable to split
>>> completion-table-with-quoting into two functions, separating the
>>> substitute-in-file-name and comint-quote-filename cases?  It seems to me
>>> that the comint-quote-filename case is way simpler than the
>>> substitute-in-file-name case, and it would be a lot easier to understand
>>> if the two cases were done separately, without the abstraction of
>>> requote and unquote functions.  I can do that if that seems reasonable.
>>> It would make fixing this issue a lot easier.
>>
>> It's worth a try.  The system we have is the best I could come up with
>> back then but is hideous, so I'm interested in a simpler solution.
>
> OK, here is a rework of just the substitute-in-file-name side.  This
> fixes this bug (by making completion continue to work when point is at
> /usr/|/), and fixes another FIXME in a test (partial completion now
> preserves environment variables!).  And I don't think it loses anything
> important, but I may be missing something.
>
> (completion--sifn-requote can now be deleted and there are probably
> other cleanups possible after this patch, but I didn't do them here to
> keep the patch smaller.  Also, rfn-eshadow needs to be updated, but
> that's just a visual issue.)

Thanks, I applied your patch and rebuilt emacs, and now completion with
the substring style works, but it's still different from the behavior
before you previous change, as your comments above seem to acknowledge:
now when I enter "/us" and hit TAB, it completes to "/usr/" and when I
hit TAB again it becomes "/usr//" with point on (i.e. just before) the
last slash and "/usr/" displayed with the file-name-shadow face.
Hitting TAB again pops up a *Completions* buffer with the correct
completions (immediate subdirectories of /usr) and typing part of a
candidate in the minibuffer correctly expands the file name.  This
behavior obtains with any directory whose immediate children are all
directories; if at least one child is a non-directory file, the
*Completions* buffer up on hitting the TAB the second time (and the part
of the file name up to the final slash has the default face); so here
the completion works also visually as before.  So your patch only
partially fixes the regression.

Steve Berman