Mercurial > hg > xemacs-beta
comparison man/lispref/minibuf.texi @ 412:697ef44129c6 r21-2-14
Import from CVS: tag r21-2-14
author | cvs |
---|---|
date | Mon, 13 Aug 2007 11:20:41 +0200 |
parents | 2f8bb876ab1d |
children |
comparison
equal
deleted
inserted
replaced
411:12e008d41344 | 412:697ef44129c6 |
---|---|
23 * Minibuffer History:: Recording previous minibuffer inputs | 23 * Minibuffer History:: Recording previous minibuffer inputs |
24 so the user can reuse them. | 24 so the user can reuse them. |
25 * Completion:: How to invoke and customize completion. | 25 * Completion:: How to invoke and customize completion. |
26 * Yes-or-No Queries:: Asking a question with a simple answer. | 26 * Yes-or-No Queries:: Asking a question with a simple answer. |
27 * Multiple Queries:: Asking a series of similar questions. | 27 * Multiple Queries:: Asking a series of similar questions. |
28 * Reading a Password:: Reading a password from the terminal. | |
29 * Minibuffer Misc:: Various customization hooks and variables. | 28 * Minibuffer Misc:: Various customization hooks and variables. |
30 @end menu | 29 @end menu |
31 | 30 |
32 @node Intro to Minibuffers | 31 @node Intro to Minibuffers |
33 @section Introduction to Minibuffers | 32 @section Introduction to Minibuffers |
36 @emph{within} a buffer, such as editing commands, work normally in a | 35 @emph{within} a buffer, such as editing commands, work normally in a |
37 minibuffer. However, many operations for managing buffers do not apply | 36 minibuffer. However, many operations for managing buffers do not apply |
38 to minibuffers. The name of a minibuffer always has the form @w{@samp{ | 37 to minibuffers. The name of a minibuffer always has the form @w{@samp{ |
39 *Minibuf-@var{number}}}, and it cannot be changed. Minibuffers are | 38 *Minibuf-@var{number}}}, and it cannot be changed. Minibuffers are |
40 displayed only in special windows used only for minibuffers; these | 39 displayed only in special windows used only for minibuffers; these |
41 windows always appear at the bottom of a frame. (Sometimes frames have | 40 windows always appear at the bottom of a frame. (Sometime frames have |
42 no minibuffer window, and sometimes a special kind of frame contains | 41 no minibuffer window, and sometimes a special kind of frame contains |
43 nothing but a minibuffer window; see @ref{Minibuffers and Frames}.) | 42 nothing but a minibuffer window; see @ref{Minibuffers and Frames}.) |
44 | 43 |
45 The minibuffer's window is normally a single line. You can resize it | 44 The minibuffer's window is normally a single line. You can resize it |
46 temporarily with the window sizing commands; it reverts to its normal | 45 temporarily with the window sizing commands; it reverts to its normal |
66 @itemize @bullet | 65 @itemize @bullet |
67 @item | 66 @item |
68 @code{minibuffer-local-map} is for ordinary input (no completion). | 67 @code{minibuffer-local-map} is for ordinary input (no completion). |
69 | 68 |
70 @item | 69 @item |
70 @code{minibuffer-local-ns-map} is similar, except that @key{SPC} exits | |
71 just like @key{RET}. This is used mainly for Mocklisp compatibility. | |
72 | |
73 @item | |
71 @code{minibuffer-local-completion-map} is for permissive completion. | 74 @code{minibuffer-local-completion-map} is for permissive completion. |
72 | 75 |
73 @item | 76 @item |
74 @code{minibuffer-local-must-match-map} is for strict completion and | 77 @code{minibuffer-local-must-match-map} is for strict completion and |
75 for cautious completion. | 78 for cautious completion. |
86 In most cases, you should not call minibuffer input functions in the | 89 In most cases, you should not call minibuffer input functions in the |
87 middle of a Lisp function. Instead, do all minibuffer input as part of | 90 middle of a Lisp function. Instead, do all minibuffer input as part of |
88 reading the arguments for a command, in the @code{interactive} spec. | 91 reading the arguments for a command, in the @code{interactive} spec. |
89 @xref{Defining Commands}. | 92 @xref{Defining Commands}. |
90 | 93 |
91 @defun read-from-minibuffer prompt-string &optional initial-contents keymap read hist abbrev-table default | 94 @defun read-from-minibuffer prompt-string &optional initial-contents keymap read hist |
92 This function is the most general way to get input through the | 95 This function is the most general way to get input through the |
93 minibuffer. By default, it accepts arbitrary text and returns it as a | 96 minibuffer. By default, it accepts arbitrary text and returns it as a |
94 string; however, if @var{read} is non-@code{nil}, then it uses | 97 string; however, if @var{read} is non-@code{nil}, then it uses |
95 @code{read} to convert the text into a Lisp object (@pxref{Input | 98 @code{read} to convert the text into a Lisp object (@pxref{Input |
96 Functions}). | 99 Functions}). |
107 The value of @var{initial-contents} may also be a cons cell of the form | 110 The value of @var{initial-contents} may also be a cons cell of the form |
108 @code{(@var{string} . @var{position})}. This means to insert | 111 @code{(@var{string} . @var{position})}. This means to insert |
109 @var{string} in the minibuffer but put point @var{position} characters | 112 @var{string} in the minibuffer but put point @var{position} characters |
110 from the beginning, rather than at the end. | 113 from the beginning, rather than at the end. |
111 | 114 |
112 When the user types a command to exit the minibuffer, | |
113 @code{read-from-minibuffer} constructs the return value from the text in | |
114 the minibuffer. Normally it returns a string containing that text. | |
115 However, if @var{read} is non-@code{nil}, @code{read-from-minibuffer} | |
116 reads the text and returns the resulting Lisp object, unevaluated. | |
117 (@xref{Input Functions}, for information about reading.) | |
118 | |
119 The argument @var{default} specifies a default value to make available | |
120 through the history commands. It should be a string, or @code{nil}. | |
121 | |
122 If @var{keymap} is non-@code{nil}, that keymap is the local keymap to | 115 If @var{keymap} is non-@code{nil}, that keymap is the local keymap to |
123 use in the minibuffer. If @var{keymap} is omitted or @code{nil}, the | 116 use in the minibuffer. If @var{keymap} is omitted or @code{nil}, the |
124 value of @code{minibuffer-local-map} is used as the keymap. Specifying | 117 value of @code{minibuffer-local-map} is used as the keymap. Specifying |
125 a keymap is the most important way to customize the minibuffer for | 118 a keymap is the most important way to customize the minibuffer for |
126 various applications such as completion. | 119 various applications such as completion. |
127 | |
128 The argument @var{abbrev-table} specifies @code{local-abbrev-table} in | |
129 the minibuffer (@pxref{Standard Abbrev Tables}). | |
130 | 120 |
131 The argument @var{hist} specifies which history list variable to use | 121 The argument @var{hist} specifies which history list variable to use |
132 for saving the input and for history commands used in the minibuffer. | 122 for saving the input and for history commands used in the minibuffer. |
133 It defaults to @code{minibuffer-history}. @xref{Minibuffer History}. | 123 It defaults to @code{minibuffer-history}. @xref{Minibuffer History}. |
134 | 124 |
137 its return value. Normally it simply makes a string containing that | 127 its return value. Normally it simply makes a string containing that |
138 text. However, if @var{read} is non-@code{nil}, | 128 text. However, if @var{read} is non-@code{nil}, |
139 @code{read-from-minibuffer} reads the text and returns the resulting | 129 @code{read-from-minibuffer} reads the text and returns the resulting |
140 Lisp object, unevaluated. (@xref{Input Functions}, for information | 130 Lisp object, unevaluated. (@xref{Input Functions}, for information |
141 about reading.) | 131 about reading.) |
142 | 132 @end defun |
143 @strong{Usage note:} The @var{initial-contents} argument and the | 133 |
144 @var{default} argument are two alternative features for more or less the | 134 @defun read-string prompt &optional initial |
145 same job. It does not make sense to use both features in a single call | |
146 to @code{read-from-minibuffer}. In general, we recommend using | |
147 @var{default}, since this permits the user to insert the default value | |
148 when it is wanted, but does not burden the user with deleting it from | |
149 the minibuffer on other occasions. However, if user is supposed to edit | |
150 default value, @var{initial-contents} may be preferred. | |
151 @end defun | |
152 | |
153 @defun read-string prompt &optional initial history default-value | |
154 This function reads a string from the minibuffer and returns it. The | 135 This function reads a string from the minibuffer and returns it. The |
155 arguments @var{prompt} and @var{initial} are used as in | 136 arguments @var{prompt} and @var{initial} are used as in |
156 @code{read-from-minibuffer}. The keymap used is | 137 @code{read-from-minibuffer}. The keymap used is |
157 @code{minibuffer-local-map}. | 138 @code{minibuffer-local-map}. |
158 | 139 |
159 The optional argument @var{history}, if non-nil, specifies a history | 140 This is a simplified interface to the |
160 list and optionally the initial position in the list. The optional | |
161 argument @var{default} specifies a default value to return if the user | |
162 enters null input; it should be a string. | |
163 | |
164 This function is a simplified interface to the | |
165 @code{read-from-minibuffer} function: | 141 @code{read-from-minibuffer} function: |
166 | 142 |
167 @smallexample | 143 @smallexample |
168 @group | 144 @group |
169 (read-string @var{prompt} @var{initial} @var{history} @var{default}) | 145 (read-string @var{prompt} @var{initial}) |
170 @equiv{} | 146 @equiv{} |
171 (read-from-minibuffer @var{prompt} @var{initial} nil nil | 147 (read-from-minibuffer @var{prompt} @var{initial} nil nil nil) |
172 @var{history} nil @var{default}))) | |
173 @end group | 148 @end group |
174 @end smallexample | 149 @end smallexample |
175 @end defun | 150 @end defun |
176 | 151 |
177 @defvar minibuffer-local-map | 152 @defvar minibuffer-local-map |
178 This is the default local keymap for reading from the minibuffer. By | 153 This is the default local keymap for reading from the minibuffer. By |
179 default, it makes the following bindings: | 154 default, it makes the following bindings: |
180 | 155 |
181 @table @asis | 156 @table @asis |
182 @item @kbd{C-j} | 157 @item @key{LFD} |
183 @code{exit-minibuffer} | 158 @code{exit-minibuffer} |
184 | 159 |
185 @item @key{RET} | 160 @item @key{RET} |
186 @code{exit-minibuffer} | 161 @code{exit-minibuffer} |
187 | 162 |
200 @item @kbd{M-s} | 175 @item @kbd{M-s} |
201 @code{previous-matching-history-element} | 176 @code{previous-matching-history-element} |
202 @end table | 177 @end table |
203 @end defvar | 178 @end defvar |
204 | 179 |
180 @c In version 18, initial is required | |
181 @c Emacs 19 feature | |
182 @defun read-no-blanks-input prompt &optional initial | |
183 This function reads a string from the minibuffer, but does not allow | |
184 whitespace characters as part of the input: instead, those characters | |
185 terminate the input. The arguments @var{prompt} and @var{initial} are | |
186 used as in @code{read-from-minibuffer}. | |
187 | |
188 This is a simplified interface to the @code{read-from-minibuffer} | |
189 function, and passes the value of the @code{minibuffer-local-ns-map} | |
190 keymap as the @var{keymap} argument for that function. Since the keymap | |
191 @code{minibuffer-local-ns-map} does not rebind @kbd{C-q}, it @emph{is} | |
192 possible to put a space into the string, by quoting it. | |
193 | |
194 @smallexample | |
195 @group | |
196 (read-no-blanks-input @var{prompt} @var{initial}) | |
197 @equiv{} | |
198 (read-from-minibuffer @var{prompt} @var{initial} minibuffer-local-ns-map) | |
199 @end group | |
200 @end smallexample | |
201 @end defun | |
202 | |
203 @defvar minibuffer-local-ns-map | |
204 This built-in variable is the keymap used as the minibuffer local keymap | |
205 in the function @code{read-no-blanks-input}. By default, it makes the | |
206 following bindings, in addition to those of @code{minibuffer-local-map}: | |
207 | |
208 @table @asis | |
209 @item @key{SPC} | |
210 @cindex @key{SPC} in minibuffer | |
211 @code{exit-minibuffer} | |
212 | |
213 @item @key{TAB} | |
214 @cindex @key{TAB} in minibuffer | |
215 @code{exit-minibuffer} | |
216 | |
217 @item @kbd{?} | |
218 @cindex @kbd{?} in minibuffer | |
219 @code{self-insert-and-exit} | |
220 @end table | |
221 @end defvar | |
222 | |
205 @node Object from Minibuffer | 223 @node Object from Minibuffer |
206 @section Reading Lisp Objects with the Minibuffer | 224 @section Reading Lisp Objects with the Minibuffer |
207 | 225 |
208 This section describes functions for reading Lisp objects with the | 226 This section describes functions for reading Lisp objects with the |
209 minibuffer. | 227 minibuffer. |
210 | 228 |
211 @defun read-expression prompt &optional initial history default-value | 229 @defun read-minibuffer prompt &optional initial |
212 This function reads a Lisp object using the minibuffer, and returns it | 230 This function reads a Lisp object in the minibuffer and returns it, |
213 without evaluating it. The arguments @var{prompt} and @var{initial} are | 231 without evaluating it. The arguments @var{prompt} and @var{initial} are |
214 used as in @code{read-from-minibuffer}. | 232 used as in @code{read-from-minibuffer}. |
215 | 233 |
216 The optional argument @var{history}, if non-nil, specifies a history | |
217 list and optionally the initial position in the list. The optional | |
218 argument @var{default-value} specifies a default value to return if the | |
219 user enters null input; it should be a string. | |
220 | |
221 This is a simplified interface to the | 234 This is a simplified interface to the |
222 @code{read-from-minibuffer} function: | 235 @code{read-from-minibuffer} function: |
223 | 236 |
224 @smallexample | 237 @smallexample |
225 @group | 238 @group |
226 (read-expression @var{prompt} @var{initial} @var{history} @var{default-value}) | 239 (read-minibuffer @var{prompt} @var{initial}) |
227 @equiv{} | 240 @equiv{} |
228 (read-from-minibuffer @var{prompt} @var{initial} nil t | 241 (read-from-minibuffer @var{prompt} @var{initial} nil t) |
229 @var{history} nil @var{default-value}) | |
230 @end group | 242 @end group |
231 @end smallexample | 243 @end smallexample |
232 | 244 |
233 Here is an example in which we supply the string @code{"(testing)"} as | 245 Here is an example in which we supply the string @code{"(testing)"} as |
234 initial input: | 246 initial input: |
235 | 247 |
236 @smallexample | 248 @smallexample |
237 @group | 249 @group |
238 (read-expression | 250 (read-minibuffer |
239 "Enter an expression: " (format "%s" '(testing))) | 251 "Enter an expression: " (format "%s" '(testing))) |
240 | 252 |
241 ;; @r{Here is how the minibuffer is displayed:} | 253 ;; @r{Here is how the minibuffer is displayed:} |
242 @end group | 254 @end group |
243 | 255 |
251 @noindent | 263 @noindent |
252 The user can type @key{RET} immediately to use the initial input as a | 264 The user can type @key{RET} immediately to use the initial input as a |
253 default, or can edit the input. | 265 default, or can edit the input. |
254 @end defun | 266 @end defun |
255 | 267 |
256 @defun read-minibuffer prompt &optional initial history default-value | 268 @defun eval-minibuffer prompt &optional initial |
257 | 269 This function reads a Lisp expression in the minibuffer, evaluates it, |
258 This is a FSF Emacs compatible function. Use @code{read-expression} | 270 then returns the result. The arguments @var{prompt} and @var{initial} |
259 instead. | 271 are used as in @code{read-from-minibuffer}. |
260 @end defun | |
261 | |
262 @defun eval-minibuffer prompt &optional initial history default-value | |
263 This function reads a Lisp expression using the minibuffer, evaluates | |
264 it, then returns the result. The arguments @var{prompt} and | |
265 @var{initial} are used as in @code{read-from-minibuffer}. | |
266 | |
267 The optional argument @var{history}, if non-nil, specifies a history | |
268 list and optionally the initial position in the list. The optional | |
269 argument @var{default-value} specifies a default value to return if the | |
270 user enters null input; it should be a string. | |
271 | 272 |
272 This function simply evaluates the result of a call to | 273 This function simply evaluates the result of a call to |
273 @code{read-expression}: | 274 @code{read-minibuffer}: |
274 | 275 |
275 @smallexample | 276 @smallexample |
276 @group | 277 @group |
277 (eval-minibuffer @var{prompt} @var{initial}) | 278 (eval-minibuffer @var{prompt} @var{initial}) |
278 @equiv{} | 279 @equiv{} |
279 (eval (read-expression @var{prompt} @var{initial})) | 280 (eval (read-minibuffer @var{prompt} @var{initial})) |
280 @end group | 281 @end group |
281 @end smallexample | 282 @end smallexample |
282 @end defun | 283 @end defun |
283 | 284 |
284 @defun edit-and-eval-command prompt command &optional history | 285 @defun edit-and-eval-command prompt form |
285 This function reads a Lisp expression in the minibuffer, and then | 286 This function reads a Lisp expression in the minibuffer, and then |
286 evaluates it. The difference between this command and | 287 evaluates it. The difference between this command and |
287 @code{eval-minibuffer} is that here the initial @var{command} is not | 288 @code{eval-minibuffer} is that here the initial @var{form} is not |
288 optional and it is treated as a Lisp object to be converted to printed | 289 optional and it is treated as a Lisp object to be converted to printed |
289 representation rather than as a string of text. It is printed with | 290 representation rather than as a string of text. It is printed with |
290 @code{prin1}, so if it is a string, double-quote characters (@samp{"}) | 291 @code{prin1}, so if it is a string, double-quote characters (@samp{"}) |
291 appear in the initial text. @xref{Output Functions}. | 292 appear in the initial text. @xref{Output Functions}. |
292 | 293 |
293 The first thing @code{edit-and-eval-command} does is to activate the | 294 The first thing @code{edit-and-eval-command} does is to activate the |
294 minibuffer with @var{prompt} as the prompt. Then it inserts the printed | 295 minibuffer with @var{prompt} as the prompt. Then it inserts the printed |
295 representation of @var{form} in the minibuffer, and lets the user edit it. | 296 representation of @var{form} in the minibuffer, and lets the user edit. |
296 When the user exits the minibuffer, the edited text is read with | 297 When the user exits the minibuffer, the edited text is read with |
297 @code{read} and then evaluated. The resulting value becomes the value | 298 @code{read} and then evaluated. The resulting value becomes the value |
298 of @code{edit-and-eval-command}. | 299 of @code{edit-and-eval-command}. |
299 | 300 |
300 In the following example, we offer the user an expression with initial | 301 In the following example, we offer the user an expression with initial |
362 elements to the history list automatically, and provide commands to | 363 elements to the history list automatically, and provide commands to |
363 allow the user to reuse items on the list. The only thing your program | 364 allow the user to reuse items on the list. The only thing your program |
364 needs to do to use a history list is to initialize it and to pass its | 365 needs to do to use a history list is to initialize it and to pass its |
365 name to the input functions when you wish. But it is safe to modify the | 366 name to the input functions when you wish. But it is safe to modify the |
366 list by hand when the minibuffer input functions are not using it. | 367 list by hand when the minibuffer input functions are not using it. |
367 | |
368 Here are some of the standard minibuffer history list variables: | |
369 | 368 |
370 @defvar minibuffer-history | 369 @defvar minibuffer-history |
371 The default history list for minibuffer history input. | 370 The default history list for minibuffer history input. |
372 @end defvar | 371 @end defvar |
373 | 372 |
550 @end smallexample | 549 @end smallexample |
551 @end defun | 550 @end defun |
552 | 551 |
553 @defun all-completions string collection &optional predicate nospace | 552 @defun all-completions string collection &optional predicate nospace |
554 This function returns a list of all possible completions of | 553 This function returns a list of all possible completions of |
555 @var{string}. The arguments to this function are the same as those of | 554 @var{string}. The parameters to this function are the same as to |
556 @code{try-completion}. | 555 @code{try-completion}. |
557 | 556 |
558 If @var{collection} is a function, it is called with three arguments: | 557 If @var{collection} is a function, it is called with three arguments: |
559 @var{string}, @var{predicate} and @code{t}; then @code{all-completions} | 558 @var{string}, @var{predicate} and @code{t}; then @code{all-completions} |
560 returns whatever the function returns. @xref{Programmed Completion}. | 559 returns whatever the function returns. @xref{Programmed Completion}. |
591 @subsection Completion and the Minibuffer | 590 @subsection Completion and the Minibuffer |
592 | 591 |
593 This section describes the basic interface for reading from the | 592 This section describes the basic interface for reading from the |
594 minibuffer with completion. | 593 minibuffer with completion. |
595 | 594 |
596 @defun completing-read prompt collection &optional predicate require-match initial hist default | 595 @defun completing-read prompt collection &optional predicate require-match initial hist |
597 This function reads a string in the minibuffer, assisting the user by | 596 This function reads a string in the minibuffer, assisting the user by |
598 providing completion. It activates the minibuffer with prompt | 597 providing completion. It activates the minibuffer with prompt |
599 @var{prompt}, which must be a string. If @var{initial} is | 598 @var{prompt}, which must be a string. If @var{initial} is |
600 non-@code{nil}, @code{completing-read} inserts it into the minibuffer as | 599 non-@code{nil}, @code{completing-read} inserts it into the minibuffer as |
601 part of the input. Then it allows the user to edit the input, providing | 600 part of the input. Then it allows the user to edit the input, providing |
610 If @var{require-match} is neither @code{nil} nor @code{t}, then the exit | 609 If @var{require-match} is neither @code{nil} nor @code{t}, then the exit |
611 commands won't exit unless the input typed is itself an element of | 610 commands won't exit unless the input typed is itself an element of |
612 @var{collection}. If @var{require-match} is @code{nil}, the exit | 611 @var{collection}. If @var{require-match} is @code{nil}, the exit |
613 commands work regardless of the input in the minibuffer. | 612 commands work regardless of the input in the minibuffer. |
614 | 613 |
615 However, empty input is always permitted, regardless of the value of | |
616 @var{require-match}; in that case, @code{completing-read} returns | |
617 @var{default}. The value of @var{default} (if non-@code{nil}) is also | |
618 available to the user through the history commands. | |
619 | |
620 The user can exit with null input by typing @key{RET} with an empty | 614 The user can exit with null input by typing @key{RET} with an empty |
621 minibuffer. Then @code{completing-read} returns @code{""}. This is how | 615 minibuffer. Then @code{completing-read} returns @code{nil}. This is |
622 the user requests whatever default the command uses for the value being | 616 how the user requests whatever default the command uses for the value |
623 read. The user can return using @key{RET} in this way regardless of the | 617 being read. The user can return using @key{RET} in this way regardless |
624 value of @var{require-match}, and regardless of whether the empty string | 618 of the value of @var{require-match}. |
625 is included in @var{collection}. | |
626 | 619 |
627 The function @code{completing-read} works by calling | 620 The function @code{completing-read} works by calling |
628 @code{read-expression}. It uses @code{minibuffer-local-completion-map} | 621 @code{read-minibuffer}. It uses @code{minibuffer-local-completion-map} |
629 as the keymap if @var{require-match} is @code{nil}, and uses | 622 as the keymap if @var{require-match} is @code{nil}, and uses |
630 @code{minibuffer-local-must-match-map} if @var{require-match} is | 623 @code{minibuffer-local-must-match-map} if @var{require-match} is |
631 non-@code{nil}. @xref{Completion Commands}. | 624 non-@code{nil}. @xref{Completion Commands}. |
632 | 625 |
633 The argument @var{hist} specifies which history list variable to use for | 626 The argument @var{hist} specifies which history list variable to use for |
712 @code{minibuffer-complete-word} | 705 @code{minibuffer-complete-word} |
713 | 706 |
714 @item @key{TAB} | 707 @item @key{TAB} |
715 @code{minibuffer-complete} | 708 @code{minibuffer-complete} |
716 | 709 |
717 @item @kbd{C-j} | 710 @item @key{LFD} |
718 @code{minibuffer-complete-and-exit} | 711 @code{minibuffer-complete-and-exit} |
719 | 712 |
720 @item @key{RET} | 713 @item @key{RET} |
721 @code{minibuffer-complete-and-exit} | 714 @code{minibuffer-complete-and-exit} |
722 @end table | 715 @end table |
750 @end deffn | 743 @end deffn |
751 | 744 |
752 @deffn Command minibuffer-complete-and-exit | 745 @deffn Command minibuffer-complete-and-exit |
753 This function completes the minibuffer contents, and exits if | 746 This function completes the minibuffer contents, and exits if |
754 confirmation is not required, i.e., if | 747 confirmation is not required, i.e., if |
755 @code{minibuffer-completion-confirm} is @code{nil}. If confirmation | 748 @code{minibuffer-completion-confirm} is non-@code{nil}. If confirmation |
756 @emph{is} required, it is given by repeating this command | 749 @emph{is} required, it is given by repeating this command |
757 immediately---the command is programmed to work without confirmation | 750 immediately---the command is programmed to work without confirmation |
758 when run twice in succession. | 751 when run twice in succession. |
759 @end deffn | 752 @end deffn |
760 | 753 |
773 @code{minibuffer-completion-predicate} as the @var{predicate} argument. | 766 @code{minibuffer-completion-predicate} as the @var{predicate} argument. |
774 The list of completions is displayed as text in a buffer named | 767 The list of completions is displayed as text in a buffer named |
775 @samp{*Completions*}. | 768 @samp{*Completions*}. |
776 @end deffn | 769 @end deffn |
777 | 770 |
778 @defun display-completion-list completions &rest cl-keys | 771 @defun display-completion-list completions |
779 This function displays @var{completions} to the stream in | 772 This function displays @var{completions} to the stream in |
780 @code{standard-output}, usually a buffer. (@xref{Read and Print}, for more | 773 @code{standard-output}, usually a buffer. (@xref{Read and Print}, for more |
781 information about streams.) The argument @var{completions} is normally | 774 information about streams.) The argument @var{completions} is normally |
782 a list of completions just returned by @code{all-completions}, but it | 775 a list of completions just returned by @code{all-completions}, but it |
783 does not have to be. Each element may be a symbol or a string, either | 776 does not have to be. Each element may be a symbol or a string, either |
850 @result{} "minibuffer.texi" | 843 @result{} "minibuffer.texi" |
851 @end group | 844 @end group |
852 @end example | 845 @end example |
853 @end defun | 846 @end defun |
854 | 847 |
855 @defun read-command prompt &optinal default-value | 848 @defun read-command prompt |
856 This function reads the name of a command and returns it as a Lisp | 849 This function reads the name of a command and returns it as a Lisp |
857 symbol. The argument @var{prompt} is used as in | 850 symbol. The argument @var{prompt} is used as in |
858 @code{read-from-minibuffer}. Recall that a command is anything for | 851 @code{read-from-minibuffer}. Recall that a command is anything for |
859 which @code{commandp} returns @code{t}, and a command name is a symbol | 852 which @code{commandp} returns @code{t}, and a command name is a symbol |
860 for which @code{commandp} returns @code{t}. @xref{Interactive Call}. | 853 for which @code{commandp} returns @code{t}. @xref{Interactive Call}. |
861 | 854 |
862 The argument @var{default-value} specifies what to return if the user | |
863 enters null input. It can be a symbol or a string; if it is a string, | |
864 @code{read-command} interns it before returning it. If @var{default} is | |
865 @code{nil}, that means no default has been specified; then if the user | |
866 enters null input, the return value is @code{nil}. | |
867 | |
868 @example | 855 @example |
869 (read-command "Command name? ") | 856 (read-command "Command name? ") |
870 | 857 |
871 @group | 858 @group |
872 ;; @r{After evaluation of the preceding expression,} | 859 ;; @r{After evaluation of the preceding expression,} |
898 'commandp t nil)) | 885 'commandp t nil)) |
899 @end group | 886 @end group |
900 @end example | 887 @end example |
901 @end defun | 888 @end defun |
902 | 889 |
903 @defun read-variable prompt &optional default-value | 890 @defun read-variable prompt |
904 This function reads the name of a user variable and returns it as a | 891 This function reads the name of a user variable and returns it as a |
905 symbol. | 892 symbol. |
906 | |
907 The argument @var{default-value} specifies what to return if the user | |
908 enters null input. It can be a symbol or a string; if it is a string, | |
909 @code{read-variable} interns it before returning it. If @var{default} | |
910 is @code{nil}, that means no default has been specified; then if the | |
911 user enters null input, the return value is @code{nil}. | |
912 | 893 |
913 @example | 894 @example |
914 @group | 895 @group |
915 (read-variable "Variable name? ") | 896 (read-variable "Variable name? ") |
916 | 897 |
950 | 931 |
951 Here is another high-level completion function, designed for reading a | 932 Here is another high-level completion function, designed for reading a |
952 file name. It provides special features including automatic insertion | 933 file name. It provides special features including automatic insertion |
953 of the default directory. | 934 of the default directory. |
954 | 935 |
955 @defun read-file-name prompt &optional directory default existing initial history | 936 @defun read-file-name prompt &optional directory default existing initial |
956 This function reads a file name in the minibuffer, prompting with | 937 This function reads a file name in the minibuffer, prompting with |
957 @var{prompt} and providing completion. If @var{default} is | 938 @var{prompt} and providing completion. If @var{default} is |
958 non-@code{nil}, then the function returns @var{default} if the user just | 939 non-@code{nil}, then the function returns @var{default} if the user just |
959 types @key{RET}. @var{default} is not checked for validity; it is | 940 types @key{RET}. @var{default} is not checked for validity; it is |
960 returned, whatever it is, if the user exits with the minibuffer empty. | 941 returned, whatever it is, if the user exits with the minibuffer empty. |
973 initial input. It defaults to the current buffer's value of | 954 initial input. It defaults to the current buffer's value of |
974 @code{default-directory}. | 955 @code{default-directory}. |
975 | 956 |
976 @c Emacs 19 feature | 957 @c Emacs 19 feature |
977 If you specify @var{initial}, that is an initial file name to insert in | 958 If you specify @var{initial}, that is an initial file name to insert in |
978 the buffer (after @var{directory}, if that is inserted). In this | 959 the buffer (after with @var{directory}, if that is inserted). In this |
979 case, point goes at the beginning of @var{initial}. The default for | 960 case, point goes at the beginning of @var{initial}. The default for |
980 @var{initial} is @code{nil}---don't insert any file name. To see what | 961 @var{initial} is @code{nil}---don't insert any file name. To see what |
981 @var{initial} does, try the command @kbd{C-x C-v}. | 962 @var{initial} does, try the command @kbd{C-x C-v}. |
982 | 963 |
983 Here is an example: | 964 Here is an example: |
1088 | 1069 |
1089 @itemize @bullet | 1070 @itemize @bullet |
1090 @item | 1071 @item |
1091 @code{nil} specifies @code{try-completion}. The completion function | 1072 @code{nil} specifies @code{try-completion}. The completion function |
1092 should return the completion of the specified string, or @code{t} if the | 1073 should return the completion of the specified string, or @code{t} if the |
1093 string is a unique and exact match already, or @code{nil} if the string | 1074 string is an exact match already, or @code{nil} if the string matches no |
1094 matches no possibility. | 1075 possibility. |
1095 | |
1096 If the string is an exact match for one possibility, but also matches | |
1097 other longer possibilities, the function should return the string, not | |
1098 @code{t}. | |
1099 | 1076 |
1100 @item | 1077 @item |
1101 @code{t} specifies @code{all-completions}. The completion function | 1078 @code{t} specifies @code{all-completions}. The completion function |
1102 should return a list of all possible completions of the specified | 1079 should return a list of all possible completions of the specified |
1103 string. | 1080 string. |
1364 value around the call. | 1341 value around the call. |
1365 | 1342 |
1366 The return value of @code{map-y-or-n-p} is the number of objects acted on. | 1343 The return value of @code{map-y-or-n-p} is the number of objects acted on. |
1367 @end defun | 1344 @end defun |
1368 | 1345 |
1369 @node Reading a Password | |
1370 @section Reading a Password | |
1371 @cindex passwords, reading | |
1372 | |
1373 To read a password to pass to another program, you can use the | |
1374 function @code{read-passwd}. | |
1375 | |
1376 @defun read-passwd prompt &optional confirm default | |
1377 This function reads a password, prompting with @var{prompt}. It does | |
1378 not echo the password as the user types it; instead, it echoes @samp{.} | |
1379 for each character in the password. | |
1380 | |
1381 The optional argument @var{confirm}, if non-@code{nil}, says to read the | |
1382 password twice and insist it must be the same both times. If it isn't | |
1383 the same, the user has to type it over and over until the last two | |
1384 times match. | |
1385 | |
1386 The optional argument @var{default} specifies the default password to | |
1387 return if the user enters empty input. It is translated to @samp{.} | |
1388 and inserted in the minibuffer. If @var{default} is @code{nil}, then | |
1389 @code{read-passwd} returns the null string in that case. | |
1390 @end defun | |
1391 | |
1392 @defopt passwd-invert-frame-when-keyboard-grabbed | |
1393 If non-nil swap the foreground and background colors of all faces while | |
1394 reading a password. Default values is @code{t} unless feature | |
1395 @code{infodock} is provided. | |
1396 @end defopt | |
1397 | |
1398 @defopt passwd-echo | |
1399 This specifies the character echoed when typing a password. When nil, | |
1400 nothing is echoed. | |
1401 @end defopt | |
1402 | |
1403 @node Minibuffer Misc | 1346 @node Minibuffer Misc |
1404 @section Minibuffer Miscellany | 1347 @section Minibuffer Miscellany |
1405 | 1348 |
1406 This section describes some basic functions and variables related to | 1349 This section describes some basic functions and variables related to |
1407 minibuffers. | 1350 minibuffers. |
1507 returns zero. | 1450 returns zero. |
1508 @end defun | 1451 @end defun |
1509 | 1452 |
1510 @defopt enable-recursive-minibuffers | 1453 @defopt enable-recursive-minibuffers |
1511 If this variable is non-@code{nil}, you can invoke commands (such as | 1454 If this variable is non-@code{nil}, you can invoke commands (such as |
1512 @code{find-file}) that use minibuffers even while the minibuffer window | 1455 @code{find-file}) that use minibuffers even while in the minibuffer |
1513 is active. Such invocation produces a recursive editing level for a new | 1456 window. Such invocation produces a recursive editing level for a new |
1514 minibuffer. The outer-level minibuffer is invisible while you are | 1457 minibuffer. The outer-level minibuffer is invisible while you are |
1515 editing the inner one. | 1458 editing the inner one. |
1516 | 1459 |
1517 This variable only affects invoking the minibuffer while the | 1460 This variable only affects invoking the minibuffer while the |
1518 minibuffer window is selected. If you switch windows while in the | 1461 minibuffer window is selected. If you switch windows while in the |
1531 This is not implemented in XEmacs because it is a kludge. If you | 1474 This is not implemented in XEmacs because it is a kludge. If you |
1532 want to explicitly set the value of @code{enable-recursive-minibuffers} | 1475 want to explicitly set the value of @code{enable-recursive-minibuffers} |
1533 in this fashion, just use an evaluated interactive spec and bind | 1476 in this fashion, just use an evaluated interactive spec and bind |
1534 @code{enable-recursive-minibuffers} while reading from the minibuffer. | 1477 @code{enable-recursive-minibuffers} while reading from the minibuffer. |
1535 See the definition of @code{next-matching-history-element} in | 1478 See the definition of @code{next-matching-history-element} in |
1536 @file{lisp/minibuf.el}. | 1479 @file{lisp/prim/minibuf.el}. |