Not Exiting Incremental Search
This subsection describes how to control whether typing a command not specifically meaningful in searches exits the search before executing the command. It also describes three 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 append, 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 (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-prefixtonil. Whenisearch-allow-scrollis non-nil(see below), prefix arguments always have the default behavior described above, i.e., they don't terminate the search, even ifisearch-allow-prefixisnil. - Scrolling Commands
- Normally, scrolling commands exit incremental search. But if you change the variable
isearch-allow-scrollto a non-nilvalue, that enables the use of the scroll-bar, as well as keyboard scrolling commands likeC-v,M-v, andC-l(Scrolling), which have a non-nilscroll-commandproperty, without exiting the search. This applies only to calling these commands via their bound key sequences—typingM-xwill still exit the search. You can give prefix arguments to these commands in the usual way. This feature normally won't let you scroll the current match out of visibility; but if you customizeisearch-allow-scrollto the special valueunlimited, that restriction is lifted. Theisearch-allow-scrollfeature also affects some other commands, such asC-x 2(split-window-below) andC-x ^(enlarge-window), which don't exactly scroll but do affect where the text appears on the screen. In fact, it affects any command that has a non-nilisearch-scrollproperty. So you can control which commands are affected by changing these properties. For example, to makeC-h lusable within an incremental search in all future Emacs sessions, useC-h cto find what command it runs (Key Help), which isview-lossage. Then you can put the following line in your init file (Init File): @example (put 'view-lossage 'isearch-scroll t) @end example 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 ifisearch-allow-scrollisnil(which it is by default). Likewise, if you change the variableisearch-allow-motionto a non-nilvalue, this enables the use of the keyboard motion commandsM-<,M->,C-vandM-v, to move respectively to the first occurrence of the current search string in the buffer, the last one, the first one after the current window, and the last one before the current window. The search direction does not change when these motion commands are used, unless you change the variableisearch-motion-changes-directionto a non-nilvalue, in which case the search direction is forward afterM-<andC-v, and backward afterM->andM-v. - Motion Commands
- When
isearch-yank-on-moveis customized toshift, you can extend the search string by holding down the shift key while typing cursor motion commands. It will yank text that ends at the new position after moving point in the current buffer. Whenisearch-yank-on-moveist, you can extend the search string without using the shift key for cursor motion commands, but it applies only for certain motion command that have theisearch-moveproperty on their symbols.