Every argument that you enter with the minibuffer is saved in a minibuffer history list so you can easily use it again later. You can use the following arguments to quickly fetch an earlier argument into the minibuffer:
While in the minibuffer, M-p (
moves through the minibuffer history list, one item at a time. Each
M-p fetches an earlier item from the history list into the
minibuffer, replacing its existing contents. Typing M-n
next-history-element) moves through the minibuffer history
list in the opposite direction, fetching later entries into the
If you type M-n in the minibuffer when there are no later entries in the minibuffer history (e.g., if you haven't previously typed M-p), Emacs tries fetching from a list of default arguments: values that you are likely to enter. You can think of this as moving through the “future history”.
The arrow keys <UP> and <DOWN> work like M-p and M-n, but if the current history item is longer than a single line, they allow you to move to the previous or next line of the current history item before going to the previous or next history item.
If you edit the text inserted by the M-p or M-n minibuffer history commands, this does not change its entry in the history list. However, the edited argument does go at the end of the history list when you submit it.
You can use M-r (
search through older elements in the history list, and M-s
next-matching-history-element) to search through newer
entries. Each of these commands asks for a regular expression
as an argument, and fetches the first matching entry into the
minibuffer. See Regexps, for an explanation of regular
expressions. A numeric prefix argument n means to fetch the
nth matching entry. These commands are unusual, in that they
use the minibuffer to read the regular expression argument, even
though they are invoked from the minibuffer. An upper-case letter in
the regular expression makes the search case-sensitive (see Lax Search).
You can also search through the history using an incremental search. See Isearch Minibuffer.
Emacs keeps separate history lists for several different kinds of
arguments. For example, there is a list for file names, used by all
the commands that read file names. Other history lists include buffer
names, command names (used by M-x), and command arguments (used
by commands like
history-length specifies the maximum length of a
minibuffer history list; adding a new element deletes the oldest
element if the list gets too long. If the value is
t, there is
no maximum length.
history-delete-duplicates specifies whether to
delete duplicates in history. If it is non-
nil, adding a new
element deletes from the list all other elements that are equal to it.
The default is