GNU Emacs Lisp Reference Manual
A minibuffer history list records previous minibuffer inputs so the user can reuse them conveniently. A history list is actually a symbol, not a list; it is a variable whose value is a list of strings (previous inputs), most recent first.
There are many separate 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.
The basic minibuffer input functions read-from-minibuffer and completing-read both accept an optional argument named hist which is how you specify the history list. Here are the possible values:
variable(variable . startpos)If you specify startpos, then you should also specify that element of the history as the initial minibuffer contents, for consistency.
If you don't specify hist, 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.
Both read-from-minibuffer and 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.
query-replace (and similar arguments to other commands).