Next: Completion Options, Previous: Completion Exit, Up: Completion
Completion commands work by narrowing a large list of possible completion alternatives to a smaller subset that “matches” what you have typed in the minibuffer. In Completion Example, we gave a simple example of such matching. The procedure of determining what constitutes a “match” is quite intricate. Emacs attempts to offer plausible completions under most circumstances.
Emacs performs completion using one or more completion styles—sets of criteria for matching minibuffer text to completion alternatives. During completion, Emacs tries each completion style in turn. If a style yields one or more matches, that is used as the list of completion alternatives. If a style produces no matches, Emacs falls back on the next style.
The list variable completion-styles
specifies the completion
styles to use. Each list element is the name of a completion style (a
Lisp symbol). The default completion styles are (in order):
basic
partial-completion
Furthermore, a ‘*’ in the minibuffer text is treated as a
wildcard—it matches any character at the corresponding
position in the completion alternative.
emacs22
basic
, except that it
ignores the text in the minibuffer after point. It is so-named
because it corresponds to the completion behavior in Emacs 22.
The following additional completion styles are also defined, and you
can add them to completion-styles
if you wish
(see Customization):
substring
Thus, if the text in the minibuffer is ‘foobar’, with point
between ‘foo’ and ‘bar’, that matches
‘afoobbarc’, where a, b, and
c can be any string including the empty string.
initials
There is also a very simple completion style called emacs21
.
In this style, if the text in the minibuffer is ‘foobar’,
only matches starting with ‘foobar’ are considered.
You can use different completion styles in different situations,
by setting the variable completion-category-overrides
.
For example, the default setting says to use only basic
and substring
completion for buffer names.