*** empty log message ***
[bpt/emacs.git] / man / mini.texi
CommitLineData
6bf7aab6 1@c This is part of the Emacs manual.
b65d8176 2@c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
8d99e09d 3@c 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
6bf7aab6
DL
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 the facility used by Emacs commands to read
10arguments more complicated than a single number. Minibuffer arguments
11can be file names, buffer names, Lisp function names, Emacs command
12names, Lisp expressions, and many other things, depending on the command
13reading the argument. You can use the usual Emacs editing commands in
14the minibuffer to edit the argument text.
15
16@cindex prompt
17 When the minibuffer is in use, it appears in the echo area, and the
18terminal's cursor moves there. The beginning of the minibuffer line
c0a5ac4a
RS
19displays a @dfn{prompt} in a special color, to say what kind of input
20you should supply and how it will be used. Often this prompt is
21derived from the name of the command that the argument is for. The
22prompt normally ends with a colon.
6bf7aab6
DL
23
24@cindex default argument
42b5e85e 25 Sometimes a @dfn{default argument} appears in parentheses before the
6bf7aab6 26colon; it too is part of the prompt. The default will be used as the
58fa012d 27argument value if you enter an empty argument (that is, just type
6bf7aab6
DL
28@key{RET}). For example, commands that read buffer names always show a
29default, which is the name of the buffer that will be used if you type
30just @key{RET}.
31
32 The simplest way to enter a minibuffer argument is to type the text
33you want, terminated by @key{RET} which exits the minibuffer. You can
34cancel the command that wants the argument, and get out of the
35minibuffer, by typing @kbd{C-g}.
36
37 Since the minibuffer uses the screen space of the echo area, it can
38conflict with other ways Emacs customarily uses the echo area. Here is how
39Emacs handles such conflicts:
40
41@itemize @bullet
42@item
43If a command gets an error while you are in the minibuffer, this does
44not cancel the minibuffer. However, the echo area is needed for the
45error message and therefore the minibuffer itself is hidden for a
46while. It comes back after a few seconds, or as soon as you type
47anything.
48
49@item
1ba2ce68
RS
50If in the minibuffer you use a command whose purpose is to display a
51message in the echo area, such as @kbd{C-x =}, the message hides the
52minibuffer for a while. The minibuffer contents come back after a few
53seconds, or as soon as you type anything.
6bf7aab6
DL
54
55@item
56Echoing of keystrokes does not take place while the minibuffer is in
57use.
58@end itemize
59
60@menu
61* File: Minibuffer File. Entering file names with the minibuffer.
62* Edit: Minibuffer Edit. How to edit in the minibuffer.
63* Completion:: An abbreviation facility for minibuffer input.
64* Minibuffer History:: Reusing recent minibuffer arguments.
65* Repetition:: Re-executing commands that used the minibuffer.
66@end menu
67
68@node Minibuffer File
69@section Minibuffers for File Names
70
71 Sometimes the minibuffer starts out with text in it. For example, when
72you are supposed to give a file name, the minibuffer starts out containing
73the @dfn{default directory}, which ends with a slash. This is to inform
74you which directory the file will be found in if you do not specify a
75directory.
76
eb9ee0db 77@c Separate paragraph to clean up ugly page break--rms
6bf7aab6
DL
78@need 1500
79 For example, the minibuffer might start out with these contents:
80
81@example
82Find File: /u2/emacs/src/
83@end example
84
85@noindent
8bd800db
RS
86where @samp{Find File:@: } is the prompt. Typing @kbd{buffer.c} as
87input specifies the file @file{/u2/emacs/src/buffer.c}. To find files
88in nearby directories, use @kbd{..}; thus, if you type
6bf7aab6
DL
89@kbd{../lisp/simple.el}, you will get the file named
90@file{/u2/emacs/lisp/simple.el}. Alternatively, you can kill with
91@kbd{M-@key{DEL}} the directory names you don't want (@pxref{Words}).
92
93 If you don't want any of the default, you can kill it with @kbd{C-a
94C-k}. But you don't need to kill the default; you can simply ignore it.
95Insert an absolute file name, one starting with a slash or a tilde,
96after the default directory. For example, to specify the file
97@file{/etc/termcap}, just insert that name, giving these minibuffer
98contents:
99
100@example
101Find File: /u2/emacs/src//etc/termcap
102@end example
103
104@noindent
105@cindex // in file name
106@cindex double slash in file name
107@cindex slashes repeated in file name
cf6ac72b 108@findex file-name-shadow-mode
6bf7aab6 109GNU Emacs gives a special meaning to a double slash (which is not
cf6ac72b
RS
110normally a useful thing to write): it means, ``ignore everything
111before the second slash in the pair.'' Thus, @samp{/u2/emacs/src/} is
112ignored in the example above, and you get the file
113@file{/etc/termcap}. The ignored part of the file name is dimmed if
114the terminal allows it; to disable this, turn off
3abf5917 115@code{file-name-shadow-mode} minor mode.
6bf7aab6 116
708bf232
RS
117 If you set @code{insert-default-directory} to @code{nil}, the
118default directory is never inserted in the minibuffer---so the
119minibuffer starts out empty. But the name you type, if relative, is
120still interpreted with respect to the same default directory.
6bf7aab6
DL
121
122@node Minibuffer Edit
123@section Editing in the Minibuffer
124
125 The minibuffer is an Emacs buffer (albeit a peculiar one), and the usual
126Emacs commands are available for editing the text of an argument you are
127entering.
128
129 Since @key{RET} in the minibuffer is defined to exit the minibuffer,
130you can't use it to insert a newline in the minibuffer. To do that,
708bf232
RS
131type @kbd{C-o} or @kbd{C-q C-j}. (The newline character is really the
132@acronym{ASCII} character control-J.)
133
134 The minibuffer has its own window, which normally has space on the
135Emacs frame at all times, but it only acts like an Emacs window when
136the minibuffer is really in use. At those times, its window is much
137like any other Emacs window; you can switch from the minibuffer window
138to another window with @kbd{C-x o}, and edit text in other windows,
139before returning to the minibuffer to submit the argument. You can
140kill text in another window, return to the minibuffer window, and then
141yank the text to use it in the argument. @xref{Windows}.
6bf7aab6 142
6bf7aab6
DL
143@cindex height of minibuffer
144@cindex size of minibuffer
145@cindex growing minibuffer
b80da86d 146@cindex resizing minibuffer
6bf7aab6
DL
147 There are some restrictions on the use of the minibuffer window,
148however. You cannot switch buffers in it---the minibuffer and its
149window are permanently attached. Also, you cannot split or kill the
150minibuffer window. But you can make it taller in the normal fashion
1cf7421b
GM
151with @kbd{C-x ^}.
152
153@vindex resize-mini-windows
58fa012d 154 The minibuffer window expands vertically as necessary to hold the
c0a5ac4a
RS
155text that you put in the minibuffer. If @code{resize-mini-windows} is
156@code{t} (the default), the window is always resized to fit the size
157of the text it displays. If its value is the symbol @code{grow-only},
158the window grows when the size of displayed text increases, but
159shrinks (back to the normal size) only when the minibuffer becomes
160inactive. If its value is @code{nil}, you have to adjust the height
161yourself.
1cf7421b
GM
162
163@vindex max-mini-window-height
79529b12
RS
164 The variable @code{max-mini-window-height} controls the maximum
165height for resizing the minibuffer window: a floating-point number
166specifies a fraction of the frame's height; an integer specifies the
167maximum number of lines; @code{nil} means do not resize the minibuffer
168window automatically. The default value is 0.25.
6bf7aab6 169
c0a5ac4a
RS
170 If, while in the minibuffer, you issue a command that displays help
171text of any sort in another window, you can use the @kbd{C-M-v}
172command while in the minibuffer to scroll the help text.
173(@kbd{M-@key{PAGEUP}} and @kbd{M-@key{PAGEDOWN}} also operate on that
174help text.) This lasts until you exit the minibuffer. This feature
175is especially useful when you display a buffer listing possible
176completions. @xref{Other Window}.
6bf7aab6
DL
177
178@vindex enable-recursive-minibuffers
179 Emacs normally disallows most commands that use the minibuffer while
180the minibuffer is active. This rule is to prevent recursive minibuffers
181from confusing novice users. If you want to be able to use such
182commands in the minibuffer, set the variable
183@code{enable-recursive-minibuffers} to a non-@code{nil} value.
184
185@node Completion
186@section Completion
187@cindex completion
188
189 For certain kinds of arguments, you can use @dfn{completion} to enter
190the argument value. Completion means that you type part of the
191argument, then Emacs visibly fills in the rest, or as much as
192can be determined from the part you have typed.
193
194 When completion is available, certain keys---@key{TAB}, @key{RET}, and
285b48ff 195@key{SPC}---are rebound to complete the text in the minibuffer before point
6bf7aab6
DL
196into a longer string that it stands for, by matching it against a set of
197@dfn{completion alternatives} provided by the command reading the
198argument. @kbd{?} is defined to display a list of possible completions
199of what you have inserted.
200
c90475c9
RS
201 For example, when @kbd{M-x} uses the minibuffer to read the name of
202a command, it provides a list of all available Emacs command names to
285b48ff 203complete against. The completion keys match the minibuffer text
6bf7aab6
DL
204against all the command names, find any additional name characters
205implied by the ones already present in the minibuffer, and add those
206characters to the ones you have given. This is what makes it possible
207to type @kbd{M-x ins @key{SPC} b @key{RET}} instead of @kbd{M-x
c90475c9
RS
208insert-buffer @key{RET}} (for example). (@key{SPC} does not do
209completion in reading file names, because it is common to use spaces
210in file names on some systems.)
6bf7aab6
DL
211
212 Case is normally significant in completion, because it is significant
213in most of the names that you can complete (buffer names, file names and
214command names). Thus, @samp{fo} does not complete to @samp{Foo}.
215Completion does ignore case distinctions for certain arguments in which
216case does not matter.
217
be8a531d
RS
218 Completion acts only on the text before point. If there is text in
219the minibuffer after point---i.e., if you move point backward after
220typing some text into the minibuffer---it remains unchanged.
221
6bf7aab6 222@menu
50fcce74
JL
223* Example: Completion Example. Examples of using completion.
224* Commands: Completion Commands. A list of completion commands.
225* Strict Completion:: Different types of completion.
226* Options: Completion Options. Options for completion.
6bf7aab6
DL
227@end menu
228
229@node Completion Example
230@subsection Completion Example
231
232@kindex TAB @r{(completion)}
233@findex minibuffer-complete
234 A concrete example may help here. If you type @kbd{M-x au @key{TAB}},
235the @key{TAB} looks for alternatives (in this case, command names) that
236start with @samp{au}. There are several, including
237@code{auto-fill-mode} and @code{auto-save-mode}---but they are all the
238same as far as @code{auto-}, so the @samp{au} in the minibuffer changes
239to @samp{auto-}.@refill
240
241 If you type @key{TAB} again immediately, there are multiple
242possibilities for the very next character---it could be any of
243@samp{cfilrs}---so no more characters are added; instead, @key{TAB}
244displays a list of all possible completions in another window.
245
246 If you go on to type @kbd{f @key{TAB}}, this @key{TAB} sees
247@samp{auto-f}. The only command name starting this way is
248@code{auto-fill-mode}, so completion fills in the rest of that. You now
249have @samp{auto-fill-mode} in the minibuffer after typing just @kbd{au
250@key{TAB} f @key{TAB}}. Note that @key{TAB} has this effect because in
251the minibuffer it is bound to the command @code{minibuffer-complete}
252when completion is available.
253
254@node Completion Commands
255@subsection Completion Commands
256
257 Here is a list of the completion commands defined in the minibuffer
258when completion is available.
259
260@table @kbd
261@item @key{TAB}
285b48ff 262Complete the text before point in the minibuffer as much as possible
6bf7aab6
DL
263(@code{minibuffer-complete}).
264@item @key{SPC}
c90475c9
RS
265Complete the minibuffer text before point, but don't go beyond one
266word (@code{minibuffer-complete-word}). @key{SPC} for completion is
267not available when entering a file name, since some users often put
268spaces in filenames.
6bf7aab6
DL
269@item @key{RET}
270Submit the text in the minibuffer as the argument, possibly completing
da4d9773
LT
271first as described
272@iftex
273in the next subsection (@code{minibuffer-complete-and-exit}).
274@end iftex
275@ifnottex
276in the next node (@code{minibuffer-complete-and-exit}). @xref{Strict
277Completion}.
278@end ifnottex
6bf7aab6 279@item ?
1ba2ce68 280Display a list of all possible completions of the text in the minibuffer
8db30414 281(@code{minibuffer-completion-help}).
6bf7aab6
DL
282@end table
283
284@kindex SPC
285@findex minibuffer-complete-word
286 @key{SPC} completes much like @key{TAB}, but never goes beyond the
287next hyphen or space. If you have @samp{auto-f} in the minibuffer and
288type @key{SPC}, it finds that the completion is @samp{auto-fill-mode},
289but it stops completing after @samp{fill-}. This gives
290@samp{auto-fill-}. Another @key{SPC} at this point completes all the
a9749dab
RS
291way to @samp{auto-fill-mode}. The command that implements this
292behavior is called @code{minibuffer-complete-word}.
6bf7aab6
DL
293
294 Here are some commands you can use to choose a completion from a
295window that displays a list of completions:
296
297@table @kbd
298@findex mouse-choose-completion
c0a5ac4a
RS
299@item Mouse-1
300@itemx Mouse-2
301Clicking mouse button 1 or 2 on a completion in the list of possible
6bf7aab6 302completions chooses that completion (@code{mouse-choose-completion}).
58fa012d 303You normally use this command while point is in the minibuffer, but you
6bf7aab6
DL
304must click in the list of completions, not in the minibuffer itself.
305
306@findex switch-to-completions
307@item @key{PRIOR}
308@itemx M-v
309Typing @key{PRIOR} or @key{PAGE-UP}, or @kbd{M-v}, while in the
310minibuffer, selects the window showing the completion list buffer
311(@code{switch-to-completions}). This paves the way for using the
312commands below. (Selecting that window in the usual ways has the same
313effect, but this way is more convenient.)
314
315@findex choose-completion
316@item @key{RET}
317Typing @key{RET} @emph{in the completion list buffer} chooses the
318completion that point is in or next to (@code{choose-completion}). To
319use this command, you must first switch windows to the window that shows
320the list of completions.
321
322@findex next-completion
323@item @key{RIGHT}
324Typing the right-arrow key @key{RIGHT} @emph{in the completion list
325buffer} moves point to the following completion (@code{next-completion}).
326
327@findex previous-completion
328@item @key{LEFT}
329Typing the left-arrow key @key{LEFT} @emph{in the completion list
330buffer} moves point toward the beginning of the buffer, to the previous
331completion (@code{previous-completion}).
332@end table
333
334@node Strict Completion
335@subsection Strict Completion
336
337 There are three different ways that @key{RET} can work in completing
338minibuffers, depending on how the argument will be used.
339
340@itemize @bullet
341@item
342@dfn{Strict} completion is used when it is meaningless to give any
343argument except one of the known alternatives. For example, when
344@kbd{C-x k} reads the name of a buffer to kill, it is meaningless to
345give anything but the name of an existing buffer. In strict
346completion, @key{RET} refuses to exit if the text in the minibuffer
347does not complete to an exact match.
348
349@item
350@dfn{Cautious} completion is similar to strict completion, except that
351@key{RET} exits only if the text was an exact match already, not
352needing completion. If the text is not an exact match, @key{RET} does
353not exit, but it does complete the text. If it completes to an exact
354match, a second @key{RET} will exit.
355
356Cautious completion is used for reading file names for files that must
357already exist.
358
359@item
360@dfn{Permissive} completion is used when any string whatever is
361meaningful, and the list of completion alternatives is just a guide.
362For example, when @kbd{C-x C-f} reads the name of a file to visit, any
363file name is allowed, in case you want to create a file. In
364permissive completion, @key{RET} takes the text in the minibuffer
365exactly as given, without completing it.
366@end itemize
367
368 The completion commands display a list of all possible completions in
369a window whenever there is more than one possibility for the very next
370character. Also, typing @kbd{?} explicitly requests such a list. If
371the list of completions is long, you can scroll it with @kbd{C-M-v}
372(@pxref{Other Window}).
373
374@node Completion Options
375@subsection Completion Options
376
377@vindex completion-ignored-extensions
89dc96ee 378@cindex ignored file names, in completion
6bf7aab6
DL
379 When completion is done on file names, certain file names are usually
380ignored. The variable @code{completion-ignored-extensions} contains a
381list of strings; a file whose name ends in any of those strings is
382ignored as a possible completion. The standard value of this variable
383has several elements including @code{".o"}, @code{".elc"}, @code{".dvi"}
384and @code{"~"}. The effect is that, for example, @samp{foo} can
385complete to @samp{foo.c} even though @samp{foo.o} exists as well.
386However, if @emph{all} the possible completions end in ``ignored''
387strings, then they are not ignored. Ignored extensions do not apply to
388lists of completions---those always mention all possible completions.
389
44829d96
EZ
390 If an element of the list in @code{completion-ignored-extensions} ends
391in a slash @file{/}, it indicates a subdirectory that should be ignored
708bf232 392when completing file names. Elements of
44829d96
EZ
393@code{completion-ignored-extensions} which do not end in a slash are
394never considered when a completion candidate is a directory; thus,
395completion returns directories whose names end in @file{.elc} even
708bf232 396though there's an element @code{".elc"} in the list.
44829d96 397
6bf7aab6 398@vindex completion-auto-help
a9749dab
RS
399 Normally, a completion command that cannot determine even one
400additional character automatically displays a list of all possible
58fa012d 401completions. If the variable @code{completion-auto-help} is set to
a9749dab
RS
402@code{nil}, this automatic display is disabled, so you must type
403@kbd{?} to display the list of completions.
6bf7aab6 404
8efd3a2b
DL
405@cindex Partial Completion mode
406@vindex partial-completion-mode
407@findex partial-completion-mode
79529b12
RS
408 Partial Completion mode implements a more powerful kind of
409completion that can complete multiple words in parallel. For example,
410it can complete the command name abbreviation @code{p-b} into
411@code{print-buffer}, because no other command starts with two words
412whose initials are @samp{p} and @samp{b}.
413
414 Partial completion of directories in file names uses @samp{*} to
415indicate the places for completion; thus, @file{/u*/b*/f*} might
416complete to @file{/usr/bin/foo}.
417
418 To enable this mode, use the command @kbd{M-x
19b2c4ca 419partial-completion-mode}, or customize the variable
79529b12
RS
420@code{partial-completion-mode}. This binds the partial completion
421commands to @key{TAB}, @key{SPC}, @key{RET}, and @kbd{?}. The usual
eda8cfcf 422completion commands are available on @kbd{M-@key{TAB}} (or
285d5fe6 423@kbd{C-M-i}), @kbd{M-@key{SPC}}, @kbd{M-@key{RET}} and @kbd{M-?}.
79529b12 424
8efd3a2b
DL
425@vindex PC-include-file-path
426@vindex PC-disable-includes
79529b12 427 Another feature of Partial Completion mode is to extend
da4d9773 428@code{find-file} so that @samp{<@var{include}>} stands for the
79529b12
RS
429file named @var{include} in some directory in the path
430@code{PC-include-file-path}. If you set @code{PC-disable-includes} to
0c141837 431non-@code{nil}, this feature is disabled.
6bf7aab6
DL
432
433@cindex Icomplete mode
8efd3a2b 434@findex icomplete-mode
6bf7aab6
DL
435 Icomplete mode presents a constantly-updated display that tells you
436what completions are available for the text you've entered so far. The
437command to enable or disable this minor mode is @kbd{M-x
438icomplete-mode}.
439
440@node Minibuffer History
441@section Minibuffer History
442@cindex minibuffer history
443@cindex history of minibuffer input
444
445 Every argument that you enter with the minibuffer is saved on a
446@dfn{minibuffer history list} so that you can use it again later in
447another argument. Special commands load the text of an earlier argument
448in the minibuffer. They discard the old minibuffer contents, so you can
449think of them as moving through the history of previous arguments.
450
451@table @kbd
452@item @key{UP}
453@itemx M-p
454Move to the next earlier argument string saved in the minibuffer history
455(@code{previous-history-element}).
456@item @key{DOWN}
457@itemx M-n
458Move to the next later argument string saved in the minibuffer history
459(@code{next-history-element}).
460@item M-r @var{regexp} @key{RET}
461Move to an earlier saved argument in the minibuffer history that has a
462match for @var{regexp} (@code{previous-matching-history-element}).
463@item M-s @var{regexp} @key{RET}
464Move to a later saved argument in the minibuffer history that has a
465match for @var{regexp} (@code{next-matching-history-element}).
466@end table
467
468@kindex M-p @r{(minibuffer history)}
469@kindex M-n @r{(minibuffer history)}
470@findex next-history-element
471@findex previous-history-element
472 The simplest way to reuse the saved arguments in the history list is
473to move through the history list one element at a time. While in the
c0a5ac4a
RS
474minibuffer, use @kbd{M-p} or up-arrow
475(@code{previous-history-element}) to ``move to'' the next earlier
476minibuffer input, and use @kbd{M-n} or down-arrow
477(@code{next-history-element}) to ``move to'' the next later input.
478These commands don't move the cursor, they bring different saved
479strings into the minibuffer. But you can think of them as ``moving''
480through the history list.
6bf7aab6
DL
481
482 The previous input that you fetch from the history entirely replaces
483the contents of the minibuffer. To use it as the argument, exit the
484minibuffer as usual with @key{RET}. You can also edit the text before
485you reuse it; this does not change the history element that you
486``moved'' to, but your new argument does go at the end of the history
487list in its own right.
488
708bf232
RS
489 For many minibuffer arguments there is a ``default'' value. Then
490you can insert the default value into the minibuffer as text by using
491@kbd{M-n} to move ``into the future'' in the history.
6bf7aab6
DL
492
493@findex previous-matching-history-element
494@findex next-matching-history-element
495@kindex M-r @r{(minibuffer history)}
496@kindex M-s @r{(minibuffer history)}
497 There are also commands to search forward or backward through the
498history; they search for history elements that match a regular
499expression that you specify with the minibuffer. @kbd{M-r}
500(@code{previous-matching-history-element}) searches older elements in
501the history, while @kbd{M-s} (@code{next-matching-history-element})
502searches newer elements. By special dispensation, these commands can
503use the minibuffer to read their arguments even though you are already
504in the minibuffer when you issue them. As with incremental searching,
f8635375 505an upper-case letter in the regular expression makes the search
6bf7aab6
DL
506case-sensitive (@pxref{Search Case}).
507
508@ignore
509 We may change the precise way these commands read their arguments.
510Perhaps they will search for a match for the string given so far in the
511minibuffer; perhaps they will search for a literal match rather than a
512regular expression match; perhaps they will only accept matches at the
513beginning of a history element; perhaps they will read the string to
514search for incrementally like @kbd{C-s}. To find out what interface is
515actually available, type @kbd{C-h f previous-matching-history-element}.
516@end ignore
517
518 All uses of the minibuffer record your input on a history list, but
519there are separate history lists for different kinds of arguments. For
520example, there is a list for file names, used by all the commands that
521read file names. (As a special feature, this history list records
522the absolute file name, no more and no less, even if that is not how
523you entered the file name.)
524
525 There are several other very specific history lists, including one for
526command names read by @kbd{M-x}, one for buffer names, one for arguments
527of commands like @code{query-replace}, and one for compilation commands
528read by @code{compile}. Finally, there is one ``miscellaneous'' history
529list that most minibuffer arguments use.
530
531@vindex history-length
532 The variable @code{history-length} specifies the maximum length of a
533minibuffer history list; once a list gets that long, the oldest element
534is deleted each time an element is added. If the value of
535@code{history-length} is @code{t}, though, there is no maximum length
536and elements are never deleted.
537
fbb2f03d
JL
538@vindex history-delete-duplicates
539 The variable @code{history-delete-duplicates} specifies whether to
540delete duplicates in history. If the value of @code{history-delete-duplicates}
541is @code{t}, that means when adding a new history element, all
542previous identical elements are deleted.
543
6bf7aab6
DL
544@node Repetition
545@section Repeating Minibuffer Commands
546@cindex command history
547@cindex history of commands
548
549 Every command that uses the minibuffer at least once is recorded on a
550special history list, together with the values of its arguments, so that
551you can repeat the entire command. In particular, every use of
552@kbd{M-x} is recorded there, since @kbd{M-x} uses the minibuffer to read
553the command name.
554
555@findex list-command-history
6bf7aab6
DL
556@table @kbd
557@item C-x @key{ESC} @key{ESC}
558Re-execute a recent minibuffer command (@code{repeat-complex-command}).
559@item M-x list-command-history
560Display the entire command history, showing all the commands
561@kbd{C-x @key{ESC} @key{ESC}} can repeat, most recent first.
562@end table
563
564@kindex C-x ESC ESC
565@findex repeat-complex-command
566 @kbd{C-x @key{ESC} @key{ESC}} is used to re-execute a recent
567minibuffer-using command. With no argument, it repeats the last such
568command. A numeric argument specifies which command to repeat; one
569means the last one, and larger numbers specify earlier ones.
570
571 @kbd{C-x @key{ESC} @key{ESC}} works by turning the previous command
572into a Lisp expression and then entering a minibuffer initialized with
573the text for that expression. If you type just @key{RET}, the command
574is repeated as before. You can also change the command by editing the
575Lisp expression. Whatever expression you finally submit is what will be
576executed. The repeated command is added to the front of the command
577history unless it is identical to the most recently executed command
578already there.
579
580 Even if you don't understand Lisp syntax, it will probably be obvious
581which command is displayed for repetition. If you do not change the
582text, it will repeat exactly as before.
583
584 Once inside the minibuffer for @kbd{C-x @key{ESC} @key{ESC}}, you can
585use the minibuffer history commands (@kbd{M-p}, @kbd{M-n}, @kbd{M-r},
586@kbd{M-s}; @pxref{Minibuffer History}) to move through the history list
587of saved entire commands. After finding the desired previous command,
588you can edit its expression as usual and then resubmit it by typing
589@key{RET} as usual.
590
3cfa7873 591@vindex isearch-resume-in-command-history
285b48ff 592 Incremental search does not, strictly speaking, use the minibuffer,
3cfa7873
KS
593but it does something similar. Although it behaves like a complex command,
594it normally does not appear in the history list for @kbd{C-x
595@key{ESC} @key{ESC}}. You can make it appear in the history by
596setting @code{isearch-resume-in-command-history} to a non-@code{nil}
c0a5ac4a 597value. @xref{Incremental Search}.
285b48ff 598
6bf7aab6
DL
599@vindex command-history
600 The list of previous minibuffer-using commands is stored as a Lisp
601list in the variable @code{command-history}. Each element is a Lisp
602expression which describes one command and its arguments. Lisp programs
603can re-execute a command by calling @code{eval} with the
604@code{command-history} element.
ab5796a9
MB
605
606@ignore
607 arch-tag: ba913cfd-b70e-400f-b663-22b2c309227f
608@end ignore