(org-export-with-timestamps)
[bpt/emacs.git] / man / search.texi
index dc6c16d..67b61ae 100644 (file)
@@ -16,7 +16,14 @@ those of other editors.
   Besides the usual @code{replace-string} command that finds all
 occurrences of one string and replaces them with another, Emacs has a
 more flexible replacement command called @code{query-replace}, which
-asks interactively which occurrences to replace.
+asks interactively which occurrences to replace.  There are also
+commands to find and operate on all matches for a pattern.
+
+  You can also search multiple files under control of a tags
+table (@pxref{Tags Search}) or through the Dired @kbd{A} command
+(@pxref{Operating on Files}), or ask the @code{grep} program to do it
+(@pxref{Grep Searching}).
+
 
 @menu
 * Incremental Search::         Search happens as you type the string.
@@ -33,6 +40,8 @@ asks interactively which occurrences to replace.
 
 @node Incremental Search
 @section Incremental Search
+@cindex incremental search
+@cindex isearch
 
   An incremental search begins searching as soon as you type the first
 character of the search string.  As you type in the search string, Emacs
@@ -63,7 +72,6 @@ Incremental search backward (@code{isearch-backward}).
 
 @node Basic Isearch
 @subsection Basics of Incremental Search
-@cindex incremental search
 
 @kindex C-s
 @findex isearch-forward
@@ -208,15 +216,15 @@ of bindings, look at the documentation of @code{isearch-mode} with
 
 @node Non-ASCII Isearch
 @subsection Isearch for Non-@acronym{ASCII} Characters
-
 @cindex searching for non-@acronym{ASCII} characters
 @cindex input method, during incremental search
 
   To enter non-@acronym{ASCII} characters in an incremental search,
-you must use an input method (@pxref{Input Methods}).  If an input
-method is enabled in the current buffer when you start the search, you
-can use it while you type the search string also.  Emacs indicates
-that by including the input method mnemonic in its prompt, like this:
+you can use @kbd{C-q} (see the previous section), but it is easier to
+use an input method (@pxref{Input Methods}).  If an input method is
+enabled in the current buffer when you start the search, you can use
+it in the search string also.  Emacs indicates that by including the
+input method mnemonic in its prompt, like this:
 
 @example
 I-search [@var{im}]:
@@ -225,10 +233,11 @@ I-search [@var{im}]:
 @noindent
 @findex isearch-toggle-input-method
 @findex isearch-toggle-specified-input-method
-where @var{im} is the mnemonic of the active input method.  You can
-toggle (enable or disable) the input method while you type the search
-string with @kbd{C-\} (@code{isearch-toggle-input-method}).  You can
-turn on a certain (non-default) input method with @kbd{C-^}
+where @var{im} is the mnemonic of the active input method.
+
+  You can toggle (enable or disable) the input method while you type
+the search string with @kbd{C-\} (@code{isearch-toggle-input-method}).
+You can turn on a certain (non-default) input method with @kbd{C-^}
 (@code{isearch-toggle-specified-input-method}), which prompts for the
 name of the input method.  The input method you enable during
 incremental search remains enabled in the current buffer afterwards.
@@ -372,9 +381,9 @@ specify is empty.  (Such an empty argument would otherwise be
 useless.)  But it does not call @code{search-forward} right away.  First
 it checks the next input character to see if is @kbd{C-w},
 which specifies a word search.
-@ifinfo
+@ifnottex
 @xref{Word Search}.
-@end ifinfo
+@end ifnottex
 @kbd{C-r @key{RET}} does likewise, for a reverse incremental search.
 
 @findex search-forward
@@ -408,7 +417,7 @@ Search for @var{words}, ignoring details of punctuation.
 Search backward for @var{words}, ignoring details of punctuation.
 @end table
 
-  Word search is a special case of nonincremental search and is invoked
+  Word search as a special case of nonincremental search is invoked
 with @kbd{C-s @key{RET} C-w}.  This is followed by the search string,
 which must always be terminated with @key{RET}.  Being nonincremental,
 this search does not start until the argument is terminated.  It works
@@ -417,6 +426,13 @@ by constructing a regular expression and searching for that; see
 
   Use @kbd{C-r @key{RET} C-w} to do backward word search.
 
+  You can also invoke word search with @kbd{C-s M-e C-w} or @kbd{C-r
+M-e C-w} followed by the search string and terminated with @key{RET},
+@kbd{C-s} or @kbd{C-r}.  This puts word search into incremental mode
+where you can use all keys available for incremental search.  However,
+when you type more words in incremental word search, it will fail
+until you type complete words.
+
 @findex word-search-forward
 @findex word-search-backward
   Forward and backward word searches are implemented by the commands
@@ -498,11 +514,13 @@ elisp, The Emacs Lisp Reference Manual}.
 special constructs and the rest are @dfn{ordinary}.  An ordinary
 character is a simple regular expression which matches that same
 character and nothing else.  The special characters are @samp{$},
-@samp{^}, @samp{.}, @samp{*}, @samp{+}, @samp{?}, @samp{[}, @samp{]} and
-@samp{\}.  Any other character appearing in a regular expression is
-ordinary, unless a @samp{\} precedes it.  (When you use regular
-expressions in a Lisp program, each @samp{\} must be doubled, see the
-example near the end of this section.)
+@samp{^}, @samp{.}, @samp{*}, @samp{+}, @samp{?}, @samp{[}, and
+@samp{\}.  The character @samp{]} is special if it ends a character
+alternative (see later).  The character @samp{-} is special inside a
+character alternative.  Any other character appearing in a regular
+expression is ordinary, unless a @samp{\} precedes it.  (When you use
+regular expressions in a Lisp program, each @samp{\} must be doubled,
+see the example near the end of this section.)
 
   For example, @samp{f} is not a special character, so it is ordinary, and
 therefore @samp{f} is a regular expression that matches the string
@@ -682,6 +700,14 @@ no preceding expression on which the @samp{*} can act.  It is poor practice
 to depend on this behavior; it is better to quote the special character anyway,
 regardless of where it appears.
 
+As a @samp{\} is not special inside a character alternative, it can
+never remove the special meaning of @samp{-} or @samp{]}.  So you
+should not quote these characters when they have no special meaning
+either.  This would not clarify anything, since backslashes can
+legitimately precede these characters where they @emph{have} special
+meaning, as in @samp{[^\]} (@code{"[^\\]"} for Lisp string syntax),
+which matches any single character except a backslash.
+
 @node Regexp Backslash
 @section Backslash in Regular Expressions
 
@@ -737,11 +763,13 @@ specifies a ``shy'' group that does not record the matched substring;
 you can't refer back to it with @samp{\@var{d}}.  This is useful
 in mechanically combining regular expressions, so that you
 can add groups for syntactic purposes without interfering with
-the numbering of the groups that were written by the user.
+the numbering of the groups that are meant to be referred to.
 
 @item \@var{d}
+@cindex back reference, in regexp
 matches the same text that matched the @var{d}th occurrence of a
-@samp{\( @dots{} \)} construct.
+@samp{\( @dots{} \)} construct.  This is called a @dfn{back
+reference}.
 
 After the end of a @samp{\( @dots{} \)} construct, the matcher remembers
 the beginning and end of the text matched by that construct.  Then,
@@ -992,15 +1020,17 @@ any match for a specified pattern.
 Replace every match for @var{regexp} with @var{newstring}.
 @end table
 
+@cindex back reference, in regexp replacement
   In @code{replace-regexp}, the @var{newstring} need not be constant:
 it can refer to all or part of what is matched by the @var{regexp}.
 @samp{\&} in @var{newstring} stands for the entire match being
 replaced.  @samp{\@var{d}} in @var{newstring}, where @var{d} is a
 digit, stands for whatever matched the @var{d}th parenthesized
-grouping in @var{regexp}.  @samp{\#} refers to the count of
-replacements already made in this command, as a decimal number.  In
-the first replacement, @samp{\#} stands for @samp{0}; in the second,
-for @samp{1}; and so on.  For example,
+grouping in @var{regexp}.  (This is called a ``back reference.'')
+@samp{\#} refers to the count of replacements already made in this
+command, as a decimal number.  In the first replacement, @samp{\#}
+stands for @samp{0}; in the second, for @samp{1}; and so on.  For
+example,
 
 @example
 M-x replace-regexp @key{RET} c[ad]+r @key{RET} \&-safe @key{RET}
@@ -1226,8 +1256,10 @@ line.
 used the minibuffer to read its arguments.  @xref{Repetition, C-x ESC
 ESC}.
 
-  See also @ref{Transforming File Names}, for Dired commands to rename,
-copy, or link files by replacing regexp matches in file names.
+  @xref{Operating on Files}, for the Dired @kbd{Q} command which
+performs query replace on selected files.  See also @ref{Transforming
+File Names}, for Dired commands to rename, copy, or link files by
+replacing regexp matches in file names.
 
 @node Other Repeating Search
 @section Other Search-and-Loop Commands
@@ -1282,7 +1314,7 @@ through multiple buffers.  It asks you to specify the buffer names one by one.
 @item M-x multi-occur-in-matching-buffers @key{RET} @var{bufregexp} @key{RET} @var{regexp} @key{RET}
 This function is similar to @code{multi-occur}, except the buffers to
 search are specified by a regular expression that matches visited
-filenames.  With a prefix argument, it uses the regular expression to match
+file names.  With a prefix argument, it uses the regular expression to match
 buffer names instead.
 
 @item M-x how-many @key{RET} @var{regexp} @key{RET}
@@ -1314,11 +1346,6 @@ the region (a newline that ends a line counts as part of that line).
 If a match is split across lines, this command keeps all those lines.
 @end table
 
-  You can also search multiple files under control of a tags table
-(@pxref{Tags Search}) or through the Dired @kbd{A} command
-(@pxref{Operating on Files}), or ask the @code{grep} program to do it
-(@pxref{Grep Searching}).
-
 @ignore
    arch-tag: fd9d8e77-66af-491c-b212-d80999613e3e
 @end ignore