aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorChong Yidong2012-04-04 17:19:32 +0800
committerChong Yidong2012-04-04 17:19:32 +0800
commit321cc491c5843ee3af86570d5b2d59b98ba0c422 (patch)
tree118c8469015212fc05c255de56d2b72eba2be128 /doc
parenta7972adfd8c545a603e395153ba6537e6d573864 (diff)
downloademacs-321cc491c5843ee3af86570d5b2d59b98ba0c422.tar.gz
emacs-321cc491c5843ee3af86570d5b2d59b98ba0c422.zip
Document completion-extra-properties in Lisp manual.
* doc/lispref/minibuf.texi (Programmed Completion): Remove obsolete variable completion-annotate-function. (Completion Variables): Rename from Completion Styles. Document completion-extra-properties. Document completion-styles-alist change. * lisp/minibuffer.el (completion-extra-properties): Doc fix.
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/ChangeLog6
-rw-r--r--doc/lispref/elisp.texi4
-rw-r--r--doc/lispref/minibuf.texi191
-rw-r--r--doc/lispref/vol1.texi4
-rw-r--r--doc/lispref/vol2.texi4
5 files changed, 112 insertions, 97 deletions
diff --git a/doc/lispref/ChangeLog b/doc/lispref/ChangeLog
index 89e740603f8..6385400572e 100644
--- a/doc/lispref/ChangeLog
+++ b/doc/lispref/ChangeLog
@@ -1,5 +1,11 @@
12012-04-04 Chong Yidong <cyd@gnu.org> 12012-04-04 Chong Yidong <cyd@gnu.org>
2 2
3 * minibuf.texi (Programmed Completion): Remove obsolete variable
4 completion-annotate-function.
5 (Completion Variables): Rename from Completion Styles. Document
6 completion-extra-properties. Document completion-styles-alist
7 change.
8
3 * display.texi (Delayed Warnings): New node. 9 * display.texi (Delayed Warnings): New node.
4 10
5 * os.texi (Notifications): Copyedits. 11 * os.texi (Notifications): Copyedits.
diff --git a/doc/lispref/elisp.texi b/doc/lispref/elisp.texi
index 508b0251a7a..a87a7ff3fa2 100644
--- a/doc/lispref/elisp.texi
+++ b/doc/lispref/elisp.texi
@@ -649,8 +649,8 @@ Completion
649 (reading buffer name, file name, etc.). 649 (reading buffer name, file name, etc.).
650* Reading File Names:: Using completion to read file names and 650* Reading File Names:: Using completion to read file names and
651 shell commands. 651 shell commands.
652* Completion Styles:: Specifying rules for performing completion. 652* Completion Variables:: Variables controlling completion behavior.
653* Programmed Completion:: Writing your own completion-function. 653* Programmed Completion:: Writing your own completion function.
654* Completion in Buffers:: Completing text in ordinary buffers. 654* Completion in Buffers:: Completing text in ordinary buffers.
655 655
656Command Loop 656Command Loop
diff --git a/doc/lispref/minibuf.texi b/doc/lispref/minibuf.texi
index 1224d80fdf8..0d7e2350bd7 100644
--- a/doc/lispref/minibuf.texi
+++ b/doc/lispref/minibuf.texi
@@ -631,8 +631,8 @@ for reading certain kinds of names with completion.
631 (reading buffer name, file name, etc.). 631 (reading buffer name, file name, etc.).
632* Reading File Names:: Using completion to read file names and 632* Reading File Names:: Using completion to read file names and
633 shell commands. 633 shell commands.
634* Completion Styles:: Specifying rules for performing completion. 634* Completion Variables:: Variables controlling completion behavior.
635* Programmed Completion:: Writing your own completion-function. 635* Programmed Completion:: Writing your own completion function.
636* Completion in Buffers:: Completing text in ordinary buffers. 636* Completion in Buffers:: Completing text in ordinary buffers.
637@end menu 637@end menu
638 638
@@ -795,7 +795,7 @@ example for @code{try-completion}:
795@defun test-completion string collection &optional predicate 795@defun test-completion string collection &optional predicate
796@anchor{Definition of test-completion} 796@anchor{Definition of test-completion}
797This function returns non-@code{nil} if @var{string} is a valid 797This function returns non-@code{nil} if @var{string} is a valid
798completion possibility specified by @var{collection} and 798completion alternative specified by @var{collection} and
799@var{predicate}. The arguments are the same as in 799@var{predicate}. The arguments are the same as in
800@code{try-completion}. For instance, if @var{collection} is a list of 800@code{try-completion}. For instance, if @var{collection} is a list of
801strings, this is true if @var{string} appears in the list and 801strings, this is true if @var{string} appears in the list and
@@ -1429,7 +1429,7 @@ current buffer visit no file using @code{M-x set-visited-file-name}.
1429 1429
1430If @var{predicate} is non-@code{nil}, it specifies a function of one 1430If @var{predicate} is non-@code{nil}, it specifies a function of one
1431argument that decides which file names are acceptable completion 1431argument that decides which file names are acceptable completion
1432possibilities. A file name is an acceptable value if @var{predicate} 1432alternatives. A file name is an acceptable value if @var{predicate}
1433returns non-@code{nil} for it. 1433returns non-@code{nil} for it.
1434 1434
1435Here is an example of using @code{read-file-name}: 1435Here is an example of using @code{read-file-name}:
@@ -1480,7 +1480,7 @@ when performing completion.
1480 1480
1481@defun read-directory-name prompt &optional directory default require-match initial 1481@defun read-directory-name prompt &optional directory default require-match initial
1482This function is like @code{read-file-name} but allows only directory 1482This function is like @code{read-file-name} but allows only directory
1483names as completion possibilities. 1483names as completion alternatives.
1484 1484
1485If @var{default} is @code{nil} and @var{initial} is non-@code{nil}, 1485If @var{default} is @code{nil} and @var{initial} is non-@code{nil},
1486@code{read-directory-name} constructs a substitute default by 1486@code{read-directory-name} constructs a substitute default by
@@ -1563,57 +1563,85 @@ This keymap is used by @code{read-shell-command} for completing
1563command and file names that are part of a shell command. 1563command and file names that are part of a shell command.
1564@end defvar 1564@end defvar
1565 1565
1566@node Completion Styles 1566@node Completion Variables
1567@subsection Completion Styles 1567@subsection Completion Variables
1568@cindex completion styles
1569 1568
1570 A @dfn{completion style} is a set of rules for generating 1569 Here are some variables which can be used to alter the default
1571completions. The user option @code{completion-styles} stores a list 1570completion behavior.
1572of completion styles, which are represented by symbols.
1573 1571
1572@cindex completion styles
1574@defopt completion-styles 1573@defopt completion-styles
1575This is a list of completion style symbols to use for performing 1574The value of this variable is a list of completion styles to use for
1576completion. Each completion style in this list must be defined in 1575performing completion. A @dfn{completion style} is a set of rules for
1576generating completions.
1577
1578Each style listed in this variable must be one of those defined in
1577@code{completion-styles-alist}. 1579@code{completion-styles-alist}.
1578@end defopt 1580@end defopt
1579 1581
1580@defvar completion-styles-alist 1582@defvar completion-styles-alist
1581This variable stores a list of available completion styles. Each 1583This variable stores a list of available completion styles. Each
1582element in the list must have the form @samp{(@var{name} 1584element in the list has the form
1583@var{try-completion} @var{all-completions})}. Here, @var{name} is the 1585
1584name of the completion style (a symbol), which may be used in 1586@example
1585@code{completion-styles-alist} to refer to this style. 1587(@var{name} @var{try-completion} @var{all-completions} @var{doc})
1586 1588@end example
1587@var{try-completion} is the function that does the completion, and 1589
1588@var{all-completions} is the function that lists the completions. 1590@noindent
1589These functions should accept four arguments: @var{string}, 1591Here, @var{name} is the name of the completion style (a symbol), which
1590@var{collection}, @var{predicate}, and @var{point}. The @var{string}, 1592may be used in @code{completion-styles-alist} to refer to this style;
1591@var{collection}, and @var{predicate} arguments have the same meanings 1593@var{try-completion} is the function that does the completion;
1592as in @code{try-completion} (@pxref{Basic Completion}), and the 1594@var{all-completions} is the function that lists the completions; and
1593@var{point} argument is the position of point within @var{string}. 1595@var{doc} is a string describing the completion style.
1594Each function should return a non-@code{nil} value if it performed its 1596
1595job, and @code{nil} if it did not (e.g., if there is no way to 1597The @var{try-completion} and @var{all-completions} functions should
1596complete @var{string} according to the completion style). 1598each accept four arguments: @var{string}, @var{collection},
1597 1599@var{predicate}, and @var{point}. The @var{string}, @var{collection},
1598When the user calls a completion command, such as 1600and @var{predicate} arguments have the same meanings as in
1601@code{try-completion} (@pxref{Basic Completion}), and the @var{point}
1602argument is the position of point within @var{string}. Each function
1603should return a non-@code{nil} value if it performed its job, and
1604@code{nil} if it did not (e.g.@: if there is no way to complete
1605@var{string} according to the completion style).
1606
1607When the user calls a completion command like
1599@code{minibuffer-complete} (@pxref{Completion Commands}), Emacs looks 1608@code{minibuffer-complete} (@pxref{Completion Commands}), Emacs looks
1600for the first style listed in @code{completion-styles} and calls its 1609for the first style listed in @code{completion-styles} and calls its
1601@var{try-completion} function. If this function returns @code{nil}, 1610@var{try-completion} function. If this function returns @code{nil},
1602Emacs moves to the next completion style listed in 1611Emacs moves to the next listed completion style and calls its
1603@code{completion-styles} and calls its @var{try-completion} function, 1612@var{try-completion} function, and so on until one of the
1604and so on until one of the @var{try-completion} functions successfully 1613@var{try-completion} functions successfully performs completion and
1605performs completion and returns a non-@code{nil} value. A similar 1614returns a non-@code{nil} value. A similar procedure is used for
1606procedure is used for listing completions, via the 1615listing completions, via the @var{all-completions} functions.
1607@var{all-completions} functions. 1616
1617@xref{Completion Styles,,, emacs, The GNU Emacs Manual}, for a
1618description of the available completion styles.
1608@end defvar 1619@end defvar
1609 1620
1610 By default, @code{completion-styles-alist} contains five pre-defined 1621@defvar completion-extra-properties
1611completion styles: @code{basic}, a basic completion style; 1622This variable is used to specify extra properties of the current
1612@code{partial-completion}, which does partial completion (completing 1623completion command. It is intended to be let-bound by specialized
1613each word in the input separately); @code{emacs22}, which performs 1624completion commands. Its value should be a list of property and value
1614completion according to the rules used in Emacs 22; @code{emacs21}, 1625pairs. The following properties are supported:
1615which performs completion according to the rules used in Emacs 21; and 1626
1616@code{initials}, which completes acronyms and initialisms. 1627@table @code
1628@item :annotation-function
1629The value should be a function to add annotations in the completions
1630buffer. This function must accept one argument, a completion, and
1631should either return @code{nil} or a string to be displayed next to
1632the completion.
1633
1634@item :exit-function
1635The value should be a function to run after performing completion.
1636The function should accept two arguments, @var{string} and
1637@var{status}, where @var{string} is the text to which the field was
1638completed and @var{status} indicates what kind of operation happened:
1639@code{finished} if text is now complete, @code{sole} if the text
1640cannot be further completed but completion is not finished, or
1641@code{exact} if the text is a valid completion but may be further
1642completed.
1643@end table
1644@end defvar
1617 1645
1618@node Programmed Completion 1646@node Programmed Completion
1619@subsection Programmed Completion 1647@subsection Programmed Completion
@@ -1640,47 +1668,41 @@ the work.
1640The string to be completed. 1668The string to be completed.
1641 1669
1642@item 1670@item
1643The predicate function to filter possible matches, or @code{nil} if 1671A predicate function with which to filter possible matches, or
1644none. Your function should call the predicate for each possible match, 1672@code{nil} if none. The function should call the predicate for each
1645and ignore the possible match if the predicate returns @code{nil}. 1673possible match, and ignore the match if the predicate returns
1674@code{nil}.
1646 1675
1647@item 1676@item
1648A flag specifying the type of operation. The best way to think about 1677A flag specifying the type of completion operation to perform. This
1649it is that the function stands for an object (in the 1678is one of the following four values:
1650``object-oriented'' sense of the word), and this third argument
1651specifies which method to run.
1652@end itemize
1653 1679
1654 There are currently four methods, i.e. four flag values, one for 1680@table @code
1655each of the four different basic operations: 1681@item nil
1656 1682This specifies a @code{try-completion} operation. The function should
1657@itemize @bullet 1683return @code{t} if the specified string is a unique and exact match;
1658@item 1684if there is more than one match, it should return the common substring
1659@code{nil} specifies @code{try-completion}. The completion function 1685of all matches (if the string is an exact match for one completion
1660should return the completion of the specified string, or @code{t} if the 1686alternative but also matches other longer alternatives, the return
1661string is a unique and exact match already, or @code{nil} if the string 1687value is the string); if there are no matches, it should return
1662matches no possibility. 1688@code{nil}.
1663 1689
1664If the string is an exact match for one possibility, but also matches 1690@item t
1665other longer possibilities, the function should return the string, not 1691This specifies an @code{all-completions} operation. The function
1666@code{t}.
1667
1668@item
1669@code{t} specifies @code{all-completions}. The completion function
1670should return a list of all possible completions of the specified 1692should return a list of all possible completions of the specified
1671string. 1693string.
1672 1694
1673@item 1695@item lambda
1674@code{lambda} specifies @code{test-completion}. The completion 1696This specifies a @code{test-completion} operation. The function
1675function should return @code{t} if the specified string is an exact 1697should return @code{t} if the specified string is an exact match for
1676match for some possibility; @code{nil} otherwise. 1698some completion alternative; @code{nil} otherwise.
1677 1699
1678@item 1700@item (boundaries . @var{suffix})
1679@code{(boundaries . SUFFIX)} specifies @code{completion-boundaries}. 1701This specifies a @code{completion-boundaries} operation. The function
1680The function should return a value of the form @code{(boundaries 1702should return @code{(boundaries START . END)}, where START is the
1681START . END)} where START is the position of the beginning boundary 1703position of the beginning boundary in the specified string, and END is
1682in the string to complete, and END is the position of the end boundary 1704the position of the end boundary in SUFFIX.
1683in SUFFIX. 1705@end table
1684@end itemize 1706@end itemize
1685 1707
1686@defun completion-table-dynamic function 1708@defun completion-table-dynamic function
@@ -1692,19 +1714,6 @@ possible completions of it. You can think of
1692and the interface for programmed completion functions. 1714and the interface for programmed completion functions.
1693@end defun 1715@end defun
1694 1716
1695@defvar completion-annotate-function
1696The value of this variable, if non-@code{nil}, should be a function
1697for ``annotating'' the entries in the @samp{*Completions*} buffer.
1698The function should accept a single argument, the completion string
1699for an entry. It should return an additional string to display next
1700to that entry in the @samp{*Completions*} buffer, or @code{nil} if no
1701additional string is to be displayed.
1702
1703The function can determine the collection used for the current
1704completion via the variable @code{minibuffer-completion-table}
1705(@pxref{Completion Commands}).
1706@end defvar
1707
1708@node Completion in Buffers 1717@node Completion in Buffers
1709@subsection Completion in Ordinary Buffers 1718@subsection Completion in Ordinary Buffers
1710@cindex inline completion 1719@cindex inline completion
@@ -1740,7 +1749,7 @@ that text, in a form suitable for passing as the second argument to
1740@code{try-completion} (@pxref{Basic Completion}); completion 1749@code{try-completion} (@pxref{Basic Completion}); completion
1741alternatives will be generated from this completion table in the usual 1750alternatives will be generated from this completion table in the usual
1742way, via the completion styles defined in @code{completion-styles} 1751way, via the completion styles defined in @code{completion-styles}
1743(@pxref{Completion Styles}). @var{props} is a property list for 1752(@pxref{Completion Variables}). @var{props} is a property list for
1744additional information; the following optional properties are 1753additional information; the following optional properties are
1745recognized: 1754recognized:
1746 1755
diff --git a/doc/lispref/vol1.texi b/doc/lispref/vol1.texi
index 52681510a51..e1fe8ba3277 100644
--- a/doc/lispref/vol1.texi
+++ b/doc/lispref/vol1.texi
@@ -671,8 +671,8 @@ Completion
671 (reading buffer name, file name, etc.). 671 (reading buffer name, file name, etc.).
672* Reading File Names:: Using completion to read file names and 672* Reading File Names:: Using completion to read file names and
673 shell commands. 673 shell commands.
674* Completion Styles:: Specifying rules for performing completion. 674* Completion Variables:: Variables controlling completion behavior.
675* Programmed Completion:: Writing your own completion-function. 675* Programmed Completion:: Writing your own completion function.
676* Completion in Buffers:: Completing text in ordinary buffers. 676* Completion in Buffers:: Completing text in ordinary buffers.
677 677
678Command Loop 678Command Loop
diff --git a/doc/lispref/vol2.texi b/doc/lispref/vol2.texi
index 3be2628f5e1..650d1672538 100644
--- a/doc/lispref/vol2.texi
+++ b/doc/lispref/vol2.texi
@@ -670,8 +670,8 @@ Completion
670 (reading buffer name, file name, etc.). 670 (reading buffer name, file name, etc.).
671* Reading File Names:: Using completion to read file names and 671* Reading File Names:: Using completion to read file names and
672 shell commands. 672 shell commands.
673* Completion Styles:: Specifying rules for performing completion. 673* Completion Variables:: Variables controlling completion behavior.
674* Programmed Completion:: Writing your own completion-function. 674* Programmed Completion:: Writing your own completion function.
675* Completion in Buffers:: Completing text in ordinary buffers. 675* Completion in Buffers:: Completing text in ordinary buffers.
676 676
677Command Loop 677Command Loop