bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: Stefan Monnier
Subject: bug#38101: User's customization to completion-styles requires tweak to completion-category-defaults
Date: Fri, 08 Nov 2019 12:14:31 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

>> >     (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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]