It doesn't seem to affect `C-x b` the same way as, e.g., `M-x`
cyrus-and opened this issue · comments
I have to admit my ignorance here, I'm new to this whole completion thing of emacs. In my head, using orderless
would mean that it is used (by default) every time there's a minibuffer completion to be performed. But I noticed some differences of behaviour when I switch to a buffer (C-x b
) compared when I execute an interactive command (M-x
). It seems to me that in the former case the default basic
completion is used. Here's how I can reproduce this:
-
start Emacs (29.0.60) with:
HOME="$(mktemp -d)" \emacs
-
install
orderless
:M-x package-install RET orderless RET
-
evaluate:
(custom-set-variables '(completion-styles '(orderless)))
Now if I type M-x scr TAB
, the *Completions*
window pops up with a bunch of candidates, both starting with and including scr
.
In I instead create a buffer named screens
(names here are just an example) with C-x b screens RET
, then I C-x b scr TAB
I obtain screens
as the sole completion, despite there's also the *scratch*
buffer in the list, in fact pressing tab with the empty prompt yields the whole list (including *scratch*
). I suspect that in this case Emacs is falling back to the basic
completion style, and you can figure this out by styling orderless-match-faces
differently, I guess.
This is unexpected to me, or maybe is this just my misunderstanding? In any case how can I obtain a consistent behaviour across all the completion contexts?
There is a default entry for buffer
in completion-category-defaults
. If you want to always use orderless
for everything you should set both completion-category-defaults
and completion-category-overrides
to nil. I used orderless
exclusively for a long time, but eventually @minad convinced me that the best option is as described in the README:
(setq completion-styles '(orderless basic)
completion-category-defaults nil
completion-category-overrides
'((file
(styles basic partial-completion))))
Notice that "overrides" is a bit of a misnomer: the styles included in completion-category-overrides
are tried first, if none match, it goes back to completion-styles
, so even with the configuration you posted, you can still get orderless to match by simply adding a space after: scr
.
That makes sense, thank you so much for the detailed explanation.