aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2001-02-19 01:57:45 +0000
committerRichard M. Stallman2001-02-19 01:57:45 +0000
commit91cf190988beb54c28478d5bc9e30bbf91bdf2dd (patch)
tree56a4b94dc2034049a0435773edf3e6d6dd2b9807
parent6ebbcf5986f63acdae5296e35ed616fea95c3145 (diff)
downloademacs-91cf190988beb54c28478d5bc9e30bbf91bdf2dd.tar.gz
emacs-91cf190988beb54c28478d5bc9e30bbf91bdf2dd.zip
Comment out description of re-builder.
Clarify isearch highlighting info and input method info. Rewrite descriptions of non-greedy repetition, \{...\}, and shy groups. Rewrite "Other Repeating Search" node. Other small clarifications.
-rw-r--r--man/search.texi217
1 files changed, 115 insertions, 102 deletions
diff --git a/man/search.texi b/man/search.texi
index 5383b0d2be8..19303c13209 100644
--- a/man/search.texi
+++ b/man/search.texi
@@ -58,8 +58,7 @@ the cursor move to after the first @samp{FO}. After another @kbd{O}, the
58cursor is after the first @samp{FOO} after the place where you started the 58cursor is after the first @samp{FOO} after the place where you started the
59search. At each step, the buffer text that matches the search string is 59search. At each step, the buffer text that matches the search string is
60highlighted, if the terminal can do that; at each step, the current search 60highlighted, if the terminal can do that; at each step, the current search
61string is updated in the echo area. Multilingual text can be input by 61string is updated in the echo area.
62toggling input methods with @kbd{C-\} or @kbd{C-^}, see below.
63 62
64 If you make a mistake in typing the search string, you can cancel 63 If you make a mistake in typing the search string, you can cancel
65characters with @key{DEL}. Each @key{DEL} cancels the last character of 64characters with @key{DEL}. Each @key{DEL} cancels the last character of
@@ -79,11 +78,11 @@ special within searches (@kbd{C-q}, @kbd{C-w}, @kbd{C-r}, @kbd{C-s},
79@kbd{C-y}, @kbd{M-y}, @kbd{M-r}, or @kbd{M-s}). 78@kbd{C-y}, @kbd{M-y}, @kbd{M-r}, or @kbd{M-s}).
80 79
81 Sometimes you search for @samp{FOO} and find it, but not the one you 80 Sometimes you search for @samp{FOO} and find it, but not the one you
82expected to find. There was a second @samp{FOO} that you forgot about, 81expected to find. There was a second @samp{FOO} that you forgot
83before the one you were aiming for. In this event, type another @kbd{C-s} 82about, before the one you were aiming for. In this event, type
84to move to the next occurrence of the search string. This can be done any 83another @kbd{C-s} to move to the next occurrence of the search string.
85number of times. If you overshoot, you can cancel some @kbd{C-s} 84You can repeat this any number of times. If you overshoot, you can
86characters with @key{DEL}. 85cancel some @kbd{C-s} characters with @key{DEL}.
87 86
88 After you exit a search, you can search for the same string again by 87 After you exit a search, you can search for the same string again by
89typing just @kbd{C-s C-s}: the first @kbd{C-s} is the key that invokes 88typing just @kbd{C-s C-s}: the first @kbd{C-s} is the key that invokes
@@ -112,15 +111,24 @@ entirely, returning point to where it was when the search started.
112case-sensitive. If you delete the upper-case character from the search 111case-sensitive. If you delete the upper-case character from the search
113string, it ceases to have this effect. @xref{Search Case}. 112string, it ceases to have this effect. @xref{Search Case}.
114 113
114 To search for a newline, type @kbd{C-j}. To search for another
115control character, such as control-S or carriage return, you must quote
116it by typing @kbd{C-q} first. This function of @kbd{C-q} is analogous
117to its use for insertion (@pxref{Inserting Text}): it causes the
118following character to be treated the way any ``ordinary'' character is
119treated in the same context. You can also specify a character by its
120octal code: enter @kbd{C-q} followed by a sequence of octal digits.
121
115@cindex searching for non-ASCII characters 122@cindex searching for non-ASCII characters
116@cindex input method, during incremental search 123@cindex input method, during incremental search
117 If an input method (@pxref{Input Methods}) is turned on in the 124 To search for non-ASCII characters, you must use an input method
118current buffer when you start the search, that input method is used to 125(@pxref{Input Methods}). If an input method is turned on in the
119read the characters while you type the search string. Emacs indicates 126current buffer when you start the search, you can use it while you
120that by including the input method mnemonic in its prompt, like this: 127type the search string also. Emacs indicates that by including the
128input method mnemonic in its prompt, like this:
121 129
122@example 130@example
123 I-search [@var{im}]: 131I-search [@var{im}]:
124@end example 132@end example
125 133
126@noindent 134@noindent
@@ -135,12 +143,13 @@ name of the input method. Note that the input method you turn on
135during incremental search is turned on in the current buffer as well. 143during incremental search is turned on in the current buffer as well.
136 144
137 If a search is failing and you ask to repeat it by typing another 145 If a search is failing and you ask to repeat it by typing another
138@kbd{C-s}, it starts again from the beginning of the buffer. Repeating 146@kbd{C-s}, it starts again from the beginning of the buffer.
139a failing reverse search with @kbd{C-r} starts again from the end. This 147Repeating a failing reverse search with @kbd{C-r} starts again from
140is called @dfn{wrapping around}. @samp{Wrapped} appears in the search 148the end. This is called @dfn{wrapping around}, and @samp{Wrapped}
141prompt once this has happened. If you keep on going past the original 149appears in the search prompt once this has happened. If you keep on
142starting point of the search, it changes to @samp{Overwrapped}, which 150going past the original starting point of the search, it changes to
143means that you are revisiting matches that you have already seen. 151@samp{Overwrapped}, which means that you are revisiting matches that
152you have already seen.
144 153
145@cindex quitting (in search) 154@cindex quitting (in search)
146 The @kbd{C-g} ``quit'' character does special things during searches; 155 The @kbd{C-g} ``quit'' character does special things during searches;
@@ -154,14 +163,6 @@ been found are discarded from the search string. With them gone, the
154search is now successful and waiting for more input, so a second @kbd{C-g} 163search is now successful and waiting for more input, so a second @kbd{C-g}
155will cancel the entire search. 164will cancel the entire search.
156 165
157 To search for a newline, type @kbd{C-j}. To search for another
158control character, such as control-S or carriage return, you must quote
159it by typing @kbd{C-q} first. This function of @kbd{C-q} is analogous
160to its use for insertion (@pxref{Inserting Text}): it causes the
161following character to be treated the way any ``ordinary'' character is
162treated in the same context. You can also specify a character by its
163octal code: enter @kbd{C-q} followed by a sequence of octal digits.
164
165 You can change to searching backwards with @kbd{C-r}. If a search fails 166 You can change to searching backwards with @kbd{C-r}. If a search fails
166because the place you started was too late in the file, you should do this. 167because the place you started was too late in the file, you should do this.
167Repeated @kbd{C-r} keeps looking for more occurrences backwards. A 168Repeated @kbd{C-r} keeps looking for more occurrences backwards. A
@@ -189,7 +190,7 @@ search remains case-insensitive.
189 190
190 The character @kbd{M-y} copies text from the kill ring into the search 191 The character @kbd{M-y} copies text from the kill ring into the search
191string. It uses the same text that @kbd{C-y} as a command would yank. 192string. It uses the same text that @kbd{C-y} as a command would yank.
192@kbd{mouse-2} in the echo area does the same. 193@kbd{Mouse-2} in the echo area does the same.
193@xref{Yanking}. 194@xref{Yanking}.
194 195
195 When you exit the incremental search, it sets the mark to where point 196 When you exit the incremental search, it sets the mark to where point
@@ -198,28 +199,20 @@ there. In Transient Mark mode, incremental search sets the mark without
198activating it, and does so only if the mark is not already active. 199activating it, and does so only if the mark is not already active.
199 200
200@cindex lazy search highlighting 201@cindex lazy search highlighting
201 By default, Isearch uses @dfn{lazy highlighting}. All matches for
202the current search string in the buffer after the point where searching
203starts are highlighted. The extra highlighting makes it easier to
204anticipate where the cursor will end up each time you press @kbd{C-s} or
205@kbd{C-r} to repeat a pending search. Highlighting of these additional
206matches happens in a deferred fashion so as not to rob Isearch of its
207usual snappy response.
208@vindex isearch-lazy-highlight-cleanup
209@findex isearch-lazy-highlight-cleanup
210By default the highlighting of matches is cleared when you end the
211search. Customize the variable @code{isearch-lazy-highlight-cleanup} to
212avoid cleaning up automatically. The command @kbd{M-x
213isearch-lazy-highlight-cleanup} can be used to clean up manually.
214@vindex isearch-lazy-highlight 202@vindex isearch-lazy-highlight
215Customize the variable @code{isearch-lazy-highlight} to turn off this 203 When you pause for a little while during incremental search, it
216feature. 204highlights all other possible matches for the search string. This
205makes it easier to anticipate where you can get to by typing @kbd{C-s}
206or @kbd{C-r} to repeat the search. The short delay before highlighting
207other matches helps indicate which match is the current one.
208If you don't like this feature, you can turn it off by setting
209@code{isearch-lazy-highlight} to @code{nil}.
217 210
218@vindex isearch-lazy-highlight-face 211@vindex isearch-lazy-highlight-face
219@cindex faces for highlighting search matches 212@cindex faces for highlighting search matches
220 You can control how does the highlighting of matches look like by 213 You can control how does the highlighting of matches look like by
221customizing the faces @code{isearch} (highlights the current match) and 214customizing the faces @code{isearch} (used for the current match) and
222@code{isearch-lazy-highlight-face} (highlights the other matches). 215@code{isearch-lazy-highlight-face} (used for the other matches).
223 216
224@vindex isearch-mode-map 217@vindex isearch-mode-map
225 To customize the special characters that incremental search understands, 218 To customize the special characters that incremental search understands,
@@ -240,11 +233,6 @@ on the screen.
240Then Emacs redisplays the window in which the search was done, to show 233Then Emacs redisplays the window in which the search was done, to show
241its new position of point. 234its new position of point.
242 235
243@ignore
244 The three dots at the end of the search string, normally used to indicate
245that searching is going on, are not displayed in slow style display.
246@end ignore
247
248@vindex search-slow-speed 236@vindex search-slow-speed
249 The slow terminal style of display is used when the terminal baud rate is 237 The slow terminal style of display is used when the terminal baud rate is
250less than or equal to the value of the variable @code{search-slow-speed}, 238less than or equal to the value of the variable @code{search-slow-speed},
@@ -459,20 +447,31 @@ preceding expression either once or not at all. For example,
459@item *?, +?, ?? 447@item *?, +?, ??
460@cindex non-greedy regexp matching 448@cindex non-greedy regexp matching
461are non-greedy variants of the operators above. The normal operators 449are non-greedy variants of the operators above. The normal operators
462@samp{*}, @samp{+}, @samp{?} are @dfn{greedy} in that they match as much 450@samp{*}, @samp{+}, @samp{?} are @dfn{greedy} in that they match as
463as they can, while if you append a @samp{?} after them, it makes them 451much as they can, as long as the overall regexp can still match. With
464non-greedy: they will match as little as possible. 452a following @samp{?}, they are non-greedy: they will match as little
453as possible.
454
455Thus, both @samp{ab*} and @samp{ab*?} can match the string @samp{a}
456and the string @samp{abbbb}; but if you try to match them both against
457the text @samp{abbb}, @samp{ab*} will match it all (the longest valid
458match), while @samp{ab*?} will match just @samp{a} (the shortest
459valid match).
460
461@item \@{@var{n}\@}
462is a postfix operator that specifies repetition @var{n} times---that
463is, the preceding regular expression must match exactly @var{n} times
464in a row. For example, @samp{x\@{4\@}} matches the string @samp{xxxx}
465and nothing else.
465 466
466@item \@{@var{n},@var{m}\@} 467@item \@{@var{n},@var{m}\@}
467is another postfix operator that specifies an interval of iteration: 468is a postfix operator that specifies repetition between @var{n} and
468the preceding regular expression must match between @var{n} and 469@var{m} times---that is, the preceding regular expression must match
469@var{m} times. If @var{m} is omitted, then there is no upper bound 470at least @var{n} times, but no more than @var{m} times. If @var{m} is
470and if @samp{,@var{m}} is omitted, then the regular expression must match 471omitted, then there is no upper limit, but the preceding regular
471exactly @var{n} times. @* 472expression must match at least @var{n} times.@* @samp{\@{0,1\@}} is
472@samp{\@{0,1\@}} is equivalent to @samp{?}. @* 473equivalent to @samp{?}. @* @samp{\@{0,\@}} is equivalent to
473@samp{\@{0,\@}} is equivalent to @samp{*}. @* 474@samp{*}. @* @samp{\@{1,\@}} is equivalent to @samp{+}.
474@samp{\@{1,\@}} is equivalent to @samp{+}. @*
475@samp{\@{@var{n}\@}} is equivalent to @samp{\@{@var{n},@var{n}\@}}.
476 475
477@item [ @dots{} ] 476@item [ @dots{} ]
478is a @dfn{character set}, which begins with @samp{[} and is terminated 477is a @dfn{character set}, which begins with @samp{[} and is terminated
@@ -591,15 +590,16 @@ To record a matched substring for future reference.
591This last application is not a consequence of the idea of a 590This last application is not a consequence of the idea of a
592parenthetical grouping; it is a separate feature that is assigned as a 591parenthetical grouping; it is a separate feature that is assigned as a
593second meaning to the same @samp{\( @dots{} \)} construct. In practice 592second meaning to the same @samp{\( @dots{} \)} construct. In practice
594there is almost no conflict between the two meanings. 593there is usually no conflict between the two meanings; when there is
594a conflict, you can use a ``shy'' group.
595 595
596@item \(?: @dots{} \) 596@item \(?: @dots{} \)
597is another grouping construct (often called ``shy'') that serves the same 597@cindex shy group, in regexp
598first two purposes, but not the third: 598specifies a ``shy'' group that does not record the matched substring;
599it cannot be referred to later on by number. This is only useful 599you can't refer back to it with @samp{\@var{d}}. This is useful
600for mechanically constructed regular expressions where grouping 600in mechanically combining regular expressions, so that you
601constructs need to be introduced implicitly and hence risk changing the 601can add groups for syntactic purposes without interfering with
602numbering of subsequent groups. 602the numbering of the groups that were written by the user.
603 603
604@item \@var{d} 604@item \@var{d}
605matches the same text that matched the @var{d}th occurrence of a 605matches the same text that matched the @var{d}th occurrence of a
@@ -718,18 +718,26 @@ of times.
718enter a tab, and @kbd{C-j} to enter a newline. You would also type 718enter a tab, and @kbd{C-j} to enter a newline. You would also type
719single backslashes as themselves, instead of doubling them for Lisp syntax. 719single backslashes as themselves, instead of doubling them for Lisp syntax.
720 720
721@ignore
722@c I commented this out because it is missing vital information
723@c and therefore useless. For instance, what do you do to *use* the
724@c regular expression when it is finished? What jobs is this good for?
725@c -- rms
726
721@findex re-builder 727@findex re-builder
722@cindex authoring regular expressions 728@cindex authoring regular expressions
723 For easier authoring of regular expressions, you can use the @kbd{M-x 729 For convenient interactive development of regular expressions, you
724re-builder} command. It provides a convenient interface for creating 730can use the @kbd{M-x re-builder} command. It provides a convenient
725regular expressions, by giving immediate visual feedback. The buffer 731interface for creating regular expressions, by giving immediate visual
726from which @code{re-builder} was invoked becomes the target for the 732feedback. The buffer from which @code{re-builder} was invoked becomes
727regexp editor, which pops in a separate window. Text that matches the 733the target for the regexp editor, which pops in a separate window. At
728regular expression you typed so far is color marked in the target 734all times, all the matches in the target buffer for the current
729buffer. Each parenthesized sub-expression of the regexp is shown in a 735regular expression are highlighted. Each parenthesized sub-expression
730distinct face, which makes it easier to verify even very complex 736of the regexp is shown in a distinct face, which makes it easier to
731regexps. (On displays that don't support colors, Emacs blinks the 737verify even very complex regexps. (On displays that don't support
732cursor around the matched text, like it does for matching parens.) 738colors, Emacs blinks the cursor around the matched text, as it does
739for matching parens.)
740@end ignore
733 741
734@node Search Case, Replace, Regexps, Search 742@node Search Case, Replace, Regexps, Search
735@section Searching and Case 743@section Searching and Case
@@ -972,13 +980,16 @@ to delete the occurrence, and then enter a recursive editing level as in
972occurrence of @var{string}. When done, exit the recursive editing level 980occurrence of @var{string}. When done, exit the recursive editing level
973with @kbd{C-M-c} to proceed to the next occurrence. 981with @kbd{C-M-c} to proceed to the next occurrence.
974 982
983@item e
984to edit the replacement string in the minibuffer. When you exit the
985minibuffer by typing @key{RET}, the minibuffer contents replace the
986current occurrence of the pattern. They also become the new
987replacement string for any further occurrences.
988
975@item C-l 989@item C-l
976to redisplay the screen. Then you must type another character to 990to redisplay the screen. Then you must type another character to
977specify what to do with this occurrence. 991specify what to do with this occurrence.
978 992
979@item e
980to let you edit the replacement string.
981
982@item C-h 993@item C-h
983to display a message summarizing these options. Then you must type 994to display a message summarizing these options. Then you must type
984another character to specify what to do with this occurrence. 995another character to specify what to do with this occurrence.
@@ -1005,9 +1016,10 @@ copy, or link files by replacing regexp matches in file names.
1005@section Other Search-and-Loop Commands 1016@section Other Search-and-Loop Commands
1006 1017
1007 Here are some other commands that find matches for a regular 1018 Here are some other commands that find matches for a regular
1008expression. They all operate from point to the end of the buffer, and 1019expression. They all ignore case in matching, if the pattern contains
1009all ignore case in matching, if the pattern contains no upper-case 1020no upper-case letters and @code{case-fold-search} is non-@code{nil}.
1010letters and @code{case-fold-search} is non-@code{nil}. 1021Aside from @code{occur}, all operate on the text from point to the end
1022of the buffer, or on the active region in Transient Mark mode.
1011 1023
1012@findex list-matching-lines 1024@findex list-matching-lines
1013@findex occur 1025@findex occur
@@ -1019,11 +1031,11 @@ letters and @code{case-fold-search} is non-@code{nil}.
1019 1031
1020@table @kbd 1032@table @kbd
1021@item M-x occur @key{RET} @var{regexp} @key{RET} 1033@item M-x occur @key{RET} @var{regexp} @key{RET}
1022Display a list showing each line in the buffer that contains a match for 1034Display a list showing each line in the buffer that contains a match
1023@var{regexp}. A numeric argument specifies the number of context lines 1035for @var{regexp}. To limit the search to part of the buffer, narrow
1024to print before and after each matching line; the default is none. 1036to that part (@pxref{Narrowing}). A numeric argument @var{n}
1025To limit the search to part of the buffer, narrow to that part 1037specifies to display @var{n} lines of context before and after each
1026(@pxref{Narrowing}). 1038matching line.
1027 1039
1028@kindex RET @r{(Occur mode)} 1040@kindex RET @r{(Occur mode)}
1029The buffer @samp{*Occur*} containing the output serves as a menu for 1041The buffer @samp{*Occur*} containing the output serves as a menu for
@@ -1036,22 +1048,23 @@ moves point to the original of the chosen occurrence.
1036Synonym for @kbd{M-x occur}. 1048Synonym for @kbd{M-x occur}.
1037 1049
1038@item M-x how-many @key{RET} @var{regexp} @key{RET} 1050@item M-x how-many @key{RET} @var{regexp} @key{RET}
1039Print the number of matches for @var{regexp} after point, or in the 1051Print the number of matches for @var{regexp} that exist in the buffer
1040active region in Transient Mark mode. 1052after point. In Transient Mark mode, if the region is active, the
1053command operates on the region instead.
1041 1054
1042@item M-x flush-lines @key{RET} @var{regexp} @key{RET} 1055@item M-x flush-lines @key{RET} @var{regexp} @key{RET}
1043Delete each line after point, or in the active region in Transient Mark 1056Delete each line that contains a match for @var{regexp}, operating on
1044mode, that contains a match for @var{regexp}. 1057the text after point. In Transient Mark mode, if the region is
1058active, the command operates on the region instead.
1045 1059
1046@item M-x keep-lines @key{RET} @var{regexp} @key{RET} 1060@item M-x keep-lines @key{RET} @var{regexp} @key{RET}
1047Delete each line that follows point, or is in the active region in 1061Delete each line that @emph{does not} contain a match for
1048Transient Mark mode, and @emph{does not} contain a match for 1062@var{regexp}, operating on the text after point. In Transient Mark
1049@var{regexp}. 1063mode, if the region is active, the command operates on the region
1064instead.
1050@end table 1065@end table
1051 1066
1052 Searching and replacing can be performed under the control of tags 1067 You can also search multiple files under control of a tags table
1053files (@pxref{Tags Search}) and Dired (@pxref{Operating on Files}). 1068(@pxref{Tags Search}) or through Dired @kbd{A} command
1054 1069(@pxref{Operating on Files}), or ask the @code{grep} program to do it
1055 In addition, you can use @code{grep} from Emacs to search a collection 1070(@pxref{Grep Searching}).
1056of files for matches for a regular expression, then visit the matches
1057either sequentially or in arbitrary order. @xref{Grep Searching}.