all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: "João Távora" <joaotavora@gmail.com>
Cc: 38101@debbugs.gnu.org
Subject: bug#38101: User's customization to completion-styles requires tweak to completion-category-defaults
Date: Fri, 08 Nov 2019 12:14:31 -0500	[thread overview]
Message-ID: <jwvk18a1fgj.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <CALDnm51NRMp9ehNpz0OShWfL4CxvSZtLMNUPTbstWZabiydPdg@mail.gmail.com> ("João Távora"'s message of "Thu, 7 Nov 2019 14:22:29 +0000")

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






      parent reply	other threads:[~2019-11-08 17:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-07 14:22 bug#38101: User's customization to completion-styles requires tweak to completion-category-defaults João Távora
2019-11-07 14:45 ` Eli Zaretskii
2019-11-07 15:09   ` João Távora
2019-11-07 15:43     ` Eli Zaretskii
2019-11-07 16:02       ` João Távora
2019-11-08 14:19         ` Eli Zaretskii
2019-11-08 15:15           ` João Távora
2019-11-08 15:35             ` Eli Zaretskii
2019-11-08 17:14 ` Stefan Monnier [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvk18a1fgj.fsf-monnier+emacs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=38101@debbugs.gnu.org \
    --cc=joaotavora@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.