Every argument that you enter with the minibuffer is saved on a minibuffer history list so that you can use it again later in another argument. Special commands load the text of an earlier argument in the minibuffer. They discard the old minibuffer contents, so you can think of them as moving through the history of previous arguments.
The simplest way to reuse the saved arguments in the history list is
to move through the history list one element at a time. While in the
minibuffer, use M-p or up-arrow (
to "move to" the next earlier minibuffer input, and use M-n or
next-history-element) to "move to" the next later
The previous input that you fetch from the history entirely replaces the contents of the minibuffer. To use it as the argument, exit the minibuffer as usual with RET. You can also edit the text before you reuse it; this does not change the history element that you "moved" to, but your new argument does go at the end of the history list in its own right.
For many minibuffer arguments there is a "default" value. In some cases, the minibuffer history commands know the default value. Then you can insert the default value into the minibuffer as text by using M-n to move "into the future" in the history. Eventually we hope to make this feature available whenever the minibuffer has a default value.
There are also commands to search forward or backward through the
history; they search for history elements that match a regular
expression that you specify with the minibuffer. M-r
previous-matching-history-element) searches older elements in
the history, while M-s (
searches newer elements. By special dispensation, these commands can
use the minibuffer to read their arguments even though you are already
in the minibuffer when you issue them. As with incremental searching,
an uppercase letter in the regular expression makes the search
case-sensitive (see section Searching and Case).
All uses of the minibuffer record your input on a history list, but there are separate history lists for different kinds of arguments. For example, there is a list for file names, used by all the commands that read file names. (As a special feature, this history list records the absolute file name, no more and no less, even if that is not how you entered the file name.)
There are several other very specific history lists, including one for
command names read by M-x, one for buffer names, one for arguments
of commands like
query-replace, and one for compilation commands
compile. Finally, there is one "miscellaneous" history
list that most minibuffer arguments use.
history-length specifies the maximum length of a
minibuffer history list; once a list gets that long, the oldest element
is deleted each time an element is added. If the value of
t, though, there is no maximum length
and elements are never deleted.
Go to the first, previous, next, last section, table of contents.