15.1.7 Searching the Minibuffer
If you start an incremental search while the minibuffer is active, Emacs searches the contents of the minibuffer. Unlike searching an ordinary buffer, the search string is not shown in the echo area, because that is used to display the minibuffer.
If an incremental search fails in the minibuffer, it tries searching the minibuffer history. See Minibuffer History. You can visualize the minibuffer and its history as a series of pages, with the earliest history element on the first page and the current minibuffer on the last page. A forward search, C-s
, searches forward to later pages; a reverse search, C-r
, searches backwards to earlier pages. Like in ordinary buffer search, a failing search can wrap around, going from the last page to the first page or vice versa.
When the current match is on a history element, that history element is pulled into the minibuffer. If you exit the incremental search normally (e.g., by typing RET
), it remains in the minibuffer afterwards. Canceling the search, with C-g
, restores the contents of the minibuffer when you began the search.