manpagez: man pages & more
info emacs
Home | html | info | man
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

9.4 Minibuffer History

Every argument that you enter with the minibuffer is saved on a minibuffer history list so you can easily use it again later. Special commands fetch the text of an earlier argument into the minibuffer, replacing the old minibuffer contents. You can think of them as moving through the history of previous arguments.


Move to the previous item in the minibuffer history, an earlier argument (previous-history-element).


Move to the next item in the minibuffer history (next-history-element).

M-r regexp <RET>

Move to an earlier item in the minibuffer history that matches regexp (previous-matching-history-element).

M-s regexp <RET>

Move to a later item in the minibuffer history that matches regexp (next-matching-history-element).

To move through the minibuffer history list one item at a time, use M-p or up-arrow (previous-history-element) to fetch the next earlier minibuffer input, and use M-n or down-arrow (next-history-element) to fetch the next later input. These commands don't move the cursor, they pull different saved strings into the minibuffer. But you can think of them as “moving” through the history list.

The input that you fetch from the history entirely replaces the contents of the minibuffer. To use it again unchanged, just type <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. You can insert the default value into the minibuffer as text by using M-n. You can think of this as moving “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. M-r (previous-matching-history-element) searches older elements in the history, while M-s (next-matching-history-element) searches newer elements. These commands are unusual; they use the minibuffer to read the regular expression even though they are invoked from the minibuffer. As with incremental searching, an upper-case 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, even if the name you entered was not absolute.)

There are several other specific history lists, including one for buffer names, one for arguments of commands like query-replace, one used by M-x for command names, and one used by compile for compilation commands. Finally, there is one “miscellaneous” history list that most minibuffer arguments use.

The variable 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 of history-length is t, though, there is no maximum length.

The variable history-delete-duplicates specifies whether to delete duplicates in history. If it is t, adding a new element deletes from the list all other elements that are equal to it.

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]
© 2000-2017
Individual documents may contain additional copyright information.