21.10 Minibuffer Commands

This section describes some commands meant for use in the minibuffer.

Command: exit-minibuffer

This command exits the active minibuffer. It is normally bound to keys in minibuffer local keymaps. The command throws an error if the current buffer is a minibuffer, but not the active minibuffer.

Command: self-insert-and-exit

This command exits the active minibuffer after inserting the last character typed on the keyboard (found in last-command-event; see Information from the Command Loop).

Command: previous-history-element n

This command replaces the minibuffer contents with the value of the nth previous (older) history element.

Command: next-history-element n

This command replaces the minibuffer contents with the value of the nth more recent history element. The position in the history can go beyond the current position and invoke “future history” (see Reading Text Strings with the Minibuffer).

Command: previous-matching-history-element pattern n

This command replaces the minibuffer contents with the value of the nth previous (older) history element that matches pattern (a regular expression).

Command: next-matching-history-element pattern n

This command replaces the minibuffer contents with the value of the nth next (newer) history element that matches pattern (a regular expression).

Command: previous-complete-history-element n

This command replaces the minibuffer contents with the value of the nth previous (older) history element that completes the current contents of the minibuffer before the point.

Command: next-complete-history-element n

This command replaces the minibuffer contents with the value of the nth next (newer) history element that completes the current contents of the minibuffer before the point.

Command: goto-history-element nabs

This function puts element of the minibuffer history in the minibuffer. The argument nabs specifies the absolute history position in descending order, where 0 means the current element and a positive number n means the nth previous element. NABS being a negative number -n means the nth entry of “future history”. When this function reaches the end of the default values provided by read-from-minibuffer (see Reading Text Strings with the Minibuffer) and completing-read (see Completion and the Minibuffer), it adds the completion candidates to “future history”, see minibuffer-default-add-function.