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

From: Dmitry Gutov <[email-masked]>
Date: Mon, 24 Jan 2022 04:03:17 +0200

On 21.01.2022 15:46, Lars Ingebrigtsen wrote:
> Lars Ingebrigtsen<[email-masked]>  writes:
> 
>> Dmitry Gutov<[email-masked]>  writes:
>>
>>> Consider changing the behavior instead, though.
>>>
>>> Yes, it's been like this for a long time, but I imagine most users
>>> won't notice the change.
>>>
>>> We could experiment on master.
>> I'd rather not change something as subtle as this (especially in a
>> mechanism that's been around for a while like this as).
> Nobody had any further opinions here in a month, so I went ahead and
> changed the doc string.  If somebody feels strongly that the semantics
> should be tweaked, I don't really have a strong opinion either way.

Hi Lars,

The doc change you have pushed in 62a84eea34c33bd1d4b1 misses the point, 
which leads me to believe that I have not explained the problem well.

The issue is not that an entry in completion-category-overrides doesn't 
override all properties wholesale, that is falls back to defaults for 
properties not specified among the overrides.

The issue is that when the 'styles' property is looked up (which is 99% 
of the uses of this variable), the override value is not used as-is. 
Instead, the default value is appended.

So the fix I had in mind looks like:

diff --git a/lisp/minibuffer.el b/lisp/minibuffer.el
index d58c23af8f..0aee55f33c 100644
--- a/lisp/minibuffer.el
+++ b/lisp/minibuffer.el
@@ -1043,7 +1043,7 @@ completion--styles
    (let* ((cat (completion-metadata-get metadata 'category))
           (over (completion--category-override cat 'styles)))
      (if over
-        (delete-dups (append (cdr over) (copy-sequence completion-styles)))
+        (cdr over)
         completion-styles)))

  (defun completion--nth-completion (n string table pred point metadata)