]> code.delx.au - gnu-emacs/blobdiff - man/search.texi
Fix typo in date
[gnu-emacs] / man / search.texi
index 5fa130a2e50e531e2efd00ef9bea7d7ba2a584c2..1e4d9ea53c6108a333b2d6099dd02c80e32ed275 100644 (file)
@@ -1,5 +1,5 @@
 @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
@@ -193,9 +193,11 @@ repeat the search will then search for a string including that
 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
@@ -215,10 +217,10 @@ string.  It uses the same text that @kbd{C-y} as a command would yank.
 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
@@ -230,11 +232,11 @@ other matches helps indicate which match is the current one.
 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,
@@ -434,7 +436,7 @@ Search}.
   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
@@ -742,10 +744,11 @@ determines which characters these are.  @xref{Syntax}.
 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{\_>}
@@ -778,13 +781,13 @@ matches any character that does @emph{not} belong to category
   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]*"
@@ -921,7 +924,8 @@ The buffer contents.
 @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
@@ -930,7 +934,7 @@ window's size, or create or delete other windows and frames.
 
 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
@@ -1038,20 +1042,21 @@ text to replace with, you must enter @samp{\\}.
   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:
@@ -1061,9 +1066,9 @@ M-x replace-regexp @key{RET} \(x\)\|y @key{RET}
 \,(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
 
@@ -1074,16 +1079,16 @@ M-x replace-regexp @key{RET} ^.\@{0,72\@}$ @key{RET}
 
   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{\#}.
@@ -1149,6 +1154,14 @@ word-delimiter characters.
 @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:
@@ -1284,6 +1297,9 @@ searched and moves point to the original of the chosen occurrence.
 @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}.