Next: Programmed Completion, Previous: Reading File Names, Up: Completion
A completion style is a set of rules for generating
completions. The user option completion-styles stores a list
of completion styles, which are represented by symbols.
This is a list of completion style symbols to use for performing completion. Each completion style in this list must be defined in
completion-styles-alist.
This variable stores a list of available completion styles. Each element in the list must have the form ‘(name try-completion all-completions)’. Here, name is the name of the completion style (a symbol), which may be used in
completion-styles-alistto refer to this style.try-completion is the function that does the completion, and all-completions is the function that lists the completions. These functions should accept four arguments: string, collection, predicate, and point. The string, collection, and predicate arguments have the same meanings as in
try-completion(see Basic Completion), and the point argument is the position of point within string. Each function should return a non-nilvalue if it performed its job, andnilif it did not (e.g., if there is no way to complete string according to the completion style).When the user calls a completion command, such as
minibuffer-complete(see Completion Commands), Emacs looks for the first style listed incompletion-stylesand calls its try-completion function. If this function returnsnil, Emacs moves to the next completion style listed incompletion-stylesand calls its try-completion function, and so on until one of the try-completion functions successfully performs completion and returns a non-nilvalue. A similar procedure is used for listing completions, via the all-completions functions.
By default, completion-styles-alist contains five pre-defined
completion styles: basic, a basic completion style;
partial-completion, which does partial completion (completing
each word in the input separately); emacs22, which performs
completion according to the rules used in Emacs 22; emacs21,
which performs completion according to the rules used in Emacs 21; and
initials, which completes acronyms and initialisms.