Subject: bug#22324: 25.0.50; completion-category-defaults style doesn't override completion-styles (gets prepended instead)

From: Dmitry Gutov <[email-masked]>
Date: Wed, 26 Jan 2022 03:43:17 +0200

On 25.01.2022 14:19, Lars Ingebrigtsen wrote:
> Dmitry Gutov <[email-masked]> writes:
> 
>> Given that the only times people are likely to notice the distinction
>> are some odd edge cases (and the extra lag is not so big or obvious),
>> there will be even fewer occasions for people to learn about and
>> customize the new var.
>>
>> Unless we obsolete the previous one, which would be a fair approach,
>> if we knew that it actually has a fair amount of users who need to
>> migrate.
> 
> Hard to say.  Perhaps searching on Github for usages of the variable
> might give us a clue?

Sure.

https://github.com/search?q=%22completion-category-overrides%22&type=code should 
a grand total of 2,433 matches, but the vast majority of those seem to 
be users of Orderless who use this scheme:

   (setq completion-styles '(orderless))
   (setq completion-category-defaults nil)
   (setq completion-category-overrides '((file (styles 
partial-completion))))

Some add 'basic' before 'partial-completion' for better "Tramp hostname 
completion".

Do these users expect the failover to the orderless style when 
partial-completion fails to complete? Possible. Orderless is more lax.

But also kinda doubtful since partial-completion is fairly powerful by 
itself, and entering the segments of a file name in a different order is 
not something does often or intentionally.

Apparently this config is recommended in the README of both Corfu and 
Vertico (https://github.com/minad/vertico#configuration), both projects 
by Daniel Mendler.

I guess we should ask Daniel whether he has been aware of the 
completion-styles failover mechanic, and what he thinks about it.

***

And there are occasionally configs like

   (setq completion-styles
         '(partial-completion substring initials basic))
   ;; override default completion style of specific modes
   (setq completion-category-overrides
         '((file (styles . (flex)))
           (buffer (styles . (flex)))
           (project-file (styles . (flex)))
           (info-menu (styles . (flex)))))

where the override is explicitly more powerful, so we know that failover 
is not desirable, just wasted CPU cycles.