]> code.delx.au - gnu-emacs/blobdiff - man/search.texi
Do not assume DST starts/ends on the same date in every year.
[gnu-emacs] / man / search.texi
index a947d4ecfb4f63134a8f2a7b7efea708920661ca..67b61aeac072123788f35d9cb40ea5714139d9f5 100644 (file)
@@ -1,6 +1,6 @@
 @c This is part of the Emacs manual.
-@c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001, 2004
-@c   Free Software Foundation, Inc.
+@c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001, 2002,
+@c   2003, 2004, 2005, 2006 Free Software Foundation, Inc.
 @c See file emacs.texi for copying conditions.
 @node Search, Fixit, Display, Top
 @chapter Searching and Replacement
@@ -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.
@@ -24,6 +31,8 @@ asks interactively which occurrences to replace.
 * Word Search::                        Search for sequence of words.
 * Regexp Search::              Search for match for a regexp.
 * Regexps::                    Syntax of regular expressions.
+* Regexp Backslash::            Regular expression constructs starting with `\'.
+* Regexp Example::              A complex regular expression explained.
 * Search Case::                        To ignore case while searching, or not.
 * Replace::                    Search, and replace some or all matches.
 * Other Repeating Search::     Operating on all matches for some regexp.
@@ -31,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
@@ -39,7 +50,6 @@ found.  When you have typed enough characters to identify the place you
 want, you can stop.  Depending on what you plan to do next, you may or
 may not need to terminate the search explicitly with @key{RET}.
 
-@c WideCommands
 @table @kbd
 @item C-s
 Incremental search forward (@code{isearch-forward}).
@@ -62,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
@@ -71,9 +80,9 @@ from the keyboard, and moves point past the next occurrence of those
 characters.  If you type @kbd{C-s} and then @kbd{F}, that puts the
 cursor after the first @samp{F} (the first following the starting point, since
 this is a forward search).  Then if you type an @kbd{O}, you will see
-the cursor move just after the first @samp{FO} (the @samp{F} in that
+the cursor move to just after the first @samp{FO} (the @samp{F} in that
 @samp{FO} may or may not be the first @samp{F}).  After another
-@kbd{O}, the cursor moves after the first @samp{FOO} after the place
+@kbd{O}, the cursor moves to just after the first @samp{FOO} after the place
 where you started the search.  At each step, the buffer text that
 matches the search string is highlighted, if the terminal can do that;
 the current search string is always displayed in the echo area.
@@ -133,19 +142,20 @@ string in the minibuffer without replacing it with items from the
 search ring, type @kbd{M-e}.  Type @kbd{C-s} or @kbd{C-r}
 to terminate editing the string and search for it.
 
-  You can change to searching backwards with @kbd{C-r}.  If a search fails
-because the place you started was too late in the file, you should do this.
-Repeated @kbd{C-r} keeps looking for more occurrences backwards.  A
-@kbd{C-s} starts going forwards again.  @kbd{C-r} in a search can be canceled
+  You can change to searching backwards with @kbd{C-r}.  For instance,
+if you are searching forward but you realize you were looking for
+something above the starting point, you can do this.  Repeated
+@kbd{C-r} keeps looking for more occurrences backwards.  A @kbd{C-s}
+starts going forwards again.  @kbd{C-r} in a search can be canceled
 with @key{DEL}.
 
 @kindex C-r
 @findex isearch-backward
   If you know initially that you want to search backwards, you can use
-@kbd{C-r} instead of @kbd{C-s} to start the search, because @kbd{C-r} as
-a key runs a command (@code{isearch-backward}) to search backward.  A
-backward search finds matches that are entirely before the starting
-point, just as a forward search finds matches that begin after it.
+@kbd{C-r} instead of @kbd{C-s} to start the search, because @kbd{C-r}
+as a key runs a command (@code{isearch-backward}) to search backward.
+A backward search finds matches that end before the starting point,
+just as a forward search finds matches that begin after it.
 
 @node Error in Isearch
 @subsection Errors in Incremental Search
@@ -204,17 +214,17 @@ alter their bindings in the keymap @code{isearch-mode-map}.  For a list
 of bindings, look at the documentation of @code{isearch-mode} with
 @kbd{C-h f isearch-mode @key{RET}}.
 
-@node Non-Ascii Isearch
+@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 incrementral 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:
+  To enter non-@acronym{ASCII} characters in an incremental search,
+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}]:
@@ -223,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.
@@ -279,40 +290,46 @@ If you don't like this feature, you can turn it off by setting
 @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{lazy-highlight}
-(for all the other matches).  The latter is also used for other matches
-inside @code{query-replace}.
+(for all the other matches).
 
 @node Isearch Scroll
 @subsection Scrolling During Incremental Search
 
-  Vertical scrolling during incremental search can be enabled by
-setting the customizable variable @code{isearch-allow-scroll} to a
-non-@code{nil} value.
-
-  You can then use the vertical scroll-bar or certain keyboard
+  You can enable the use of vertical scrolling during incremental
+search (without exiting the search) by setting the customizable
+variable @code{isearch-allow-scroll} to a non-@code{nil} value.  This
+applies to using the vertical scroll-bar and to certain keyboard
 commands such as @kbd{@key{PRIOR}} (@code{scroll-down}),
-@kbd{@key{NEXT}} (@code{scroll-up}) and @kbd{C-l} (@code{recenter})
-within the search, thus letting you see more of the text near the
-current match.  You must run these commands via their key sequences to
-stay in the search---typing M-x @var{comand-name} will always
-terminate a search.
+@kbd{@key{NEXT}} (@code{scroll-up}) and @kbd{C-l} (@code{recenter}).
+You must run these commands via their key sequences to stay in the
+search---typing @kbd{M-x} will terminate the search.  You can give
+prefix arguments to these commands in the usual way.
 
-  You can give prefix arguments to these commands in the usual way.
-The current match cannot be scrolled out of the window---this is
-intentional.
+  This feature won't let you scroll the current match out of visibility,
+however.
 
-  Several other commands, such as @kbd{C-x 2}
+  The feature also affects some other commands, such as @kbd{C-x 2}
 (@code{split-window-vertically}) and @kbd{C-x ^}
-(@code{enlarge-window}) which don't scroll the window, are
-nevertheless made available under this rubric, since they are likewise
-handy during a search.
+(@code{enlarge-window}) which don't exactly scroll but do affect where
+the text appears on the screen.  In general, it applies to any command
+whose name has a non-@code{nil} @code{isearch-scroll} property.  So you
+can control which commands are affected by changing these properties.
 
-  You can make other commands usable within an incremental search by
-giving the command a non-@code{nil} @code{isearch-scroll} property.
-This works for commands that don't permanently change point, the
-buffer contents, the match data, the current buffer, or the selected
-window and frame.  The command must not delete the current window and
-must not itself attempt an incremental search.
+  For example, to make @kbd{C-h l} usable within an incremental search
+in all future Emacs sessions, use @kbd{C-h c} to find what command it
+runs.  (You type @kbd{C-h c C-h l}; it says @code{view-lossage}.)
+Then you can put the following line in your @file{.emacs} file
+(@pxref{Init File}):
+
+@example
+(put 'view-lossage 'isearch-scroll t)
+@end example
+
+@noindent
+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.
 
 @node Slow Isearch
 @subsection Slow Terminal Incremental Search
@@ -331,7 +348,8 @@ its new position of point.
 @vindex search-slow-speed
   The slow terminal style of display is used when the terminal baud rate is
 less than or equal to the value of the variable @code{search-slow-speed},
-initially 1200.  See @code{baud-rate} in @ref{Display Custom}.
+initially 1200.  See also the discussion of the variable @code{baud-rate}
+(@pxref{baud-rate,, Customization of Display}).
 
 @vindex search-slow-window-lines
   The number of lines to use in slow terminal search display is controlled
@@ -363,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
@@ -374,7 +392,7 @@ which specifies a word search.
 commands @code{search-forward} and @code{search-backward}.  These
 commands may be bound to keys in the usual manner.  The feature that you
 can get to them via the incremental search commands exists for
-historical reasons, and to avoid the need to find key sequences
+historical reasons, and to avoid the need to find separate key sequences
 for them.
 
 @node Word Search
@@ -399,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
@@ -408,13 +426,20 @@ 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
 @code{word-search-forward} and @code{word-search-backward}.  These
 commands may be bound to keys in the usual manner.  They are available
 via the incremental search commands both for historical reasons and
-to avoid the need to find suitable key sequences for them.
+to avoid the need to find separate key sequences for them.
 
 @node Regexp Search
 @section Regular Expression Search
@@ -451,11 +476,14 @@ say, incremental regexp and non-regexp searches have independent
 defaults.  They also have separate search rings that you can access with
 @kbd{M-p} and @kbd{M-n}.
 
+@vindex search-whitespace-regexp
   If you type @key{SPC} in incremental regexp search, it matches any
-sequence of whitespace characters, including newlines.  If you want
-to match just a space, type @kbd{C-q @key{SPC}}.
+sequence of whitespace characters, including newlines.  If you want to
+match just a space, type @kbd{C-q @key{SPC}}.  You can control what a
+bare space matches by setting the variable
+@code{search-whitespace-regexp} to the desired regexp.
 
-  Note that adding characters to the regexp in an incremental regexp
+  In some cases, adding characters to the regexp in an incremental regexp
 search can make the cursor move back and start again.  For example, if
 you have searched for @samp{foo} and you add @samp{\|bar}, the cursor
 backs up in case the first @samp{bar} precedes the first @samp{foo}.
@@ -486,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
@@ -658,20 +688,34 @@ has two functions: it quotes the special characters (including
 Because @samp{\} quotes special characters, @samp{\$} is a regular
 expression that matches only @samp{$}, and @samp{\[} is a regular
 expression that matches only @samp{[}, and so on.
+
+See the following section for the special constructs that begin
+with @samp{\}.
 @end table
 
-Note: for historical compatibility, special characters are treated as
+  Note: for historical compatibility, special characters are treated as
 ordinary ones if they are in contexts where their special meanings make no
 sense.  For example, @samp{*foo} treats @samp{*} as ordinary since there is
 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.@refill
+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
 
-For the most part, @samp{\} followed by any character matches only that
-character.  However, there are several exceptions: two-character
-sequences starting with @samp{\} that have special meanings.  The second
-character in the sequence is always an ordinary character when used on
-its own.  Here is a table of @samp{\} constructs.
+  For the most part, @samp{\} followed by any character matches only
+that character.  However, there are several exceptions: two-character
+sequences starting with @samp{\} that have special meanings.  The
+second character in the sequence is always an ordinary character when
+used on its own.  Here is a table of @samp{\} constructs.
 
 @table @kbd
 @item \|
@@ -719,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,
@@ -825,8 +871,11 @@ 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.  It is a simplified version of the
-regexp that Emacs uses, by default, to recognize the end of a sentence
+@node Regexp Example
+@section Regular Expression Example
+
+  Here is a complicated regexp---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
@@ -853,27 +902,6 @@ for Lisp syntax.  In commands that use ordinary minibuffer input to
 read a regexp, you would quote the @kbd{C-j} by preceding it with a
 @kbd{C-q} to prevent @kbd{C-j} from exiting the minibuffer.
 
-@ignore
-@c I commented this out because it is missing vital information
-@c and therefore useless.  For instance, what do you do to *use* the
-@c regular expression when it is finished?  What jobs is this good for?
-@c  -- rms
-
-@findex re-builder
-@cindex authoring regular expressions
-  For convenient interactive development of regular expressions, you
-can use the @kbd{M-x re-builder} command.  It provides a convenient
-interface for creating regular expressions, by giving immediate visual
-feedback.  The buffer from which @code{re-builder} was invoked becomes
-the target for the regexp editor, which pops in a separate window.  At
-all times, all the matches in the target buffer for the current
-regular expression are highlighted.  Each parenthesized sub-expression
-of the regexp is shown in a distinct face, which makes it easier to
-verify even very complex regexps.  (On displays that don't support
-colors, Emacs blinks the cursor around the matched text, as it does
-for matching parens.)
-@end ignore
-
 @node Search Case
 @section Searching and Case
 
@@ -906,6 +934,12 @@ searches also, including those performed by the replace commands
 (@pxref{Replace}) and the minibuffer history matching commands
 (@pxref{Minibuffer History}).
 
+  Several related variables control case-sensitivity of searching and
+matching for specific commands or activities.  For instance,
+@code{tags-case-fold-search} controls case sensitivity for
+@code{find-tag}.  To find these variables, do @kbd{M-x
+apropos-variable @key{RET} case-fold-search @key{RET}}.
+
 @node Replace
 @section Replacement Commands
 @cindex replacement
@@ -916,13 +950,13 @@ searches also, including those performed by the replace commands
   Global search-and-replace operations are not needed often in Emacs,
 but they are available.  In addition to the simple @kbd{M-x
 replace-string} command which replaces all occurrences,
-there is a @kbd{M-x query-replace} command which finds each occurrence
+there is @kbd{M-%} (@code{query-replace}), which presents each occurrence
 of the pattern and asks you whether to replace it.
 
   The replace commands normally operate on the text from point to the
 end of the buffer; however, in Transient Mark mode (@pxref{Transient
 Mark}), when the mark is active, they operate on the region.  The
-replace commands all replace one string (or regexp) with one
+basic replace commands replace one string (or regexp) with one
 replacement string.  It is possible to perform several replacements in
 parallel using the command @code{expand-region-abbrevs}
 (@pxref{Expanding Abbrevs}).
@@ -986,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}
@@ -1012,7 +1048,15 @@ M-x replace-regexp @key{RET} \(c[ad]+r\)-safe @key{RET} \1 @key{RET}
 performs the inverse transformation.  To include a @samp{\} in the
 text to replace with, you must enter @samp{\\}.
 
-  You can also use Lisp expressions to calculate parts of the
+  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.
+
+  The remainder of this subsection is intended for specialized tasks
+and requires knowledge of Lisp.  Most readers can skip it.
+
+  You can 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 and converts it to text without quoting (if
@@ -1050,22 +1094,6 @@ M-x replace-regexp @key{RET} ^.\@{0,72\@}$ @key{RET}
 \,(format "%-72sABC%05d" \& \#) @key{RET}
 @end example
 
-  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{\#}.
-
 @node Replacement and Case, Query Replace, Regexp Replace, Replace
 @subsection Replace Commands and Case
 
@@ -1228,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
@@ -1244,7 +1274,7 @@ Mark mode.
 @findex list-matching-lines
 @findex occur
 @findex multi-occur
-@findex multi-occur-by-filename-regexp
+@findex multi-occur-in-matching-buffers
 @findex how-many
 @findex delete-non-matching-lines
 @findex delete-matching-lines
@@ -1257,7 +1287,8 @@ Display a list showing each line in the buffer that contains a match
 for @var{regexp}.  To limit the search to part of the buffer, narrow
 to that part (@pxref{Narrowing}).  A numeric argument @var{n}
 specifies that @var{n} lines of context are to be displayed before and
-after each matching line.
+after each matching line.  Currently, @code{occur} can not correctly
+handle multiline matches.
 
 @kindex RET @r{(Occur mode)}
 @kindex o @r{(Occur mode)}
@@ -1270,19 +1301,21 @@ 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}.
+After using @kbd{M-x occur}, you can use @code{next-error} to visit
+the occurrences found, one by one.  @ref{Compilation Mode}.
 
 @item M-x list-matching-lines
 Synonym for @kbd{M-x occur}.
 
 @item M-x multi-occur @key{RET} @var{buffers} @key{RET} @var{regexp} @key{RET}
 This function is just like @code{occur}, except it is able to search
-through multiple buffers.
+through multiple buffers.  It asks you to specify the buffer names one by one.
 
-@item M-x multi-occur-by-filename-regexp @key{RET} @var{bufregexp} @key{RET} @var{regexp} @key{RET}
+@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 regexp on their filename.
+search are specified by a regular expression that matches visited
+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}
 Print the number of matches for @var{regexp} that exist in the buffer
@@ -1290,22 +1323,29 @@ after point.  In Transient Mark mode, if the region is active, the
 command operates on the region instead.
 
 @item M-x flush-lines @key{RET} @var{regexp} @key{RET}
-Delete each line that contains a match for @var{regexp}, operating on
-the text after point.  In Transient Mark mode, if the region is
-active, the command operates on the region instead.
+This command deletes each line that contains a match for @var{regexp},
+operating on the text after point; it deletes the current line
+if it contains a match starting after point.  In Transient Mark mode,
+if the region is active, the command operates on the region instead;
+it deletes a line partially contained in the region if it contains a
+match entirely contained in the region.
+
+If a match is split across lines, @code{flush-lines} deletes all those
+lines.  It deletes the lines before starting to look for the next
+match; hence, it ignores a match starting on the same line at which
+another match ended.
 
 @item M-x keep-lines @key{RET} @var{regexp} @key{RET}
-Delete each line that @emph{does not} contain a match for
-@var{regexp}, operating on the text after point.  In Transient Mark
-mode, if the region is active, the command operates on the region
-instead.
+This command deletes each line that @emph{does not} contain a match for
+@var{regexp}, operating on the text after point; if point is not at the
+beginning of a line, it always keeps the current line.  In Transient
+Mark mode, if the region is active, the command operates on the region
+instead; it never deletes lines that are only partially contained in
+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 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