Mercurial > emacs
comparison doc/lispref/minibuf.texi @ 109689:ffde65bb1dd2
merge emacs-23
author | Kenichi Handa <handa@etlken> |
---|---|
date | Tue, 27 Jul 2010 16:01:48 +0900 |
parents | 71353caf35e3 |
children | ea5dcd4a779a |
comparison
equal
deleted
inserted
replaced
108493:e5f3704cf67a | 109689:ffde65bb1dd2 |
---|---|
1 @c -*-texinfo-*- | 1 @c -*-texinfo-*- |
2 @c This is part of the GNU Emacs Lisp Reference Manual. | 2 @c This is part of the GNU Emacs Lisp Reference Manual. |
3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2001, 2002, | 3 @c Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1998, 1999, 2001, 2002, |
4 @c 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. | 4 @c 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
5 @c Free Software Foundation, Inc. | |
5 @c See the file elisp.texi for copying conditions. | 6 @c See the file elisp.texi for copying conditions. |
6 @setfilename ../../info/minibuf | 7 @setfilename ../../info/minibuf |
7 @node Minibuffers, Command Loop, Read and Print, Top | 8 @node Minibuffers, Command Loop, Read and Print, Top |
8 @chapter Minibuffers | 9 @chapter Minibuffers |
9 @cindex arguments, reading | 10 @cindex arguments, reading |
20 | 21 |
21 @menu | 22 @menu |
22 * Intro to Minibuffers:: Basic information about minibuffers. | 23 * Intro to Minibuffers:: Basic information about minibuffers. |
23 * Text from Minibuffer:: How to read a straight text string. | 24 * Text from Minibuffer:: How to read a straight text string. |
24 * Object from Minibuffer:: How to read a Lisp object or expression. | 25 * Object from Minibuffer:: How to read a Lisp object or expression. |
25 * Minibuffer History:: Recording previous minibuffer inputs | 26 * Minibuffer History:: Recording previous minibuffer inputs |
26 so the user can reuse them. | 27 so the user can reuse them. |
27 * Initial Input:: Specifying initial contents for the minibuffer. | 28 * Initial Input:: Specifying initial contents for the minibuffer. |
28 * Completion:: How to invoke and customize completion. | 29 * Completion:: How to invoke and customize completion. |
29 * Yes-or-No Queries:: Asking a question with a simple answer. | 30 * Yes-or-No Queries:: Asking a question with a simple answer. |
30 * Multiple Queries:: Asking a series of similar questions. | 31 * Multiple Queries:: Asking a series of similar questions. |
31 * Reading a Password:: Reading a password from the terminal. | 32 * Reading a Password:: Reading a password from the terminal. |
32 * Minibuffer Commands:: Commands used as key bindings in minibuffers. | 33 * Minibuffer Commands:: Commands used as key bindings in minibuffers. |
33 * Minibuffer Contents:: How such commands access the minibuffer text. | 34 * Minibuffer Contents:: How such commands access the minibuffer text. |
34 * Minibuffer Windows:: Operating on the special minibuffer windows. | 35 * Minibuffer Windows:: Operating on the special minibuffer windows. |
35 * Recursive Mini:: Whether recursive entry to minibuffer is allowed. | 36 * Recursive Mini:: Whether recursive entry to minibuffer is allowed. |
36 * Minibuffer Misc:: Various customization hooks and variables. | 37 * Minibuffer Misc:: Various customization hooks and variables. |
810 unpredictable. | 811 unpredictable. |
811 | 812 |
812 If @var{collection} is a function, it is called with three arguments, | 813 If @var{collection} is a function, it is called with three arguments, |
813 the values @var{string}, @var{predicate} and @code{lambda}; whatever | 814 the values @var{string}, @var{predicate} and @code{lambda}; whatever |
814 it returns, @code{test-completion} returns in turn. | 815 it returns, @code{test-completion} returns in turn. |
816 @end defun | |
817 | |
818 @defun completion-boundaries string collection predicate suffix | |
819 This function returns the boundaries of the field on which @var{collection} | |
820 will operate, assuming that @var{string} holds the text before point | |
821 and @var{suffix} holds the text after point. | |
822 | |
823 Normally completion operates on the whole string, so for all normal | |
824 collections, this will always return @code{(0 . (length | |
825 @var{suffix}))}. But more complex completion such as completion on | |
826 files is done one field at a time. For example, completion of | |
827 @code{"/usr/sh"} will include @code{"/usr/share/"} but not | |
828 @code{"/usr/share/doc"} even if @code{"/usr/share/doc"} exists. | |
829 Also @code{all-completions} on @code{"/usr/sh"} will not include | |
830 @code{"/usr/share/"} but only @code{"share/"}. So if @var{string} is | |
831 @code{"/usr/sh"} and @var{suffix} is @code{"e/doc"}, | |
832 @code{completion-boundaries} will return @code{(5 . 1)} which tells us | |
833 that the @var{collection} will only return completion information that | |
834 pertains to the area after @code{"/usr/"} and before @code{"/doc"}. | |
815 @end defun | 835 @end defun |
816 | 836 |
817 If you store a completion alist in a variable, you should mark the | 837 If you store a completion alist in a variable, you should mark the |
818 variable as ``risky'' with a non-@code{nil} | 838 variable as ``risky'' with a non-@code{nil} |
819 @code{risky-local-variable} property. @xref{File Local Variables}. | 839 @code{risky-local-variable} property. @xref{File Local Variables}. |
1616 Sometimes it is not possible to create an alist or an obarray | 1636 Sometimes it is not possible to create an alist or an obarray |
1617 containing all the intended possible completions. In such a case, you | 1637 containing all the intended possible completions. In such a case, you |
1618 can supply your own function to compute the completion of a given | 1638 can supply your own function to compute the completion of a given |
1619 string. This is called @dfn{programmed completion}. Emacs uses | 1639 string. This is called @dfn{programmed completion}. Emacs uses |
1620 programmed completion when completing file names (@pxref{File Name | 1640 programmed completion when completing file names (@pxref{File Name |
1621 Completion}). | 1641 Completion}), among many other cases. |
1622 | 1642 |
1623 To use this feature, pass a symbol with a function definition as the | 1643 To use this feature, pass a function as the @var{collection} |
1624 @var{collection} argument to @code{completing-read}. The function | 1644 argument to @code{completing-read}. The function |
1625 @code{completing-read} arranges to pass your completion function along | 1645 @code{completing-read} arranges to pass your completion function along |
1626 to @code{try-completion} and @code{all-completions}, which will then let | 1646 to @code{try-completion}, @code{all-completions}, and other basic |
1627 your function do all the work. | 1647 completion functions, which will then let your function do all |
1648 the work. | |
1628 | 1649 |
1629 The completion function should accept three arguments: | 1650 The completion function should accept three arguments: |
1630 | 1651 |
1631 @itemize @bullet | 1652 @itemize @bullet |
1632 @item | 1653 @item |
1636 The predicate function to filter possible matches, or @code{nil} if | 1657 The predicate function to filter possible matches, or @code{nil} if |
1637 none. Your function should call the predicate for each possible match, | 1658 none. Your function should call the predicate for each possible match, |
1638 and ignore the possible match if the predicate returns @code{nil}. | 1659 and ignore the possible match if the predicate returns @code{nil}. |
1639 | 1660 |
1640 @item | 1661 @item |
1641 A flag specifying the type of operation. | 1662 A flag specifying the type of operation. The best way to think about |
1663 it is that the function stands for an object (in the | |
1664 ``object-oriented'' sense of the word), and this third argument | |
1665 specifies which method to run. | |
1642 @end itemize | 1666 @end itemize |
1643 | 1667 |
1644 There are three flag values for three operations: | 1668 There are currently four methods, i.e. four flag values, one for |
1669 each of the four different basic operations: | |
1645 | 1670 |
1646 @itemize @bullet | 1671 @itemize @bullet |
1647 @item | 1672 @item |
1648 @code{nil} specifies @code{try-completion}. The completion function | 1673 @code{nil} specifies @code{try-completion}. The completion function |
1649 should return the completion of the specified string, or @code{t} if the | 1674 should return the completion of the specified string, or @code{t} if the |
1661 | 1686 |
1662 @item | 1687 @item |
1663 @code{lambda} specifies @code{test-completion}. The completion | 1688 @code{lambda} specifies @code{test-completion}. The completion |
1664 function should return @code{t} if the specified string is an exact | 1689 function should return @code{t} if the specified string is an exact |
1665 match for some possibility; @code{nil} otherwise. | 1690 match for some possibility; @code{nil} otherwise. |
1691 | |
1692 @item | |
1693 @code{(boundaries . SUFFIX)} specifies @code{completion-boundaries}. | |
1694 The function should return a value of the form @code{(boundaries | |
1695 START . END)} where START is the position of the beginning boundary in | |
1696 in the string to complete, and END is the position of the end boundary | |
1697 in SUFFIX. | |
1666 @end itemize | 1698 @end itemize |
1667 | 1699 |
1668 It would be consistent and clean for completion functions to allow | 1700 It would be consistent and clean for completion functions to allow |
1669 lambda expressions (lists that are functions) as well as function | 1701 lambda expressions (lists that are functions) as well as function |
1670 symbols as @var{collection}, but this is impossible. Lists as | 1702 symbols as @var{collection}, but this is impossible. Lists as |