* doc/lispref/minibuf.texi (Programmed Completion): Document metadata method.

(Completion Variables): Document completion-category-overrides.
This commit is contained in:
Chong Yidong 2012-04-06 14:39:35 +08:00
parent c8bf3227a2
commit ea0ff31442
2 changed files with 80 additions and 14 deletions

View file

@ -1,9 +1,12 @@
2012-04-06 Chong Yidong <cyd@gnu.org>
* minibuf.texi (Programmed Completion): Document metadata method.
(Completion Variables): Document completion-category-overrides.
2012-04-05 Chong Yidong <cyd@gnu.org> 2012-04-05 Chong Yidong <cyd@gnu.org>
* anti.texi (Antinews): Rewrite for Emacs 23. * anti.texi (Antinews): Rewrite for Emacs 23.
* minibuf.texi (Programmed Completion): Document metadata method.
2012-04-04 Chong Yidong <cyd@gnu.org> 2012-04-04 Chong Yidong <cyd@gnu.org>
* minibuf.texi (Programmed Completion): Remove obsolete variable * minibuf.texi (Programmed Completion): Remove obsolete variable

View file

@ -1575,12 +1575,10 @@ completion behavior.
@cindex completion styles @cindex completion styles
@defopt completion-styles @defopt completion-styles
The value of this variable is a list of completion styles to use for The value of this variable is a list of completion style (symbols) to
performing completion. A @dfn{completion style} is a set of rules for use for performing completion. A @dfn{completion style} is a set of
generating completions. rules for generating completions. Each symbol in occurring this list
must have a corresponding entry in @code{completion-styles-alist}.
Each style listed in this variable must be one of those defined in
@code{completion-styles-alist}.
@end defopt @end defopt
@defvar completion-styles-alist @defvar completion-styles-alist
@ -1588,15 +1586,16 @@ This variable stores a list of available completion styles. Each
element in the list has the form element in the list has the form
@example @example
(@var{name} @var{try-completion} @var{all-completions} @var{doc}) (@var{style} @var{try-completion} @var{all-completions} @var{doc})
@end example @end example
@noindent @noindent
Here, @var{name} is the name of the completion style (a symbol), which Here, @var{style} is the name of the completion style (a symbol),
may be used in @code{completion-styles-alist} to refer to this style; which may be used in the @code{completion-styles} variable to refer to
@var{try-completion} is the function that does the completion; this style; @var{try-completion} is the function that does the
@var{all-completions} is the function that lists the completions; and completion; @var{all-completions} is the function that lists the
@var{doc} is a string describing the completion style. completions; and @var{doc} is a string describing the completion
style.
The @var{try-completion} and @var{all-completions} functions should The @var{try-completion} and @var{all-completions} functions should
each accept four arguments: @var{string}, @var{collection}, each accept four arguments: @var{string}, @var{collection},
@ -1622,6 +1621,31 @@ listing completions, via the @var{all-completions} functions.
description of the available completion styles. description of the available completion styles.
@end defvar @end defvar
@defopt completion-category-overrides
This variable specifies special completion styles and other completion
behaviors to use when completing certain types of text. Its value
should be a list of the form @code{(@var{category} . @var{alist})}.
@var{category} is a symbol describing what is being completed;
currently, the @code{buffer} and @code{file} categories are defined,
but others can be defined via specialized completion functions
(@pxref{Programmed Completion}). @var{alist} is an association list
describing how completion should behave for the corresponding
category. The following alist keys are supported:
@table @code
@item styles
The value should be a list of completion styles (symbols).
@item cycle
The value should be a value for @code{completion-cycle-threshold}
(@pxref{Completion Options,,, emacs, The GNU Emacs Manual}) for this
category.
@end table
@noindent
Additional alist entries may be defined in the future.
@end defopt
@defvar completion-extra-properties @defvar completion-extra-properties
This variable is used to specify extra properties of the current This variable is used to specify extra properties of the current
completion command. It is intended to be let-bound by specialized completion command. It is intended to be let-bound by specialized
@ -1706,9 +1730,48 @@ This specifies a @code{completion-boundaries} operation. The function
should return @code{(boundaries START . END)}, where START is the should return @code{(boundaries START . END)}, where START is the
position of the beginning boundary in the specified string, and END is position of the beginning boundary in the specified string, and END is
the position of the end boundary in SUFFIX. the position of the end boundary in SUFFIX.
@item metadata
This specifies a request for information about the state of the
current completion. The function should return an alist, as described
below. The alist may contain any number of elements.
@end table @end table
@noindent
If the flag has any other value, the completion function should return
@code{nil}.
@end itemize @end itemize
The following is a list of metadata entries that a completion function
may return in response to a @code{metadata} flag argument:
@table @code
@item category
The value should be a symbol describing what kind of text the
completion function is trying to complete. If the symbol matches one
of the keys in @code{completion-category-overrides}, the usual
completion behavior is overridden. @xref{Completion Variables}.
@item annotation-function
The value should be a function for @dfn{annotating} completions. The
function should take one argument, @var{string}, which is a possible
completion. It should return a string, which is displayed after the
completion @var{string} in the @samp{*Completions*} buffer.
@item display-sort-function
The value should be a function for sorting completions. The function
should take one argument, a list of completion strings, and return a
sorted list of completion strings. It is allowed to alter the input
list destructively.
@item cycle-sort-function
The value should be a function for sorting completions, when
@code{completion-cycle-threshold} is non-@code{nil} and the user is
cycling through completion alternatives. @xref{Completion Options,,,
emacs, The GNU Emacs Manual}. Its argument list and return value are
the same as for @code{display-sort-function}.
@end table
@defun completion-table-dynamic function @defun completion-table-dynamic function
This function is a convenient way to write a function that can act as This function is a convenient way to write a function that can act as
programmed completion function. The argument @var{function} should be programmed completion function. The argument @var{function} should be