A minibuffer history list records previous minibuffer inputs so the user can reuse them conveniently. It is a variable whose value is a list of strings (previous inputs), most recent first.
There are many separate minibuffer history lists, used for different kinds of inputs. It’s the Lisp programmer’s job to specify the right history list for each use of the minibuffer.
You specify a minibuffer history list with the optional history
Here are the possible values for it:
Use variable (a symbol) as the history list.
Use variable (a symbol) as the history list, and assume that the initial history position is startpos (a nonnegative integer).
Specifying 0 for startpos is equivalent to just specifying the
previous-history-element will display
the most recent element of the history list in the minibuffer. If you
specify a positive startpos, the minibuffer history functions
behave as if
(elt variable (1- startpos)) were the
history element currently shown in the minibuffer.
For consistency, you should also specify that element of the history as the initial minibuffer contents, using the initial argument to the minibuffer input function (see Initial Input).
If you don’t specify history, then the default history list
minibuffer-history is used. For other standard history lists,
see below. You can also create your own history list variable; just
initialize it to
nil before the first use.
completing-read add new
elements to the history list automatically, and provide commands to
allow the user to reuse items on the list. The only thing your program
needs to do to use a history list is to initialize it and to pass its
name to the input functions when you wish. But it is safe to modify the
list by hand when the minibuffer input functions are not using it.
Emacs functions that add a new element to a history list can also
delete old elements if the list gets too long. The variable
history-length specifies the maximum length for most history
lists. To specify a different maximum length for a particular history
list, put the length in the
history-length property of the
history list symbol. The variable
specifies whether to delete duplicates in history.
This function adds a new element newelt, if it isn’t the empty
string, to the history list stored in the variable history-var,
and returns the updated history list. It limits the list length to
the value of maxelt (if non-
(described below). The possible values of maxelt have the same
meaning as the values of
add-to-history removes duplicate members from the
history list if
history-delete-duplicates is non-
However, if keep-all is non-
nil, that says not to remove
duplicates, and to add newelt to the list even if it is empty.
If the value of this variable is
nil, standard functions that
read from the minibuffer don’t add new elements to the history list.
This lets Lisp programs explicitly manage input history by using
add-to-history. The default value is
The value of this variable specifies the maximum length for all
history lists that don’t specify their own maximum lengths. If the
t, that means there is no maximum (don’t delete old
elements). If a history list variable’s symbol has a non-
history-length property, it overrides this variable for that
particular history list.
If the value of this variable is
t, that means when adding a
new history element, all previous identical elements are deleted.
Here are some of the standard minibuffer history list variables:
The default history list for minibuffer history input.
A history list for arguments to
query-replace (and similar
arguments to other commands).
A history list for file-name arguments.
A history list for buffer-name arguments.
A history list for regular expression arguments.
A history list for arguments that are names of extended commands.
A history list for arguments that are shell commands.
A history list for arguments that are Lisp expressions to evaluate.
A history list for arguments that are faces.