Document completion styles in Emacs manual; copyedits.
[emacs.git] / doc / emacs / mini.texi
bloba9b0394e9b77c63c9c3534b8c4135c22cd66d0ad
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
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.
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.
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}.
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.
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.
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
50 @node Minibuffer File
51 @section Minibuffers for File Names
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:
60 @example
61 Find File: /u2/emacs/src/
62 @end example
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.
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}).
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:
81 @example
82 Find File: /u2/emacs/src//etc/termcap
83 @end example
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}.)
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}.
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.
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.
127   You can also enter remote file names in the minibuffer.
128 @xref{Remote Files}.
130 @node Minibuffer Edit
131 @section Editing in the Minibuffer
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.)
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}).
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.
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}.
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}.
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}).
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.
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}.
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}.
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
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.
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.
217   Although completion is usually done in the minibuffer, the feature
218 is sometimes available in ordinary buffers too.  @xref{Symbol
219 Completion}.
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
229 @node Completion Example
230 @subsection Completion Example
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.
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}.
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.
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.
256   Hence, typing just @kbd{a u @key{TAB} - f @key{TAB}} allows you to
257 enter @samp{auto-fill-mode}.
259 @node Completion Commands
260 @subsection Completion Commands
262   Here is a list of the completion commands defined in the minibuffer
263 when completion is allowed.
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
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.
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}.
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:
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}).
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}).
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}).
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}).
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
340 @node Strict Completion
341 @subsection Strict Completion
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.
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.
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.
361 Cautious completion is used for reading file names for files that must
362 already exist, for example.
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
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.
377 @node Completion Styles
378 @subsection How Completion Alternatives Are Chosen
379 @cindex completion style
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.
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.
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):
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.
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}.)
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.
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
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}):
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).
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.
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
447 @node Completion Options
448 @subsection Completion Options
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.
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 is significant by
466 default; to ignore case differences, change the variable
467 @code{read-buffer-completion-ignore-case} to a non-@code{nil} value.
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.  The variable
473 @code{completion-ignored-extensions} contains a list of strings; a
474 file name ending in any of those strings is ignored as a completion
475 alternative.  The standard value of this variable has several elements
476 including @code{".o"}, @code{".elc"}, and @code{"~"}.  For example, if
477 a directory contains @samp{foo.c} and @samp{foo.elc}, @samp{foo}
478 completes to @samp{foo.c}.  However, if @emph{all} possible
479 completions end in ``ignored'' strings, they are not ignored: in the
480 previous example, @samp{foo.e} completes to @samp{foo.elc}.
481 Displaying the completion list disregards
482 @code{completion-ignored-extensions}; all completions are listed.
484 @vindex completion-auto-help
485   If @code{completion-auto-help} is set to @code{nil}, the completion
486 commands never display the completion list buffer; you must type
487 @kbd{?}  to display the list.  If the value is @code{lazy}, Emacs only
488 shows the completion list buffer on the second attempt to complete.
489 In other words, if there is nothing to complete, the first @key{TAB}
490 echoes @samp{Next char not unique}; the second @key{TAB} does the
491 completion list buffer.
493   If an element of @code{completion-ignored-extensions} ends in a
494 slash (@file{/}), it's a subdirectory name; that directory and its
495 contents are ignored.  Elements of
496 @code{completion-ignored-extensions} that do not end in a slash are
497 ordinary file names.
499 @cindex Icomplete mode
500 @findex icomplete-mode
501   Icomplete mode presents a constantly-updated display that tells you
502 what completions are available for the text you've entered so far.  The
503 command to enable or disable this minor mode is @kbd{M-x
504 icomplete-mode}.
506 @node Minibuffer History
507 @section Minibuffer History
508 @cindex minibuffer history
509 @cindex history of minibuffer input
511   Every argument that you enter with the minibuffer is saved in a
512 @dfn{minibuffer history list} so you can easily use it again later.
513 You can use the following arguments to quickly fetch an earlier
514 argument into the minibuffer:
516 @table @kbd
517 @item M-p
518 @itemx @key{Up}
519 Move to the previous item in the minibuffer history, an earlier
520 argument (@code{previous-history-element}).
521 @item M-n
522 @itemx @key{Down}
523 Move to the next item in the minibuffer history
524 (@code{next-history-element}).
525 @item M-r @var{regexp} @key{RET}
526 Move to an earlier item in the minibuffer history that
527 matches @var{regexp} (@code{previous-matching-history-element}).
528 @item M-s @var{regexp} @key{RET}
529 Move to a later item in the minibuffer history that matches
530 @var{regexp} (@code{next-matching-history-element}).
531 @end table
533 @kindex M-p @r{(minibuffer history)}
534 @kindex M-n @r{(minibuffer history)}
535 @findex next-history-element
536 @findex previous-history-element
537   While in the minibuffer, typing @kbd{M-p} or @key{Up}
538 (@code{previous-history-element}) moves up through the minibuffer
539 history list, one item at a time.  Each @kbd{M-p} fetches an earlier
540 item from the history list into the minibuffer, replacing its existing
541 contents.  Similarly, typing @kbd{M-n} or @key{Down}
542 (@code{next-history-element}) moves back down the history list,
543 fetching later entries into the minibuffer.  You can think of these
544 commands as ``backwards'' and ``forwards'' through the history list.
546   If you type @kbd{M-n} in the minibuffer when there are no later
547 entries in the minibuffer history (e.g., if you haven't previously
548 typed @kbd{M-p}), Emacs tries fetching from a list of default
549 argument: values that you are likely to enter.  You can think of this
550 as moving through the ``future list'' instead of the ``history list''.
552   The input that @kbd{M-p} or @kbd{M-n} fetches into the minibuffer
553 entirely replaces the existing contents of the minibuffer, so you can
554 simply type @key{RET} to use it as an argument.  You can also edit the
555 text before you reuse it; this does not change the history element
556 that you ``moved'' to, but your new argument does go at the end of the
557 history list in its own right.
559 @findex previous-matching-history-element
560 @findex next-matching-history-element
561 @kindex M-r @r{(minibuffer history)}
562 @kindex M-s @r{(minibuffer history)}
563   There are also commands to search forward or backward through the
564 history; they search for history elements that match a regular
565 expression.  @kbd{M-r} (@code{previous-matching-history-element})
566 searches older elements in the history, while @kbd{M-s}
567 (@code{next-matching-history-element}) searches newer elements.  These
568 commands are unusual: they use the minibuffer to read the regular
569 expression even though they are invoked from the minibuffer.  As with
570 incremental searching, an upper-case letter in the regular expression
571 makes the search case-sensitive (@pxref{Search Case}).  You can also
572 search through the history using an incremental search (@pxref{Isearch
573 Minibuffer}).
575   All uses of the minibuffer record your input on a history list, but
576 there are separate history lists for different kinds of arguments.
577 For example, there is a list for file names, used by all the commands
578 that read file names.  (As a special feature, this history list
579 records the absolute file name, even if the name you entered was not
580 absolute.)
582   There are several other specific history lists, including one for
583 buffer names, one for arguments of commands like @code{query-replace},
584 one used by @kbd{M-x} for command names, and one used by
585 @code{compile} for compilation commands.  Finally, there is one
586 ``miscellaneous'' history list that most minibuffer arguments use.
588 @vindex history-length
589   The variable @code{history-length} specifies the maximum length of a
590 minibuffer history list; adding a new element deletes the oldest
591 element if the list gets too long.  If the value of
592 @code{history-length} is @code{t}, there is no maximum length.
594 @vindex history-delete-duplicates
595   The variable @code{history-delete-duplicates} specifies whether to
596 delete duplicates in history.  If it is non-@code{nil}, adding a new
597 element deletes from the list all other elements that are equal to it.
598 The default is @code{nil}.
600 @node Repetition
601 @section Repeating Minibuffer Commands
602 @cindex command history
603 @cindex history of commands
605   Every command that uses the minibuffer once is recorded on a special
606 history list, the @dfn{command history}, together with the values of
607 its arguments, so that you can repeat the entire command.  In
608 particular, every use of @kbd{M-x} is recorded there, since @kbd{M-x}
609 uses the minibuffer to read the command name.
611 @findex list-command-history
612 @table @kbd
613 @item C-x @key{ESC} @key{ESC}
614 Re-execute a recent minibuffer command from the command history
615  (@code{repeat-complex-command}).
616 @item M-x list-command-history
617 Display the entire command history, showing all the commands
618 @kbd{C-x @key{ESC} @key{ESC}} can repeat, most recent first.
619 @end table
621 @kindex C-x ESC ESC
622 @findex repeat-complex-command
623   @kbd{C-x @key{ESC} @key{ESC}} is used to re-execute a recent command
624 that used the minibuffer.  With no argument, it repeats the last such
625 command.  A numeric argument specifies which command to repeat; 1
626 means the last one, 2 the previous, and so on.
628   @kbd{C-x @key{ESC} @key{ESC}} works by turning the previous command
629 into a Lisp expression and then entering a minibuffer initialized with
630 the text for that expression.  Even if you don't understand Lisp
631 syntax, it will probably be obvious which command is displayed for
632 repetition.  If you type just @key{RET}, that repeats the command
633 unchanged.  You can also change the command by editing the Lisp
634 expression before you execute it.  The repeated command is added to
635 the front of the command history unless it is identical to the most
636 recent item.
638   Once inside the minibuffer for @kbd{C-x @key{ESC} @key{ESC}}, you can
639 use the minibuffer history commands (@kbd{M-p}, @kbd{M-n}, @kbd{M-r},
640 @kbd{M-s}; @pxref{Minibuffer History}) to move through the history list
641 of saved entire commands.  After finding the desired previous command,
642 you can edit its expression as usual and then repeat it by typing
643 @key{RET}.
645 @vindex isearch-resume-in-command-history
646   Incremental search does not, strictly speaking, use the minibuffer.
647 Therefore, although it behaves like a complex command, it normally
648 does not appear in the history list for @kbd{C-x @key{ESC} @key{ESC}}.
649 You can make incremental search commands appear in the history by
650 setting @code{isearch-resume-in-command-history} to a non-@code{nil}
651 value.  @xref{Incremental Search}.
653 @vindex command-history
654   The list of previous minibuffer-using commands is stored as a Lisp
655 list in the variable @code{command-history}.  Each element is a Lisp
656 expression which describes one command and its arguments.  Lisp programs
657 can re-execute a command by calling @code{eval} with the
658 @code{command-history} element.
660 @node Passwords
661 @section Entering passwords
663 Sometimes, you may need to enter a password into Emacs.  For instance,
664 when you tell Emacs to visit a file on another machine via a network
665 protocol such as FTP, you often need to supply a password to gain
666 access to the machine (@pxref{Remote Files}).
668   Entering a password is, in a basic sense, similar to using a
669 minibuffer.  Emacs displays a prompt in the echo area (such as
670 @samp{Password: }); after you type the required password, press
671 @key{RET} to submit it.  To prevent others from seeing your password,
672 every character you type is displayed as a dot (@samp{.}) instead of
673 its usual form.
675   Most of the features and commands associated with the minibuffer can
676 @emph{not} be used when entering a password.  There is no history or
677 completion, and you cannot change windows or perform any other action
678 with Emacs until you have submitted the password.
680   While you are typing the password, you may press @key{DEL} to delete
681 backwards, removing the last character entered.  @key{C-u} deletes
682 everything you have typed so far.  @kbd{C-g} quits the password prompt
683 (@pxref{Quitting}).  @kbd{C-y} inserts the current kill into the
684 password (@pxref{Killing}).  You may type either @key{RET} or
685 @key{ESC} to submit the password.  Any other self-inserting character
686 key inserts the associated character into the password, and all other
687 input is ignored.