294 |
@kbd{@key{NEXT}} (@code{scroll-up}) and @kbd{C-l} (@code{recenter}) |
@kbd{@key{NEXT}} (@code{scroll-up}) and @kbd{C-l} (@code{recenter}) |
295 |
within the search, thus letting you see more of the text near the |
within the search, thus letting you see more of the text near the |
296 |
current match. You must run these commands via their key sequences to |
current match. You must run these commands via their key sequences to |
297 |
stay in the search---typing M-x @var{comand-name} will always |
stay in the search---typing M-x @var{command-name} will always |
298 |
terminate a search. |
terminate a search. |
299 |
|
|
300 |
You can give prefix arguments to these commands in the usual way. |
You can give prefix arguments to these commands in the usual way. |
309 |
|
|
310 |
You can make other commands usable within an incremental search by |
You can make other commands usable within an incremental search by |
311 |
giving the command a non-@code{nil} @code{isearch-scroll} property. |
giving the command a non-@code{nil} @code{isearch-scroll} property. |
312 |
|
For example, to make @kbd{C-h l} usable within an incremental search |
313 |
|
in all future Emacs sessions, use @kbd{C-h c} to find what command it |
314 |
|
runs. (You type @kbd{C-h c C-h l}; it says @code{view-lossage}.) Then |
315 |
|
you can put the following line in your @file{.emacs} file (@pxref{Init File}): |
316 |
|
|
317 |
|
@example |
318 |
|
(put 'view-lossage 'isearch-scroll t) |
319 |
|
@end example |
320 |
|
|
321 |
|
@noindent |
322 |
This works for commands that don't permanently change point, the |
This works for commands that don't permanently change point, the |
323 |
buffer contents, the match data, the current buffer, or the selected |
buffer contents, the match data, the current buffer, or the selected |
324 |
window and frame. The command must not delete the current window and |
window and frame. The command must not delete the current window and |
341 |
@vindex search-slow-speed |
@vindex search-slow-speed |
342 |
The slow terminal style of display is used when the terminal baud rate is |
The slow terminal style of display is used when the terminal baud rate is |
343 |
less than or equal to the value of the variable @code{search-slow-speed}, |
less than or equal to the value of the variable @code{search-slow-speed}, |
344 |
initially 1200. See @code{baud-rate} in @ref{Display Custom}. |
initially 1200. See also the discussion of the variable @code{baud-rate} |
345 |
|
(@pxref{baud-rate,, Customization of Display}). |
346 |
|
|
347 |
@vindex search-slow-window-lines |
@vindex search-slow-window-lines |
348 |
The number of lines to use in slow terminal search display is controlled |
The number of lines to use in slow terminal search display is controlled |
1023 |
performs the inverse transformation. To include a @samp{\} in the |
performs the inverse transformation. To include a @samp{\} in the |
1024 |
text to replace with, you must enter @samp{\\}. |
text to replace with, you must enter @samp{\\}. |
1025 |
|
|
1026 |
You can also use Lisp expressions to calculate parts of the |
If you want to enter part of the replacement string by hand each |
1027 |
|
time, use @samp{\?} in the replacement string. Each replacement will |
1028 |
|
ask you to edit the replacement string in the minibuffer, putting |
1029 |
|
point where the @samp{\?} was. |
1030 |
|
|
1031 |
|
The remainder of this subsection is intended for specialized tasks |
1032 |
|
and requires knowledge of Lisp. Most readers can skip it. |
1033 |
|
|
1034 |
|
You can use Lisp expressions to calculate parts of the |
1035 |
replacement string. To do this, write @samp{\,} followed by the |
replacement string. To do this, write @samp{\,} followed by the |
1036 |
expression in the replacement string. Each replacement calculates the |
expression in the replacement string. Each replacement calculates the |
1037 |
value of the expression and converts it to text without quoting (if |
value of the expression and converts it to text without quoting (if |
1069 |
\,(format "%-72sABC%05d" \& \#) @key{RET} |
\,(format "%-72sABC%05d" \& \#) @key{RET} |
1070 |
@end example |
@end example |
1071 |
|
|
|
If you want to enter part of the replacement string by hand each |
|
|
time, use @samp{\?} in the replacement string. Each replacement will |
|
|
ask you to edit the replacement string in the minibuffer, putting |
|
|
point where the @samp{\?} was. For example, |
|
|
|
|
|
@example |
|
|
M-x replace-regexp @key{RET} \\footnote@{ @key{RET} |
|
|
\&\\label@{fn:\#\?@} @key{RET} |
|
|
@end example |
|
|
|
|
|
@noindent |
|
|
will add labels starting with @samp{\label@{fn:0@}} to occurrences of |
|
|
@samp{\footnote@{}, but letting you edit each replacement before |
|
|
performing it. To number the labels starting at 1, use @samp{\,(1+ |
|
|
\#)} instead of @samp{\#}. |
|
|
|
|
1072 |
@node Replacement and Case, Query Replace, Regexp Replace, Replace |
@node Replacement and Case, Query Replace, Regexp Replace, Replace |
1073 |
@subsection Replace Commands and Case |
@subsection Replace Commands and Case |
1074 |
|
|
1260 |
for @var{regexp}. To limit the search to part of the buffer, narrow |
for @var{regexp}. To limit the search to part of the buffer, narrow |
1261 |
to that part (@pxref{Narrowing}). A numeric argument @var{n} |
to that part (@pxref{Narrowing}). A numeric argument @var{n} |
1262 |
specifies that @var{n} lines of context are to be displayed before and |
specifies that @var{n} lines of context are to be displayed before and |
1263 |
after each matching line. |
after each matching line. Currently, @code{occur} can not correctly |
1264 |
|
handle multiline matches. |
1265 |
|
|
1266 |
@kindex RET @r{(Occur mode)} |
@kindex RET @r{(Occur mode)} |
1267 |
@kindex o @r{(Occur mode)} |
@kindex o @r{(Occur mode)} |
1275 |
does not select it. |
does not select it. |
1276 |
|
|
1277 |
Occur mode supports the @code{next-error} functionality described in |
Occur mode supports the @code{next-error} functionality described in |
1278 |
in @ref{Compilation Mode}. |
@ref{Compilation Mode}. |
1279 |
|
|
1280 |
@item M-x list-matching-lines |
@item M-x list-matching-lines |
1281 |
Synonym for @kbd{M-x occur}. |
Synonym for @kbd{M-x occur}. |
1294 |
command operates on the region instead. |
command operates on the region instead. |
1295 |
|
|
1296 |
@item M-x flush-lines @key{RET} @var{regexp} @key{RET} |
@item M-x flush-lines @key{RET} @var{regexp} @key{RET} |
1297 |
Delete each line that contains a match for @var{regexp}, operating on |
This command deletes each line that contains a match for @var{regexp}, |
1298 |
the text after point. In Transient Mark mode, if the region is |
operating on the text after point; it deletes the current line |
1299 |
active, the command operates on the region instead. |
if it contains a match starting after point. In Transient Mark mode, |
1300 |
|
if the region is active, the command operates on the region instead; |
1301 |
|
it deletes a line partially contained in the region if it contains a |
1302 |
|
match entirely contained in the region. |
1303 |
|
|
1304 |
|
If a match is split across lines, @code{flush-lines} deletes all those |
1305 |
|
lines. It deletes the lines before starting to look for the next |
1306 |
|
match; hence, it ignores a match starting on the same line at which |
1307 |
|
another match ended. |
1308 |
|
|
1309 |
@item M-x keep-lines @key{RET} @var{regexp} @key{RET} |
@item M-x keep-lines @key{RET} @var{regexp} @key{RET} |
1310 |
Delete each line that @emph{does not} contain a match for |
This command deletes each line that @emph{does not} contain a match for |
1311 |
@var{regexp}, operating on the text after point. In Transient Mark |
@var{regexp}, operating on the text after point; if point is not at the |
1312 |
mode, if the region is active, the command operates on the region |
beginning of a line, it always keeps the current line. In Transient |
1313 |
instead. |
Mark mode, if the region is active, the command operates on the region |
1314 |
|
instead; it never deletes lines that are only partially contained in |
1315 |
|
the region (a newline that ends a line counts as part of that line). |
1316 |
|
|
1317 |
|
If a match is split across lines, this command keeps all those lines. |
1318 |
@end table |
@end table |
1319 |
|
|
1320 |
You can also search multiple files under control of a tags table |
You can also search multiple files under control of a tags table |
1321 |
(@pxref{Tags Search}) or through Dired @kbd{A} command |
(@pxref{Tags Search}) or through the Dired @kbd{A} command |
1322 |
(@pxref{Operating on Files}), or ask the @code{grep} program to do it |
(@pxref{Operating on Files}), or ask the @code{grep} program to do it |
1323 |
(@pxref{Grep Searching}). |
(@pxref{Grep Searching}). |
1324 |
|
|