]> code.delx.au - gnu-emacs/blob - doc/emacs/mini.texi
Corrections and tweaks to Help chapter in Emacs manual.
[gnu-emacs] / doc / emacs / mini.texi
1 @c This is part of the Emacs manual.
2 @c Copyright (C) 1985-1987, 1993-1995, 1997, 2000-2011
3 @c Free Software Foundation, Inc.
4 @c See file emacs.texi for copying conditions.
5 @node Minibuffer, M-x, Basic, Top
6 @chapter The Minibuffer
7 @cindex minibuffer
8
9 The @dfn{minibuffer} is where Emacs commands read complicated
10 arguments, such as file names, buffer names, Emacs command names, or
11 Lisp expressions. We call it the ``minibuffer'' because it's a
12 special-purpose buffer with a small amount of screen space. You can
13 use the usual Emacs editing commands in the minibuffer to edit the
14 argument text.
15
16 @cindex prompt
17 When the minibuffer is in use, it appears in the echo area, with a
18 cursor. The minibuffer starts with a @dfn{prompt} in a distinct
19 color, usually ending with a colon. The prompt states what kind of
20 input is expected, and how it will be used.
21
22 The simplest way to enter a minibuffer argument is to type the text,
23 then @key{RET} to submit the argument and exit the minibuffer. You
24 can cancel the minibuffer, and the command that wants the argument, by
25 typing @kbd{C-g}.
26
27 @cindex default argument
28 Sometimes, a @dfn{default argument} appears in the prompt, inside
29 parentheses before the colon. This default will be used as the
30 argument if you just type @key{RET}. For example, commands that read
31 buffer names usually show a buffer name as the default; you can type
32 @key{RET} to operate on that default buffer.
33
34 Since the minibuffer appears in the echo area, it can conflict with
35 other uses of the echo area. If an error message or an informative
36 message is emitted while the minibuffer is active, the message hides
37 the minibuffer for a few seconds, or until you type something; then
38 the minibuffer comes back. While the minibuffer is in use, keystrokes
39 do not echo.
40
41 @menu
42 * Minibuffer File:: Entering file names with the minibuffer.
43 * Minibuffer Edit:: How to edit in the minibuffer.
44 * Completion:: An abbreviation facility for minibuffer input.
45 * Minibuffer History:: Reusing recent minibuffer arguments.
46 * Repetition:: Re-executing commands that used the minibuffer.
47 * Passwords:: Entering passwords in the echo area.
48 @end menu
49
50 @node Minibuffer File
51 @section Minibuffers for File Names
52
53 @cindex default directory
54 Commands such as @kbd{C-x C-f} (@code{find-file}) use the minibuffer
55 to read a file name argument (@pxref{Basic Files}). When the
56 minibuffer is used to read a file name, it typically starts out with
57 some initial text ending in a slash. This is the @dfn{default
58 directory}. For example, it may start out like this:
59
60 @example
61 Find File: /u2/emacs/src/
62 @end example
63
64 @noindent
65 Here, @samp{Find File:@: } is the prompt and @samp{/u2/emacs/src/} is
66 the default directory. If you now type @kbd{buffer.c} as input, that
67 specifies the file @file{/u2/emacs/src/buffer.c}. @xref{File Names},
68 for information about the default directory.
69
70 You can specify the parent directory with @file{..}:
71 @file{/a/b/../foo.el} is equivalent to @file{/a/foo.el}.
72 Alternatively, you can use @kbd{M-@key{DEL}} to kill directory names
73 backwards (@pxref{Words}).
74
75 To specify a file in a completely different directory, you can kill
76 the entire default with @kbd{C-a C-k} (@pxref{Minibuffer Edit}).
77 Alternatively, you can ignore the default, and enter an absolute file
78 name starting with a slash or a tilde after the default directory.
79 For example, you can specify @file{/etc/termcap} as follows:
80
81 @example
82 Find File: /u2/emacs/src//etc/termcap
83 @end example
84
85 @noindent
86 @cindex // in file name
87 @cindex double slash in file name
88 @cindex slashes repeated in file name
89 @findex file-name-shadow-mode
90 Emacs interprets a double slash as ``ignore everything before the
91 second slash in the pair.'' In the example above,
92 @file{/u2/emacs/src/} is ignored, so the argument you supplied is
93 @file{/etc/termcap}. The ignored part of the file name is dimmed if
94 the terminal allows it. (To disable this dimming, turn off File Name
95 Shadow mode with the command @kbd{M-x file-name-shadow-mode}.)
96
97 @cindex home directory shorthand
98 Emacs interprets @file{~/} as your home directory. Thus,
99 @file{~/foo/bar.txt} specifies a file named @file{bar.txt}, inside a
100 directory named @file{foo}, which is in turn located in your home
101 directory. In addition, @file{~@var{user-id}/} means the home
102 directory of a user whose login name is @var{user-id}. Any leading
103 directory name in front of the @file{~} is ignored: thus,
104 @file{/u2/emacs/~/foo/bar.txt} is equivalent to @file{~/foo/bar.txt}.
105
106 On MS-Windows and MS-DOS systems, where a user doesn't always have a
107 home directory, Emacs uses several alternatives. For MS-Windows, see
108 @ref{Windows HOME}; for MS-DOS, see
109 @ifnottex
110 @ref{MS-DOS File Names}.
111 @end ifnottex
112 @iftex
113 @ref{MS-DOS File Names, HOME on MS-DOS,, emacs, the digital version of
114 the Emacs Manual}.
115 @end iftex
116 On these systems, the @file{~@var{user-id}/} construct is supported
117 only for the current user, i.e., only if @var{user-id} is the current
118 user's login name.
119
120 @vindex insert-default-directory
121 To prevent Emacs from inserting the default directory when reading
122 file names, change the variable @code{insert-default-directory} to
123 @code{nil}. In that case, the minibuffer starts out empty.
124 Nonetheless, relative file name arguments are still interpreted based
125 on the same default directory.
126
127 You can also enter remote file names in the minibuffer.
128 @xref{Remote Files}.
129
130 @node Minibuffer Edit
131 @section Editing in the Minibuffer
132
133 The minibuffer is an Emacs buffer, albeit a peculiar one, and the
134 usual Emacs commands are available for editing the argument text.
135 (The prompt, however, is @dfn{read-only}, and cannot be changed.)
136
137 Since @key{RET} in the minibuffer submits the argument, you can't
138 use it to insert a newline. You can do that with @kbd{C-q C-j}, which
139 inserts a @kbd{C-j} control character, which is formally equivalent to
140 a newline character (@pxref{Inserting Text}). Alternatively, you can
141 use the @kbd{C-o} (@code{open-line}) command (@pxref{Blank Lines}).
142
143 Inside a minibuffer, the keys @key{TAB}, @key{SPC}, and @kbd{?} are
144 often bound to @dfn{completion commands}, which allow you to easily
145 fill in the desired text without typing all of it. @xref{Completion}.
146 As with @key{RET}, you can use @kbd{C-q} to insert a @key{TAB},
147 @key{SPC}, or @samp{?} character.
148
149 For convenience, @kbd{C-a} (@code{move-beginning-of-line}) in a
150 minibuffer moves point to the beginning of the argument text, not the
151 beginning of the prompt. For example, this allows you to erase the
152 entire argument with @kbd{C-a C-k}.
153
154 @cindex height of minibuffer
155 @cindex size of minibuffer
156 @cindex growing minibuffer
157 @cindex resizing minibuffer
158 When the minibuffer is active, the echo area is treated much like an
159 ordinary Emacs window. For instance, you can switch to another window
160 (with @kbd{C-x o}), edit text there, then return to the minibuffer
161 window to finish the argument. You can even kill text in another
162 window, return to the minibuffer window, and yank the text into the
163 argument. There are some restrictions on the minibuffer window,
164 however: for instance, you cannot split it. @xref{Windows}.
165
166 @vindex resize-mini-windows
167 Normally, the minibuffer window occupies a single screen line.
168 However, if you add two or more lines' worth of text into the
169 minibuffer, it expands automatically to accommodate the text. The
170 variable @code{resize-mini-windows} controls the resizing of the
171 minibuffer. The default value is @code{grow-only}, which means the
172 behavior we have just described. If the value is @code{t}, the
173 minibuffer window will also shrink automatically if you remove some
174 lines of text from the minibuffer, down to a minimum of one screen
175 line. If the value is @code{nil}, the minibuffer window never changes
176 size automatically, but you can use the usual window-resizing commands
177 on it (@pxref{Windows}).
178
179 @vindex max-mini-window-height
180 The variable @code{max-mini-window-height} controls the maximum
181 height for resizing the minibuffer window. A floating-point number
182 specifies a fraction of the frame's height; an integer specifies the
183 maximum number of lines; @code{nil} means do not resize the minibuffer
184 window automatically. The default value is 0.25.
185
186 The @kbd{C-M-v} command in the minibuffer scrolls the help text from
187 commands that display help text of any sort in another window. You
188 can also scroll the help text with @kbd{M-@key{prior}} and
189 @kbd{M-@key{next}} (or, equivalently, @kbd{M-@key{PageUp}} and
190 @kbd{M-@key{PageDown}}). This is especially useful with long lists of
191 possible completions. @xref{Other Window}.
192
193 @vindex enable-recursive-minibuffers
194 Emacs normally disallows most commands that use the minibuffer while
195 the minibuffer is active. To allow such commands in the minibuffer,
196 set the variable @code{enable-recursive-minibuffers} to @code{t}.
197
198 @node Completion
199 @section Completion
200 @c This node is referenced in the tutorial. When renaming or deleting
201 @c it, the tutorial needs to be adjusted.
202 @cindex completion
203
204 You can often use a feature called @dfn{completion} to help enter
205 arguments. This means that after you type part of the argument, Emacs
206 can fill in the rest, or some of it, based on what was typed so far.
207
208 @cindex completion alternative
209 When completion is available, certain keys (usually @key{TAB},
210 @key{RET}, and @key{SPC}) are rebound in the minibuffer to special
211 completion commands (@pxref{Completion Commands}). These commands
212 attempt to complete the text in the minibuffer, based on a set of
213 @dfn{completion alternatives} provided by the command that requested
214 the argument. You can usually type @kbd{?} to see a list of
215 completion alternatives.
216
217 Although completion is usually done in the minibuffer, the feature
218 is sometimes available in ordinary buffers too. @xref{Symbol
219 Completion}.
220
221 @menu
222 * Example: Completion Example. Examples of using completion.
223 * Commands: Completion Commands. A list of completion commands.
224 * Strict Completion:: Different types of completion.
225 * Completion Styles:: How completion matches are chosen.
226 * Options: Completion Options. Options for completion.
227 @end menu
228
229 @node Completion Example
230 @subsection Completion Example
231
232 @kindex TAB @r{(completion)}
233 A simple example may help here. @kbd{M-x} uses the minibuffer to
234 read the name of a command, so completion works by matching the
235 minibuffer text against the names of existing Emacs commands. Suppose
236 you wish to run the command @code{auto-fill-mode}. You can do that by
237 typing @kbd{M-x auto-fill-mode @key{RET}}, but it is easier to use
238 completion.
239
240 If you type @kbd{M-x a u @key{TAB}}, the @key{TAB} looks for
241 completion alternatives (in this case, command names) that start with
242 @samp{au}. There are several, including @code{auto-fill-mode} and
243 @code{autoconf-mode}, but they all begin with @code{auto}, so the
244 @samp{au} in the minibuffer completes to @samp{auto}.
245
246 If you type @key{TAB} again immediately, it cannot determine the
247 next character; it could be @samp{-}, @samp{a}, or @samp{c}. So it
248 does not add any characters; instead, @key{TAB} displays a list of all
249 possible completions in another window.
250
251 Next, type @kbd{-f}. The minibuffer now contains @samp{auto-f}, and
252 the only command name that starts with this is @code{auto-fill-mode}.
253 If you now type @key{TAB}, completion fills in the rest of the
254 argument @samp{auto-fill-mode} into the minibuffer.
255
256 Hence, typing just @kbd{a u @key{TAB} - f @key{TAB}} allows you to
257 enter @samp{auto-fill-mode}.
258
259 @node Completion Commands
260 @subsection Completion Commands
261
262 Here is a list of the completion commands defined in the minibuffer
263 when completion is allowed.
264
265 @table @kbd
266 @item @key{TAB}
267 @findex minibuffer-complete
268 Complete the text in the minibuffer as much as possible; if unable to
269 complete, display a list of possible completions
270 (@code{minibuffer-complete}).
271 @item @key{SPC}
272 Complete up to one word from the minibuffer text before point
273 (@code{minibuffer-complete-word}). This command is not available for
274 arguments that often include spaces, such as file names.
275 @item @key{RET}
276 Submit the text in the minibuffer as the argument, possibly completing
277 first (@code{minibuffer-complete-and-exit}). @xref{Strict Completion}.
278 @item ?
279 Display a list of completions (@code{minibuffer-completion-help}).
280 @end table
281
282 @kindex TAB @r{(completion)}
283 @findex minibuffer-complete
284 @key{TAB} (@code{minibuffer-complete}) is the most fundamental
285 completion command. It searches for all possible completions that
286 match the existing minibuffer text, and attempts to complete as much
287 as it can. @xref{Completion Styles}, for how completion alternatives
288 are chosen.
289
290 @kindex SPC @r{(completion)}
291 @findex minibuffer-complete-word
292 @key{SPC} (@code{minibuffer-complete-word}) completes like
293 @key{TAB}, but only up to the next hyphen or space. If you have
294 @samp{auto-f} in the minibuffer and type @key{SPC}, it finds that the
295 completion is @samp{auto-fill-mode}, but it only inserts @samp{ill-},
296 giving @samp{auto-fill-}. Another @key{SPC} at this point completes
297 all the way to @samp{auto-fill-mode}.
298
299 @kindex ? @r{(completion)}
300 @cindex completion list
301 If @key{TAB} or @key{SPC} is unable to complete, it displays a list
302 of matching completion alternatives (if there are any) in another
303 window. You can display the same list with @kbd{?}
304 (@code{minibuffer-completion-help}). The following commands can be
305 used with the completion list:
306
307 @table @kbd
308 @findex mouse-choose-completion
309 @item Mouse-1
310 @itemx Mouse-2
311 Clicking mouse button 1 or 2 on a completion alternative chooses it
312 (@code{mouse-choose-completion}).
313
314 @findex switch-to-completions
315 @item M-v
316 @itemx @key{PageUp}
317 @itemx @key{prior}
318 Typing @kbd{M-v}, while in the minibuffer, selects the window showing
319 the completion list (@code{switch-to-completions}). This paves the
320 way for using the commands below. @key{PageUp} or @key{prior} does
321 the same. You can also select the window in other ways
322 (@pxref{Windows}).
323
324 @findex choose-completion
325 @item @key{RET}
326 While in the completion list buffer, this chooses the completion at
327 point (@code{choose-completion}).
328
329 @findex next-completion
330 @item @key{Right}
331 While in the completion list buffer, this moves point to the following
332 completion alternative (@code{next-completion}).
333
334 @findex previous-completion
335 @item @key{Left}
336 While in the completion list buffer, this moves point to the previous
337 completion alternative (@code{previous-completion}).
338 @end table
339
340 @node Strict Completion
341 @subsection Strict Completion
342
343 There are three ways that the @key{RET}
344 (@code{minibuffer-complete-and-exit}) completion command can act,
345 depending on how the argument will be used.
346
347 @itemize @bullet
348 @item
349 @dfn{Strict} completion accepts only known completion candidates. For
350 example, when @kbd{C-x k} reads the name of a buffer to kill, only the
351 name of an existing buffer makes sense. In strict completion,
352 @key{RET} refuses to exit if the text in the minibuffer does not
353 complete to an exact match.
354
355 @item
356 @dfn{Cautious} completion is similar to strict completion, except that
357 @key{RET} exits only if the text is an already exact match.
358 Otherwise, @key{RET} does not exit, but it does complete the text. If
359 that completes to an exact match, a second @key{RET} will exit.
360
361 Cautious completion is used for reading file names for files that must
362 already exist, for example.
363
364 @item
365 @dfn{Permissive} completion allows any input; the completion
366 candidates are just suggestions. For example, when @kbd{C-x C-f}
367 reads the name of a file to visit, any file name is allowed, including
368 nonexistent file (in case you want to create a file). In permissive
369 completion, @key{RET} does not complete, it just submits the argument
370 as you have entered it.
371 @end itemize
372
373 Like the other completion commands, @key{RET} displays a list of all
374 possible completions whenever it is supposed to complete but is unable
375 to complete any further.
376
377 @node Completion Styles
378 @subsection How Completion Alternatives Are Chosen
379 @cindex completion style
380
381 Completion commands work by narrowing a large list of possible
382 completion alternatives to a smaller subset that ``matches'' what you
383 have typed in the minibuffer. In @ref{Completion Example}, we gave a
384 simple example of such matching. The procedure of determining what
385 constitutes a ``match'' is quite intricate. Emacs attempts to offer
386 plausible completions under most circumstances.
387
388 Emacs performs completion using one or more @dfn{completion
389 styles}---sets of criteria for matching minibuffer text to completion
390 alternatives. During completion, Emacs tries each completion style in
391 turn. If a style yields one or more matches, that is used as the list
392 of completion alternatives. If a style produces no matches, Emacs
393 falls back on the next style.
394
395 @vindex completion-styles
396 The list variable @code{completion-styles} specifies the completion
397 styles to use. Each list element is the name of a completion style (a
398 Lisp symbol). The default completion styles are (in order):
399
400 @table @code
401 @item basic
402 A matching completion alternative must have the same beginning as the
403 text in the minibuffer before point. Furthermore, if there is any
404 text in the minibuffer after point, the rest of the completion
405 alternative must contain that text as a substring.
406
407 @findex partial completion
408 @item partial-completion
409 This aggressive completion style divides the minibuffer text into
410 words separated by hyphens or spaces, and completes each word
411 separately. (For example, when completing command names,
412 @samp{em-l-m} completes to @samp{emacs-lisp-mode}.)
413
414 Furthermore, a @samp{*} in the minibuffer text is treated as a
415 @dfn{wildcard}---it matches any character at the corresponding
416 position in the completion alternative.
417
418 @item emacs22
419 This completion style is similar to @code{basic}, except that it
420 ignores the text in the minibuffer after point. It is so-named
421 because it corresponds to the completion behavior in Emacs 22 and
422 earlier.
423 @end table
424
425 @noindent
426 The following additional completion styles are also defined, and you
427 can add them to @code{completion-styles} if you wish
428 (@pxref{Customization}):
429
430 @table @code
431 @item substring
432 A matching completion alternative must contain the text in the
433 minibuffer before point, and the text in the minibuffer after point,
434 as substrings (in that same order).
435
436 Thus, if the text in the minibuffer is @samp{foobar}, with point
437 between @samp{foo} and @samp{bar}, that matches
438 @samp{@var{a}foo@var{b}bar@var{c}}, where @var{a}, @var{b}, and
439 @var{c} can be any string including the empty string.
440
441 @item initials
442 This very aggressive completion style attempts to complete acronyms
443 and initialisms. For example, when completing command names, it
444 matches @samp{lch} to @samp{list-command-history}.
445 @end table
446
447 @node Completion Options
448 @subsection Completion Options
449
450 @cindex case-sensitivity and completion
451 @cindex case in completion
452 Case is significant when completing case-sensitive arguments, such
453 as command names. For example, when completing command names,
454 @samp{AU} does not complete to @samp{auto-fill-mode}. Case
455 differences are ignored when completing arguments in which case does
456 not matter.
457
458 @vindex read-file-name-completion-ignore-case
459 @vindex read-buffer-completion-ignore-case
460 When completing file names, case differences are ignored if the
461 variable @code{read-file-name-completion-ignore-case} is
462 non-@code{nil}. The default value is @code{nil} on systems that have
463 case-sensitive file-names, such as GNU/Linux; it is non-@code{nil} on
464 systems that have case-insensitive file-names, such as Microsoft
465 Windows. When completing buffer names, case differences are ignored
466 if the variable @code{read-buffer-completion-ignore-case} is
467 non-@code{nil}; the default is @code{nil}.
468
469 @vindex completion-ignored-extensions
470 @cindex ignored file names, in completion
471 When completing file names, Emacs usually omits certain alternatives
472 that are considered unlikely to be chosen, as determined by the list
473 variable @code{completion-ignored-extensions}. Each element in the
474 list should be a string; any file name ending in such a string is
475 ignored as a completion alternative. Any element ending in a slash
476 (@file{/}) represents a subdirectory name. The standard value of
477 @code{completion-ignored-extensions} has several elements including
478 @code{".o"}, @code{".elc"}, and @code{"~"}. For example, if a
479 directory contains @samp{foo.c} and @samp{foo.elc}, @samp{foo}
480 completes to @samp{foo.c}. However, if @emph{all} possible
481 completions end in ``ignored'' strings, they are not ignored: in the
482 previous example, @samp{foo.e} completes to @samp{foo.elc}. Emacs
483 disregards @code{completion-ignored-extensions} when showing
484 completion alternatives in the completion list.
485
486 @vindex completion-auto-help
487 If @code{completion-auto-help} is set to @code{nil}, the completion
488 commands never display the completion list buffer; you must type
489 @kbd{?} to display the list. If the value is @code{lazy}, Emacs only
490 shows the completion list buffer on the second attempt to complete.
491 In other words, if there is nothing to complete, the first @key{TAB}
492 echoes @samp{Next char not unique}; the second @key{TAB} does the
493 completion list buffer.
494
495 @vindex completion-cycle-threshold
496 If @code{completion-cycle-threshold} is non-@code{nil}, completion
497 commands can ``cycle'' through completion alternatives. Normally, if
498 there is more than one completion alternative for the text in the
499 minibuffer, a completion command completes up to the longest common
500 substring. If you change @code{completion-cycle-threshold} to
501 @code{t}, the completion command instead completes to the first of
502 those completion alternatives; each subsequent invocation of the
503 completion command replaces that with the next completion alternative,
504 in a cyclic manner. If you give @code{completion-cycle-threshold} a
505 numeric value @var{n}, completion commands switch to this cycling
506 behavior only when there are fewer than @var{n} alternatives.
507
508 @cindex Icomplete mode
509 @findex icomplete-mode
510 Icomplete mode presents a constantly-updated display that tells you
511 what completions are available for the text you've entered so far. The
512 command to enable or disable this minor mode is @kbd{M-x
513 icomplete-mode}.
514
515 @node Minibuffer History
516 @section Minibuffer History
517 @cindex minibuffer history
518 @cindex history of minibuffer input
519
520 Every argument that you enter with the minibuffer is saved in a
521 @dfn{minibuffer history list} so you can easily use it again later.
522 You can use the following arguments to quickly fetch an earlier
523 argument into the minibuffer:
524
525 @table @kbd
526 @item M-p
527 @itemx @key{Up}
528 Move to the previous item in the minibuffer history, an earlier
529 argument (@code{previous-history-element}).
530 @item M-n
531 @itemx @key{Down}
532 Move to the next item in the minibuffer history
533 (@code{next-history-element}).
534 @item M-r @var{regexp} @key{RET}
535 Move to an earlier item in the minibuffer history that
536 matches @var{regexp} (@code{previous-matching-history-element}).
537 @item M-s @var{regexp} @key{RET}
538 Move to a later item in the minibuffer history that matches
539 @var{regexp} (@code{next-matching-history-element}).
540 @end table
541
542 @kindex M-p @r{(minibuffer history)}
543 @kindex M-n @r{(minibuffer history)}
544 @kindex UP @r{(minibuffer history)}
545 @kindex DOWN @r{(minibuffer history)}
546 @findex next-history-element
547 @findex previous-history-element
548 While in the minibuffer, @kbd{M-p} or @key{Up}
549 (@code{previous-history-element}) moves through the minibuffer history
550 list, one item at a time. Each @kbd{M-p} fetches an earlier item from
551 the history list into the minibuffer, replacing its existing contents.
552 Typing @kbd{M-n} or @key{Down} (@code{next-history-element}) moves
553 through the minibuffer history list in the opposite direction,
554 fetching later entries into the minibuffer.
555
556 If you type @kbd{M-n} in the minibuffer when there are no later
557 entries in the minibuffer history (e.g., if you haven't previously
558 typed @kbd{M-p}), Emacs tries fetching from a list of default
559 arguments: values that you are likely to enter. You can think of this
560 as moving through the ``future history'' list.
561
562 If you edit the text inserted by the @kbd{M-p} or @key{M-n}
563 minibuffer history commands, this does not change its entry in the
564 history list. However, the edited argument does go at the end of the
565 history list when you submit it.
566
567 @findex previous-matching-history-element
568 @findex next-matching-history-element
569 @kindex M-r @r{(minibuffer history)}
570 @kindex M-s @r{(minibuffer history)}
571 You can use @kbd{M-r} (@code{previous-matching-history-element}) to
572 search through older elements in the history list, and @kbd{M-s}
573 (@code{next-matching-history-element}) to search through newer
574 entries. Each of these commands asks for a @dfn{regular expression}
575 as an argument, and fetches the first matching entry into the
576 minibuffer. @xref{Regexps}, for an explanation of regular
577 expressions. A numeric prefix argument @var{n} means to fetch the
578 @var{n}th matching entry. These commands are unusual, in that they
579 use the minibuffer to read the regular expression argument, even
580 though they are invoked from the minibuffer. An upper-case letter in
581 the regular expression makes the search case-sensitive (@pxref{Search
582 Case}).
583
584 You can also search through the history using an incremental search.
585 @xref{Isearch Minibuffer}.
586
587 Emacs keeps separate history lists for several different kinds of
588 arguments. For example, there is a list for file names, used by all
589 the commands that read file names. Other history lists include buffer
590 names, command names (used by @kbd{M-x}), and command arguments (used
591 by commands like @code{query-replace}).
592
593 @vindex history-length
594 The variable @code{history-length} specifies the maximum length of a
595 minibuffer history list; adding a new element deletes the oldest
596 element if the list gets too long. If the value is @code{t}, there is
597 no maximum length.
598
599 @vindex history-delete-duplicates
600 The variable @code{history-delete-duplicates} specifies whether to
601 delete duplicates in history. If it is non-@code{nil}, adding a new
602 element deletes from the list all other elements that are equal to it.
603 The default is @code{nil}.
604
605 @node Repetition
606 @section Repeating Minibuffer Commands
607 @cindex command history
608 @cindex history of commands
609
610 Every command that uses the minibuffer once is recorded on a special
611 history list, the @dfn{command history}, together with the values of
612 its arguments, so that you can repeat the entire command. In
613 particular, every use of @kbd{M-x} is recorded there, since @kbd{M-x}
614 uses the minibuffer to read the command name.
615
616 @findex list-command-history
617 @table @kbd
618 @item C-x @key{ESC} @key{ESC}
619 Re-execute a recent minibuffer command from the command history
620 (@code{repeat-complex-command}).
621 @item M-x list-command-history
622 Display the entire command history, showing all the commands
623 @kbd{C-x @key{ESC} @key{ESC}} can repeat, most recent first.
624 @end table
625
626 @kindex C-x ESC ESC
627 @findex repeat-complex-command
628 @kbd{C-x @key{ESC} @key{ESC}} re-executes a recent command that used
629 the minibuffer. With no argument, it repeats the last such command.
630 A numeric argument specifies which command to repeat; 1 means the last
631 one, 2 the previous, and so on.
632
633 @kbd{C-x @key{ESC} @key{ESC}} works by turning the previous command
634 into a Lisp expression and then entering a minibuffer initialized with
635 the text for that expression. Even if you don't know Lisp, it will
636 probably be obvious which command is displayed for repetition. If you
637 type just @key{RET}, that repeats the command unchanged. You can also
638 change the command by editing the Lisp expression before you execute
639 it. The repeated command is added to the front of the command history
640 unless it is identical to the most recent item.
641
642 Once inside the minibuffer for @kbd{C-x @key{ESC} @key{ESC}}, you
643 can use the usual minibuffer history commands (@pxref{Minibuffer
644 History}) to move through the history list. After finding the desired
645 previous command, you can edit its expression as usual and then repeat
646 it by typing @key{RET}.
647
648 @vindex isearch-resume-in-command-history
649 Incremental search does not, strictly speaking, use the minibuffer.
650 Therefore, although it behaves like a complex command, it normally
651 does not appear in the history list for @kbd{C-x @key{ESC} @key{ESC}}.
652 You can make incremental search commands appear in the history by
653 setting @code{isearch-resume-in-command-history} to a non-@code{nil}
654 value. @xref{Incremental Search}.
655
656 @vindex command-history
657 The list of previous minibuffer-using commands is stored as a Lisp
658 list in the variable @code{command-history}. Each element is a Lisp
659 expression which describes one command and its arguments. Lisp programs
660 can re-execute a command by calling @code{eval} with the
661 @code{command-history} element.
662
663 @node Passwords
664 @section Entering passwords
665
666 Sometimes, you may need to enter a password into Emacs. For instance,
667 when you tell Emacs to visit a file on another machine via a network
668 protocol such as FTP, you often need to supply a password to gain
669 access to the machine (@pxref{Remote Files}).
670
671 Entering a password is similar to using a minibuffer. Emacs
672 displays a prompt in the echo area (such as @samp{Password: }); after
673 you type the required password, press @key{RET} to submit it. To
674 prevent others from seeing your password, every character you type is
675 displayed as a dot (@samp{.}) instead of its usual form.
676
677 Most of the features and commands associated with the minibuffer can
678 @emph{not} be used when entering a password. There is no history or
679 completion, and you cannot change windows or perform any other action
680 with Emacs until you have submitted the password.
681
682 While you are typing the password, you may press @key{DEL} to delete
683 backwards, removing the last character entered. @key{C-u} deletes
684 everything you have typed so far. @kbd{C-g} quits the password prompt
685 (@pxref{Quitting}). @kbd{C-y} inserts the current kill into the
686 password (@pxref{Killing}). You may type either @key{RET} or
687 @key{ESC} to submit the password. Any other self-inserting character
688 key inserts the associated character into the password, and all other
689 input is ignored.