414 |
inputs. It's the Lisp programmer's job to specify the right history |
inputs. It's the Lisp programmer's job to specify the right history |
415 |
list for each use of the minibuffer. |
list for each use of the minibuffer. |
416 |
|
|
417 |
The basic minibuffer input functions @code{read-from-minibuffer} and |
You specify the history list with the optional @var{hist} argument |
418 |
@code{completing-read} both accept an optional argument named @var{hist} |
to either @code{read-from-minibuffer} or @code{completing-read}. Here |
419 |
which is how you specify the history list. Here are the possible |
are the possible values for it: |
|
values: |
|
420 |
|
|
421 |
@table @asis |
@table @asis |
422 |
@item @var{variable} |
@item @var{variable} |
586 |
@node Basic Completion |
@node Basic Completion |
587 |
@subsection Basic Completion Functions |
@subsection Basic Completion Functions |
588 |
|
|
589 |
The functions @code{try-completion}, @code{all-completions} and |
The completion functions @code{try-completion}, |
590 |
@code{test-completion} have nothing in themselves to do with |
@code{all-completions} and @code{test-completion} have nothing in |
591 |
minibuffers. We describe them in this chapter so as to keep them near |
themselves to do with minibuffers. We describe them in this chapter |
592 |
the higher-level completion features that do use the minibuffer. |
so as to keep them near the higher-level completion features that do |
593 |
|
use the minibuffer. |
594 |
|
|
595 |
@defun try-completion string collection &optional predicate |
@defun try-completion string collection &optional predicate |
596 |
This function returns the longest common substring of all possible |
This function returns the longest common substring of all possible |
788 |
|
|
789 |
Here are two examples of use: |
Here are two examples of use: |
790 |
|
|
791 |
@example |
@smallexample |
792 |
(defvar foo (lazy-completion-table foo make-my-alist 'global)) |
(defvar foo (lazy-completion-table foo make-my-alist 'global)) |
793 |
|
|
794 |
(make-local-variable 'bar) |
(make-local-variable 'bar) |
795 |
(setq bar (lazy-completion-table foo make-my-alist 'local) |
(setq bar (lazy-completion-table foo make-my-alist 'local) |
796 |
@end example |
@end smallexample |
797 |
@end defmac |
@end defmac |
798 |
|
|
799 |
@node Minibuffer Completion |
@node Minibuffer Completion |
879 |
If the user then types @kbd{@key{DEL} @key{DEL} b @key{RET}}, |
If the user then types @kbd{@key{DEL} @key{DEL} b @key{RET}}, |
880 |
@code{completing-read} returns @code{barfoo}. |
@code{completing-read} returns @code{barfoo}. |
881 |
|
|
882 |
The @code{completing-read} function binds three variables to pass |
The @code{completing-read} function binds variables to pass |
883 |
information to the commands that actually do completion. These |
information to the commands that actually do completion. |
884 |
variables are @code{minibuffer-completion-table}, |
They are described in the following section. |
|
@code{minibuffer-completion-predicate} and |
|
|
@code{minibuffer-completion-confirm}. For more information about them, |
|
|
see @ref{Completion Commands}. |
|
885 |
@end defun |
@end defun |
886 |
|
|
887 |
@node Completion Commands |
@node Completion Commands |
895 |
emacs, The GNU Emacs Manual}, for a short description of Partial |
emacs, The GNU Emacs Manual}, for a short description of Partial |
896 |
Completion mode. |
Completion mode. |
897 |
|
|
|
@defvar minibuffer-local-completion-map |
|
|
@code{completing-read} uses this value as the local keymap when an |
|
|
exact match of one of the completions is not required. By default, this |
|
|
keymap makes the following bindings: |
|
|
|
|
|
@table @asis |
|
|
@item @kbd{?} |
|
|
@code{minibuffer-completion-help} |
|
|
|
|
|
@item @key{SPC} |
|
|
@code{minibuffer-complete-word} |
|
|
|
|
|
@item @key{TAB} |
|
|
@code{minibuffer-complete} |
|
|
@end table |
|
|
|
|
|
@noindent |
|
|
with other characters bound as in @code{minibuffer-local-map} |
|
|
(@pxref{Definition of minibuffer-local-map}). |
|
|
@end defvar |
|
|
|
|
|
@defvar minibuffer-local-must-match-map |
|
|
@code{completing-read} uses this value as the local keymap when an |
|
|
exact match of one of the completions is required. Therefore, no keys |
|
|
are bound to @code{exit-minibuffer}, the command that exits the |
|
|
minibuffer unconditionally. By default, this keymap makes the following |
|
|
bindings: |
|
|
|
|
|
@table @asis |
|
|
@item @kbd{?} |
|
|
@code{minibuffer-completion-help} |
|
|
|
|
|
@item @key{SPC} |
|
|
@code{minibuffer-complete-word} |
|
|
|
|
|
@item @key{TAB} |
|
|
@code{minibuffer-complete} |
|
|
|
|
|
@item @kbd{C-j} |
|
|
@code{minibuffer-complete-and-exit} |
|
|
|
|
|
@item @key{RET} |
|
|
@code{minibuffer-complete-and-exit} |
|
|
@end table |
|
|
|
|
|
@noindent |
|
|
with other characters bound as in @code{minibuffer-local-map}. |
|
|
@end defvar |
|
|
|
|
898 |
@defvar minibuffer-completion-table |
@defvar minibuffer-completion-table |
899 |
The value of this variable is the collection used for completion in |
The value of this variable is the collection used for completion in |
900 |
the minibuffer. This is the global variable that contains what |
the minibuffer. This is the global variable that contains what |
908 |
minibuffer completion functions. |
minibuffer completion functions. |
909 |
@end defvar |
@end defvar |
910 |
|
|
911 |
|
@defvar minibuffer-completion-confirm |
912 |
|
When the value of this variable is non-@code{nil}, Emacs asks for |
913 |
|
confirmation of a completion before exiting the minibuffer. |
914 |
|
@code{completing-read} binds this variable, and the function |
915 |
|
@code{minibuffer-complete-and-exit} checks the value before exiting. |
916 |
|
@end defvar |
917 |
|
|
918 |
@deffn Command minibuffer-complete-word |
@deffn Command minibuffer-complete-word |
919 |
This function completes the minibuffer contents by at most a single |
This function completes the minibuffer contents by at most a single |
920 |
word. Even if the minibuffer contents have only one completion, |
word. Even if the minibuffer contents have only one completion, |
935 |
when run twice in succession. |
when run twice in succession. |
936 |
@end deffn |
@end deffn |
937 |
|
|
|
@defvar minibuffer-completion-confirm |
|
|
When the value of this variable is non-@code{nil}, Emacs asks for |
|
|
confirmation of a completion before exiting the minibuffer. The |
|
|
function @code{minibuffer-complete-and-exit} checks the value of this |
|
|
variable before it exits. |
|
|
@end defvar |
|
|
|
|
938 |
@deffn Command minibuffer-completion-help |
@deffn Command minibuffer-completion-help |
939 |
This function creates a list of the possible completions of the |
This function creates a list of the possible completions of the |
940 |
current minibuffer contents. It works by calling @code{all-completions} |
current minibuffer contents. It works by calling @code{all-completions} |
973 |
can be completed because the next character is not uniquely determined. |
can be completed because the next character is not uniquely determined. |
974 |
@end defopt |
@end defopt |
975 |
|
|
976 |
|
@defvar minibuffer-local-completion-map |
977 |
|
@code{completing-read} uses this value as the local keymap when an |
978 |
|
exact match of one of the completions is not required. By default, this |
979 |
|
keymap makes the following bindings: |
980 |
|
|
981 |
|
@table @asis |
982 |
|
@item @kbd{?} |
983 |
|
@code{minibuffer-completion-help} |
984 |
|
|
985 |
|
@item @key{SPC} |
986 |
|
@code{minibuffer-complete-word} |
987 |
|
|
988 |
|
@item @key{TAB} |
989 |
|
@code{minibuffer-complete} |
990 |
|
@end table |
991 |
|
|
992 |
|
@noindent |
993 |
|
with other characters bound as in @code{minibuffer-local-map} |
994 |
|
(@pxref{Definition of minibuffer-local-map}). |
995 |
|
@end defvar |
996 |
|
|
997 |
|
@defvar minibuffer-local-must-match-map |
998 |
|
@code{completing-read} uses this value as the local keymap when an |
999 |
|
exact match of one of the completions is required. Therefore, no keys |
1000 |
|
are bound to @code{exit-minibuffer}, the command that exits the |
1001 |
|
minibuffer unconditionally. By default, this keymap makes the following |
1002 |
|
bindings: |
1003 |
|
|
1004 |
|
@table @asis |
1005 |
|
@item @kbd{?} |
1006 |
|
@code{minibuffer-completion-help} |
1007 |
|
|
1008 |
|
@item @key{SPC} |
1009 |
|
@code{minibuffer-complete-word} |
1010 |
|
|
1011 |
|
@item @key{TAB} |
1012 |
|
@code{minibuffer-complete} |
1013 |
|
|
1014 |
|
@item @kbd{C-j} |
1015 |
|
@code{minibuffer-complete-and-exit} |
1016 |
|
|
1017 |
|
@item @key{RET} |
1018 |
|
@code{minibuffer-complete-and-exit} |
1019 |
|
@end table |
1020 |
|
|
1021 |
|
@noindent |
1022 |
|
with other characters bound as in @code{minibuffer-local-map}. |
1023 |
|
@end defvar |
1024 |
|
|
1025 |
@node High-Level Completion |
@node High-Level Completion |
1026 |
@subsection High-Level Completion Functions |
@subsection High-Level Completion Functions |
1027 |
|
|