[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

E.4 Minibuffer History

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.

UP
M-p
Move to the next earlier argument string saved in the minibuffer history (previous-history-element).
DOWN
M-n
Move to the next later argument string saved in the minibuffer history (next-history-element).
M-r regexp RET
Move to an earlier saved argument in the minibuffer history that has a match for regexp (previous-matching-history-element).
M-s regexp RET
Move to a later saved argument in the minibuffer history that has a match for regexp (next-matching-history-element).

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 (previous-history-element) to "move to" the next earlier minibuffer input, and use M-n or down-arrow (next-history-element) to "move to" the next later input.

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 (next-matching-history-element) 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 upper-case letter in the regular expression makes the search case-sensitive (see section K.6 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 read by compile. 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; once a list gets that long, the oldest element is deleted each time an element is added. If the value of history-length is t, though, there is no maximum length and elements are never deleted.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on April 2, 2002 using texi2html