diff options
| author | Chong Yidong | 2009-03-18 04:01:05 +0000 |
|---|---|---|
| committer | Chong Yidong | 2009-03-18 04:01:05 +0000 |
| commit | dc1ce9aa18bacf51e434a0957d9ae5c54835b782 (patch) | |
| tree | 3551825b0cd3f9a3b5a4be54f217cfb6f2985240 | |
| parent | f639ba70f66d4770cb698f667b91620e970b77c0 (diff) | |
| download | emacs-dc1ce9aa18bacf51e434a0957d9ae5c54835b782.tar.gz emacs-dc1ce9aa18bacf51e434a0957d9ae5c54835b782.zip | |
(Completion Styles): New node.
| -rw-r--r-- | doc/lispref/minibuf.texi | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi index cb600990f57..121ac486d65 100644 --- a/doc/lispref/minibuf.texi +++ b/doc/lispref/minibuf.texi | |||
| @@ -634,6 +634,7 @@ for reading certain kinds of names with completion. | |||
| 634 | (reading buffer name, file name, etc.) | 634 | (reading buffer name, file name, etc.) |
| 635 | * Reading File Names:: Using completion to read file names and | 635 | * Reading File Names:: Using completion to read file names and |
| 636 | shell commands. | 636 | shell commands. |
| 637 | * Completion Styles:: Specifying rules for performing completion. | ||
| 637 | * Programmed Completion:: Writing your own completion-function. | 638 | * Programmed Completion:: Writing your own completion-function. |
| 638 | @end menu | 639 | @end menu |
| 639 | 640 | ||
| @@ -1532,6 +1533,58 @@ This keymap is used by @code{read-shell-command} for completing | |||
| 1532 | command and file names that are part of a shell command. | 1533 | command and file names that are part of a shell command. |
| 1533 | @end defvar | 1534 | @end defvar |
| 1534 | 1535 | ||
| 1536 | @node Completion Styles | ||
| 1537 | @subsection Completion Styles | ||
| 1538 | @cindex completion styles | ||
| 1539 | |||
| 1540 | A @dfn{completion style} is a set of rules for generating | ||
| 1541 | completions. The user option @code{completion-styles} stores a list | ||
| 1542 | of completion styles, which are represented by symbols. | ||
| 1543 | |||
| 1544 | @defopt completion-styles | ||
| 1545 | This is a list of completion style symbols to use for performing | ||
| 1546 | completion. Each completion style in this list must be defined in | ||
| 1547 | @code{completion-styles-alist}. | ||
| 1548 | @end defopt | ||
| 1549 | |||
| 1550 | @defvar completion-styles-alist | ||
| 1551 | This variable stores a list of available completion styles. Each | ||
| 1552 | element in the list must have the form @samp{(@var{name} | ||
| 1553 | @var{try-completion} @var{all-completions})}. Here, @var{name} is the | ||
| 1554 | name of the completion style (a symbol), which may be used in | ||
| 1555 | @code{completion-styles-alist} to refer to this style. | ||
| 1556 | |||
| 1557 | @var{try-completion} is the function that does the completion, and | ||
| 1558 | @var{all-completions} is the function that lists the completions. | ||
| 1559 | These functions should accept four arguments: @var{string}, | ||
| 1560 | @var{collection}, @var{predicate}, and @var{point}. The @var{string}, | ||
| 1561 | @var{collection}, and @var{predicate} arguments have the same meanings | ||
| 1562 | as in @code{try-completion} (@pxref{Basic Completion}), and the | ||
| 1563 | @var{point} argument is the position of point within @var{string}. | ||
| 1564 | Each function should return a non-@code{nil} value if it performed its | ||
| 1565 | job, and @code{nil} if it did not (e.g., if there is no way to | ||
| 1566 | complete @var{string} according to the completion style). | ||
| 1567 | |||
| 1568 | When the user calls a completion command, such as | ||
| 1569 | @code{minibuffer-complete} (@pxref{Completion Commands}), Emacs looks | ||
| 1570 | for the first style listed in @code{completion-styles} and calls its | ||
| 1571 | @var{try-completion} function. If this function returns @code{nil}, | ||
| 1572 | Emacs moves to the next completion style listed in | ||
| 1573 | @code{completion-styles} and calls its @var{try-completion} function, | ||
| 1574 | and so on until one of the @var{try-completion} functions successfully | ||
| 1575 | performs completion and returns a non-@code{nil} value. A similar | ||
| 1576 | procedure is used for listing completions, via the | ||
| 1577 | @var{all-completions} functions. | ||
| 1578 | @end defvar | ||
| 1579 | |||
| 1580 | By default, @code{completion-styles-alist} contains four pre-defined | ||
| 1581 | completion styles: @code{basic}, a basic completion style; | ||
| 1582 | @code{partial-completion}, which does partial completion (completing | ||
| 1583 | each word in the input separately); @code{emacs22}, which performs | ||
| 1584 | completion according to the rules used in Emacs 22; and | ||
| 1585 | @code{emacs21}, which performs completion according to the rules used | ||
| 1586 | in Emacs 21. | ||
| 1587 | |||
| 1535 | @node Programmed Completion | 1588 | @node Programmed Completion |
| 1536 | @subsection Programmed Completion | 1589 | @subsection Programmed Completion |
| 1537 | @cindex programmed completion | 1590 | @cindex programmed completion |