bug#38101: User's customization to completion-styles requires tweak to completion-category-defaults

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

bug#38101: User's customization to completion-styles requires tweak to completion-category-defaults

João Távora
> >     (setq completion-styles '(flex))
> >     (setq completion-category-defaults nil )
>
> Ha, I was just thinking about that: could you open a bug report about
> the need for tweaking completion-category-defaults?
> Note: the above `setq` isn't enough because packages can (and do) add
> themselves to completion-category-defaults later on.
>
>         Stefan

Hi maintainers,

As you can read in the above conversation, completion-category-defaults
needs to be tweaked to "unshadow" the user's customization to
completion-styles.

This is a bug report to track any possible improvements that can be done
in this regard.

João



Reply | Threaded
Open this post in threaded view
|

bug#38101: User's customization to completion-styles requires tweak to completion-category-defaults

Eli Zaretskii
> From: João Távora <[hidden email]>
> Date: Thu, 7 Nov 2019 14:22:29 +0000
>
> > >     (setq completion-styles '(flex))
> > >     (setq completion-category-defaults nil )
> >
> > Ha, I was just thinking about that: could you open a bug report about
> > the need for tweaking completion-category-defaults?
> > Note: the above `setq` isn't enough because packages can (and do) add
> > themselves to completion-category-defaults later on.
> >
> >         Stefan
>
> Hi maintainers,
>
> As you can read in the above conversation, completion-category-defaults
> needs to be tweaked to "unshadow" the user's customization to
> completion-styles.

Please help me to find this conversation by giving some URL or Subject
and Date.

Thanks.



Reply | Threaded
Open this post in threaded view
|

bug#38101: User's customization to completion-styles requires tweak to completion-category-defaults

João Távora
On Thu, Nov 7, 2019 at 2:46 PM Eli Zaretskii <[hidden email]> wrote:
> > Hi maintainers,
> >
> > As you can read in the above conversation, completion-category-defaults
> > needs to be tweaked to "unshadow" the user's customization to
> > completion-styles.
>
> Please help me to find this conversation by giving some URL or Subject
> and Date.

Sorry Eli, this was sent to me off-list by Stefan.  I just noticed it now.
(Also very sorry Stefan, this was a mistake).

Eli, the conversation you want is in Emacs devel, a reply of mine
to Oscar Fuentes yesterday, with a subject that includes "fido-mode".

João



Reply | Threaded
Open this post in threaded view
|

bug#38101: User's customization to completion-styles requires tweak to completion-category-defaults

Eli Zaretskii
> From: João Távora <[hidden email]>
> Date: Thu, 7 Nov 2019 15:09:04 +0000
> Cc: [hidden email]
>
> > Please help me to find this conversation by giving some URL or Subject
> > and Date.
>
> Sorry Eli, this was sent to me off-list by Stefan.  I just noticed it now.
> (Also very sorry Stefan, this was a mistake).
>
> Eli, the conversation you want is in Emacs devel, a reply of mine
> to Oscar Fuentes yesterday, with a subject that includes "fido-mode".

Thanks, but that thread is huge, and you've posted quite a lot there.
Could you perhaps state the URL of that message in the emacs-devel
archives?



Reply | Threaded
Open this post in threaded view
|

bug#38101: User's customization to completion-styles requires tweak to completion-category-defaults

João Távora
Reply | Threaded
Open this post in threaded view
|

bug#38101: User's customization to completion-styles requires tweak to completion-category-defaults

Eli Zaretskii
> From: João Távora <[hidden email]>
> Date: Thu, 7 Nov 2019 16:02:03 +0000
> Cc: [hidden email]
>
> Sure thing.
>
> https://lists.gnu.org/archive/html/emacs-devel/2019-11/msg00227.html

Thanks, but I see no references there to completion-category-defaults
or anything along those lines.

Perhaps Stefan or someone else could describe the actual problem in
this bug report?

TIA



Reply | Threaded
Open this post in threaded view
|

bug#38101: User's customization to completion-styles requires tweak to completion-category-defaults

João Távora
On Fri, Nov 8, 2019 at 2:20 PM Eli Zaretskii <[hidden email]> wrote:

>
> > From: João Távora <[hidden email]>
> > Date: Thu, 7 Nov 2019 16:02:03 +0000
> > Cc: [hidden email]
> >
> > Sure thing.
> >
> > https://lists.gnu.org/archive/html/emacs-devel/2019-11/msg00227.html
>
> Thanks, but I see no references there to completion-category-defaults
> or anything along those lines.

It's on line 23-24 of the linked email's body.

As I wrote, this is the problem:

JT >  completion-category-defaults
JT > needs to be tweaked to "unshadow" the user's customization to
JT > completion-styles.

This means that if you customize completion-styles, you also need
to tweak completion-category-defaults, because the latter shadows
the former. Stefan thinks this is a bug, and so do I.

Moreover, Stefan has stated that you need to "constantly" tweak
completion-category-defaults because other packages might
add to it.

I haven't analyzed the problem sufficiently to tell you _why_ the
shadowing happens, just that it happens.

João



Reply | Threaded
Open this post in threaded view
|

bug#38101: User's customization to completion-styles requires tweak to completion-category-defaults

Eli Zaretskii
> From: João Távora <[hidden email]>
> Date: Fri, 8 Nov 2019 15:15:35 +0000
> Cc: Stefan Monnier <[hidden email]>, [hidden email]
>
> JT >  completion-category-defaults
> JT > needs to be tweaked to "unshadow" the user's customization to
> JT > completion-styles.
>
> This means that if you customize completion-styles, you also need
> to tweak completion-category-defaults, because the latter shadows
> the former. Stefan thinks this is a bug, and so do I.
>
> Moreover, Stefan has stated that you need to "constantly" tweak
> completion-category-defaults because other packages might
> add to it.
>
> I haven't analyzed the problem sufficiently to tell you _why_ the
> shadowing happens, just that it happens.

Thanks, this does explain the issue nicely.



Reply | Threaded
Open this post in threaded view
|

bug#38101: User's customization to completion-styles requires tweak to completion-category-defaults

Stefan Monnier
In reply to this post by João Távora
>> >     (setq completion-styles '(flex))
>> >     (setq completion-category-defaults nil)

Right: `completion-category-defaults` lets us specify different default
completion styles for particular cases, but it doesn't clearly says "how
different" and instead just overrides the global setting.

In practice it's been used so far to override the default (mostly)
prefix completion with substring completion, IOW the override is
performed in order to use a "more lax" completion (where "lax" here can
be understood as the size of the set of matching candidates for a given
pattern: `substring` matches more candidates than `basic` so it is "more
lax").

But if the user sets the default completion style to a "very lax" style
such as `flex` then the override doesn't work as intended any more.

It won't completely prevent the use of `flex` luckily:

    (defun completion--styles (metadata)
      (let* ((cat (completion-metadata-get metadata 'category))
             (over (completion--category-override cat 'styles)))
        (if over
            (delete-dups (append (cdr over) (copy-sequence completion-styles)))
           completion-styles)))

So, if the default `completion-styles` is `(flex)` and the
`completion-category-defaults` specifies, say, `(basic substring)`, then
the result is to use `(basic substring flex)` which still includes
`flex` (hence the problem is not too crippling) but `flex` will only be
used when both `basic` and `substring` fail to find any matching
candidates, which is not what was desired.  In this specific case is
`basic` or `substring` find matching candidates those would also have
been returned by `flex` and (presumably) with the best scores, so the
end result (compared to only using `flex`) is mostly that *Completions*
gets truncated.


        Stefan