@c This is part of the Emacs manual.
-@c Copyright (C) 1985, 86, 87, 93, 94, 95, 97, 2000, 2001
+@c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001, 2004
@c Free Software Foundation, Inc.
@c See file emacs.texi for copying conditions.
@node Search, Fixit, Display, Top
character or word.
@kbd{C-y} is similar to @kbd{C-w} but copies all the rest of the
-current line into the search string. Both @kbd{C-y} and @kbd{C-w}
-convert the text they copy to lower case if the search is currently
-not case-sensitive; this is so the search remains case-insensitive.
+current line into the search string. If point is already at the end
+of a line, it grabs the entire next line. Both @kbd{C-y} and
+@kbd{C-w} convert the text they copy to lower case if the search is
+currently not case-sensitive; this is so the search remains
+case-insensitive.
@kbd{C-M-w} and @kbd{C-M-y} modify the search string by only one
character at a time: @kbd{C-M-w} deletes the last character from the
there. In Transient Mark mode, incremental search sets the mark without
activating it, and does so only if the mark is not already active.
- @kbd{M-%} or @kbd{C-M-%} exits the incremental search and starts an
-interactive command @code{query-replace} or @code{query-replace-regexp}
-with the last search string inserted in the minibuffer as initial input
-for the string to replace.
+ @kbd{M-%} typed in incremental search invokes @code{query-replace}
+or @code{query-replace-regexp} (depending on search mode) with the
+current search string used as the string to replace. @xref{Query
+Replace}.
@cindex lazy search highlighting
@vindex isearch-lazy-highlight
If you don't like this feature, you can turn it off by setting
@code{isearch-lazy-highlight} to @code{nil}.
-@vindex isearch-lazy-highlight-face
@cindex faces for highlighting search matches
You can control how this highlighting looks by customizing the faces
-@code{isearch} (used for the current match) and
-@code{isearch-lazy-highlight-face} (for all the other matches).
+@code{isearch} (used for the current match) and @code{lazy-highlight}
+(for all the other matches). The latter is also used for other matches
+inside @code{query-replace}.
@vindex isearch-mode-map
To customize the special characters that incremental search understands,
This manual describes regular expression features that users
typically want to use. There are additional features that are
mainly used in Lisp programs; see @ref{Regular Expressions,,,
-elisp, the same manual}.
+elisp, The Emacs Lisp Reference Manual}.
Regular expressions have a syntax in which a few characters are
special constructs and the rest are @dfn{ordinary}. An ordinary
matches any character that is not a word-constituent.
@item \_<
-matches the empty string, but only at the beginning of a symbol. A
-symbol is a sequence of one or more word or symbol constituent
-characters. @samp{\_<} matches at the beginning of the buffer only if
-a symbol-constituent character follows.
+matches the empty string, but only at the beginning of a symbol.
+A symbol is a sequence of one or more symbol-constituent characters.
+A symbol-constituent character is a character whose syntax is either
+@samp{w} or @samp{_}. @samp{\_<} matches at the beginning of the
+buffer only if a symbol-constituent character follows.
@item \_>
matches the empty string, but only at the end of a symbol. @samp{\_>}
The constructs that pertain to words and syntax are controlled by the
setting of the syntax table (@pxref{Syntax}).
- Here is a complicated regexp, stored in @code{sentence-end} and used
-by Emacs to recognize the end of a sentence together with any
-whitespace that follows. We show its Lisp syntax to distinguish the
-spaces from the tab characters. In Lisp syntax, the string constant
-begins and ends with a double-quote. @samp{\"} stands for a
-double-quote as part of the regexp, @samp{\\} for a backslash as part
-of the regexp, @samp{\t} for a tab, and @samp{\n} for a newline.
+ Here is a complicated regexp. It is a simplified version of the
+regexp that Emacs uses, by default, to recognize the end of a sentence
+together with any whitespace that follows. We show its Lisp syntax to
+distinguish the spaces from the tab characters. In Lisp syntax, the
+string constant begins and ends with a double-quote. @samp{\"} stands
+for a double-quote as part of the regexp, @samp{\\} for a backslash as
+part of the regexp, @samp{\t} for a tab, and @samp{\n} for a newline.
@example
"[.?!][]\"')]*\\($\\| $\\|\t\\| \\)[ \t\n]*"
@item
The selected window and selected frame.
@item
-The current match-data @xref{Match Data,,,elisp}.
+The current match-data. @xref{Match Data,,, elisp, The Emacs Lisp
+Reference Manual}.
@end enumerate
Additionally, the command must not delete the current window and must
Note that an attempt by a command to scroll the text
@emph{horizontally} won't work, although it will do no harm---any such
-scrolling will be overriden and nullified by the display code.
+scrolling will be overridden and nullified by the display code.
@node Replace, Other Repeating Search, Configuring Scrolling, Search
@section Replacement Commands
You can also use Lisp expressions to calculate parts of the
replacement string. To do this, write @samp{\,} followed by the
expression in the replacement string. Each replacement calculates the
-value of the expression, which ought to be a string, and uses it in
+value of the expression and converts it to text without quoting (if
+it's a string, this means using the string's contents), and uses it in
the replacement string in place of the expression itself. If the
expression is a symbol, one space in the replacement string after the
-symbol name counts as part of the symbol name, so the value replaces
-them both.
-
- Inside such an expression, @samp{\&} and @samp{\@var{n}} used as
-subexpressions refer respectively to the entire match as a string, and
-to a submatch as a string. @var{n} may exceed 9 here, and the value
-of @samp{\@var{n}} is @code{nil} if subexpression @var{n} did not
-match. You can also use @samp{\#&} and @samp{\#@var{n}} refer to
-those matches converted to numbers (this is valid when the match or
-submatch has the form of a number). @samp{\#} stands for the number
-of already-completed replacements.
+symbol name goes with the symbol name, so the value replaces them
+both.
+
+ Inside such an expression, you can use some special sequences.
+@samp{\&} and @samp{\@var{n}} refer here, as usual, to the entire
+match as a string, and to a submatch as a string. @var{n} may be
+multiple digits, and the value of @samp{\@var{n}} is @code{nil} if
+subexpression @var{n} did not match. You can also use @samp{\#&} and
+@samp{\#@var{n}} to refer to those matches as numbers (this is valid
+when the match or submatch has the form of a numeral). @samp{\#} here
+too stands for the number of already-completed replacements.
Repeating our example to exchange @samp{x} and @samp{y}, we can thus
do it also this way:
\,(if \1 "y" "x") @key{RET}
@end example
- The @code{format} function (@pxref{Formatting Strings,,,elisp, GNU
-Emacs Lisp Reference Manual}) comes in handy for computing replacement
-strings for @samp{\,}. For example, to add consecutively numbered
+ For computing replacement strings for @samp{\,}, the @code{format}
+function is often useful (@pxref{Formatting Strings,,, elisp, The Emacs
+Lisp Reference Manual}). For example, to add consecutively numbered
strings like @samp{ABC00042} to columns 73 @w{to 80} (unless they are
already occupied), you can use
If you want to enter part of the replacement string by hand each
time, use @samp{\?} in the replacement string. Each replacement will
-enter a recursive edit, with point at the position where the @samp{\?}
-was. For example,
+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}
+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 occurences of
+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{\#}.
@kindex C-M-%
@findex query-replace-regexp
@kbd{C-M-%} performs regexp search and replace (@code{query-replace-regexp}).
+It works like @code{replace-regexp} except that it queries
+like @code{query-replace}.
+
+@cindex faces for highlighting query replace
+ These commands highlight the current match using the face
+@code{query-replace}. They highlight other matches using
+@code{lazy-highlight} just like incremental search (@pxref{Incremental
+Search}).
The characters you can type when you are shown a match for the string
or regexp are:
@kbd{o} and @kbd{C-o} display the match in another window; @kbd{C-o}
does not select it.
+Occur mode supports the @code{next-error} functionality described in
+in @ref{Compilation Mode}.
+
@item M-x list-matching-lines
Synonym for @kbd{M-x occur}.