Subject: bug#64351: probabe bug associated with “completion-regexp-list”

From: Stefan Monnier <[email-masked]>
Date: Sat, 01 Jul 2023 10:19:50 -0400

>> Bad idea.
>> Admittedly, `completion-regexp-list` is documented poorly enough that
>> it's not clear what usage is valid and what isn't, but a lot of
>> completion code will be broken if you set it globally to anything else
>> than nil.
>
> Would you mind telling more about valid uses of this?
> I'd like to improve the documentation.

Here's what I know: `completion-regexp-list` used to be virtually unused
in Emacs's code base, so I don't know what was its intended use.

But when completion UIs started to offer other styles than just
prefix-based completion, they also started to use
`try/all/test-completion` more "internally" (i.e. for intermediate
computations rather than to compute the final list of completions
displayed to the user) and they did it without paying attention to
`completion-regexp-list`, i.e. in ways which tended to just misbehave
when `completion-regexp-list` wasn't nil.

So, in practice nowadays, the only reliable way to use
`completion-regexp-list` is to think of it as an optional argument to
`try/all/test-completion`, but one that has to be provided via a nearby
let-binding rather than by listing it explicitly at the call site.

> You are saying that you don't like my proposed patch for the emacs-29
> branch, and would even prefer to leave it unfixed?

Your patch is harmless, IMO, so it's OK to install it.

> The binding you propose might be appropriate for master, but not for
> the release branch.

Agreed.

> > Or alternatively to say "if it hurts, don't do that".
> That could be okay, if we also say how to use this variable so it
> doesn't hurt.

My opinion is that we should document that variable as something that's
not meant to be used/set by users, but only one that should be set by
the code that calls `try/all/test-completion`.

        Stefan