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.
Move to the next earlier argument string saved in the minibuffer history
Move to the next later argument string saved in the minibuffer history
Move to an earlier saved argument in the minibuffer history that has a
match for regexp (
Move to a later saved argument in the minibuffer history that has a
match for regexp (
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.
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 Search 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.
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.