Subject: Re: bug#70217: [PATCH] Add substring-partial-completion style

From: Eshel Yaron <[email-masked]>
Date: Sat, 06 Apr 2024 10:10:40 +0200

Drew Adams writes:

>> > It's preferable for this to be a separate style from partial-completion
>> > rather than a customization for partial-completion, because completing
>> > with a leading glob is inefficient: it doesn't allow the completion
>> > table to do any filtering at all.  So, for example, one might want the
>> > regular partial-completion style to run first, and if it doesn't find
>> > anything then the substring-partial-completion style can run.
>>
>> FWIW, I think the "language of completion styles"
>> would benefit from being a bit richer.
>
> FWIW, I agree.  Richer in different ways/dimensions.
>
>> I.e. instead of a completion style (i.e. an entry
>> in `completion-styles`) being limited to a symbol,
>> we could extend it so a style can take arguments.

One thing to keep in mind is that such parameterized completion styles
would make user interaction with completion styles more complicated.
It's much easier to indicate the effective completion style to the user,
and to allow them to pick and choose their completion styles on the fly,
when these completion styles are mere symbols.  (Currently Emacs doesn't
provide such UI for completion styles, but I proposed something along
these lines in branch feature/minibuffer-completion-enhancements.)

>>
>> E.g. the `substring` style could take an argument
>> which when set to the symbol `pcm` would cause it
>> to behave like your "substring-partial-completion":
>> (setq completion-styles '(basic (substring pcm) emacs22))
>>
>> Alternatively, it could be an argument to `partial-completion`, e.g.:
>> (setq completion-styles '(basic (partial-completion notanchored) emacs22))

[...]

> ...you have no way of knowing which style was
> actually used to produce a given set of candidates.
> For users, the link (cognitive and otherwise) is
> lost between a style and its completions for a
> given input pattern.

+1

I agree it's quite important to indicate which completion style produced
what you're seeing, at the very least such indication makes it clear
where you should look if you don't like the completions you got.

Best,

Eshel