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