Next: , Previous: Special Isearch, Up: Incremental Search

15.1.6 Not Exiting Incremental Search

This subsection describes how to control whether typing a command not specifically meaningful is searches exits the search before executing the command. It also describes two categories of commands which you can type without exiting the current incremental search, even though they are not themselves part of incremental search.

Normally, typing a command that is not bound by the incremental search exits the search before executing the command. Thus, the command operates on the buffer from which you invoked the search. However, if you customize the variable search-exit-option to nil, the characters which you type that are not interpreted by the incremental search are simply appended to the search string. This is so you could include in the search string control characters, such as C-a, that would normally exit the search and invoke the command bound to them on the buffer.

Prefix Arguments
In incremental search, when you type a command that specifies a prefix argument (see Arguments), by default it will apply either to the next action in the search or to the command that exits the search. In other words, entering a prefix argument will not by itself terminate the search.

In previous versions of Emacs, entering a prefix argument always terminated the search. You can revert to this behavior by setting the variable isearch-allow-prefix to nil.

When isearch-allow-scroll is non-nil (see below), prefix arguments always have the default behavior described above, i.e., they don't terminate the search, even if isearch-allow-prefix is nil.

Scrolling Commands
Normally, scrolling commands exit incremental search. If you change the variable isearch-allow-scroll to a non-nil value, that enables the use of the scroll-bar, as well as keyboard scrolling commands like C-v, M-v, and C-l (see Scrolling). This applies only to calling these commands via their bound key sequences—typing M-x will still exit the search. You can give prefix arguments to these commands in the usual way. This feature won't let you scroll the current match out of visibility, however.

The isearch-allow-scroll feature also affects some other commands, such as C-x 2 (split-window-below) and C-x ^ (enlarge-window), which don't exactly scroll but do affect where the text appears on the screen. It applies to any command whose name has a non-nil isearch-scroll property. So you can control which commands are affected by changing these properties.

For example, to make C-h l usable within an incremental search in all future Emacs sessions, use C-h c to find what command it runs (see Key Help), which is view-lossage. Then you can put the following line in your init file (see Init File):

          (put 'view-lossage 'isearch-scroll t)

This feature can be applied to any command that doesn't permanently change point, the buffer contents, the match data, the current buffer, or the selected window and frame. The command must not itself attempt an incremental search. This feature is disabled if isearch-allow-scroll is nil (which it is by default).