comparison man/search.texi @ 82981:335d5c2fc901

Revision: miles@gnu.org--gnu-2004/emacs--gnus--5.10--patch-2 Merge from lorentey@elte.hu--2004/emacs--multi-tty--0, emacs--cvs-trunk--0 Patches applied: * lorentey@elte.hu--2004/emacs--multi-tty--0--patch-224 Added sorted-doc to backup regex in lib-src. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-465 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-482 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-483 Build-in-place tweak * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-484 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-486 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-487 Tweak permissions * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-488 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-489 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-490 Update from CVS: man/fixit.texi (Spelling): Fix typo. * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-491 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-494 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-495 Update from CVS: Add missing lisp/mh-e files * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-496 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-499 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-500 - miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-522 Update from CVS
author Miles Bader <miles@gnu.org>
date Sat, 04 Sep 2004 12:01:21 +0000
parents a139f4d21416
children 384212f1e3a5 3219f94257bc
comparison
equal deleted inserted replaced
82980:08aac74a5b90 82981:335d5c2fc901
213 When you exit the incremental search, it sets the mark to where point 213 When you exit the incremental search, it sets the mark to where point
214 @emph{was}, before the search. That is convenient for moving back 214 @emph{was}, before the search. That is convenient for moving back
215 there. In Transient Mark mode, incremental search sets the mark without 215 there. In Transient Mark mode, incremental search sets the mark without
216 activating it, and does so only if the mark is not already active. 216 activating it, and does so only if the mark is not already active.
217 217
218 @kbd{M-%} or @kbd{C-M-%} exits the incremental search and starts an 218 @kbd{M-%} typed in incremental search invokes @code{query-replace}
219 interactive command @code{query-replace} or @code{query-replace-regexp} 219 or @code{query-replace-regexp} (depending on search mode) with the
220 with the last search string inserted in the minibuffer as initial input 220 current search string used as the string to replace.
221 for the string to replace.
222 221
223 @cindex lazy search highlighting 222 @cindex lazy search highlighting
224 @vindex isearch-lazy-highlight 223 @vindex isearch-lazy-highlight
225 When you pause for a little while during incremental search, it 224 When you pause for a little while during incremental search, it
226 highlights all other possible matches for the search string. This 225 highlights all other possible matches for the search string. This
432 @cindex syntax of regexps 431 @cindex syntax of regexps
433 432
434 This manual describes regular expression features that users 433 This manual describes regular expression features that users
435 typically want to use. There are additional features that are 434 typically want to use. There are additional features that are
436 mainly used in Lisp programs; see @ref{Regular Expressions,,, 435 mainly used in Lisp programs; see @ref{Regular Expressions,,,
437 elisp, the same manual}. 436 elisp, The Emacs Lisp Reference Manual}.
438 437
439 Regular expressions have a syntax in which a few characters are 438 Regular expressions have a syntax in which a few characters are
440 special constructs and the rest are @dfn{ordinary}. An ordinary 439 special constructs and the rest are @dfn{ordinary}. An ordinary
441 character is a simple regular expression which matches that same 440 character is a simple regular expression which matches that same
442 character and nothing else. The special characters are @samp{$}, 441 character and nothing else. The special characters are @samp{$},
919 @item 918 @item
920 The buffer contents. 919 The buffer contents.
921 @item 920 @item
922 The selected window and selected frame. 921 The selected window and selected frame.
923 @item 922 @item
924 The current match-data @xref{Match Data,,,elisp}. 923 The current match-data. @xref{Match Data,,, elisp, The Emacs Lisp
924 Reference Manual}.
925 @end enumerate 925 @end enumerate
926 926
927 Additionally, the command must not delete the current window and must 927 Additionally, the command must not delete the current window and must
928 not itself attempt an incremental search. It may, however, change the 928 not itself attempt an incremental search. It may, however, change the
929 window's size, or create or delete other windows and frames. 929 window's size, or create or delete other windows and frames.
930 930
931 Note that an attempt by a command to scroll the text 931 Note that an attempt by a command to scroll the text
932 @emph{horizontally} won't work, although it will do no harm---any such 932 @emph{horizontally} won't work, although it will do no harm---any such
933 scrolling will be overriden and nullified by the display code. 933 scrolling will be overridden and nullified by the display code.
934 934
935 @node Replace, Other Repeating Search, Configuring Scrolling, Search 935 @node Replace, Other Repeating Search, Configuring Scrolling, Search
936 @section Replacement Commands 936 @section Replacement Commands
937 @cindex replacement 937 @cindex replacement
938 @cindex search-and-replace commands 938 @cindex search-and-replace commands
1036 text to replace with, you must enter @samp{\\}. 1036 text to replace with, you must enter @samp{\\}.
1037 1037
1038 You can also use Lisp expressions to calculate parts of the 1038 You can also use Lisp expressions to calculate parts of the
1039 replacement string. To do this, write @samp{\,} followed by the 1039 replacement string. To do this, write @samp{\,} followed by the
1040 expression in the replacement string. Each replacement calculates the 1040 expression in the replacement string. Each replacement calculates the
1041 value of the expression, which ought to be a string, and uses it in 1041 value of the expression and converts it to text without quoting (if
1042 it's a string, this means using the string's contents), and uses it in
1042 the replacement string in place of the expression itself. If the 1043 the replacement string in place of the expression itself. If the
1043 expression is a symbol, one space in the replacement string after the 1044 expression is a symbol, one space in the replacement string after the
1044 symbol name counts as part of the symbol name, so the value replaces 1045 symbol name goes with the symbol name, so the value replaces them
1045 them both. 1046 both.
1046 1047
1047 Inside such an expression, @samp{\&} and @samp{\@var{n}} used as 1048 Inside such an expression, you can use some special sequences.
1048 subexpressions refer respectively to the entire match as a string, and 1049 @samp{\&} and @samp{\@var{n}} refer here, as usual, to the entire
1049 to a submatch as a string. @var{n} may exceed 9 here, and the value 1050 match as a string, and to a submatch as a string. @var{n} may be
1050 of @samp{\@var{n}} is @code{nil} if subexpression @var{n} did not 1051 multiple digits, and the value of @samp{\@var{n}} is @code{nil} if
1051 match. You can also use @samp{\#&} and @samp{\#@var{n}} refer to 1052 subexpression @var{n} did not match. You can also use @samp{\#&} and
1052 those matches converted to numbers (this is valid when the match or 1053 @samp{\#@var{n}} to refer to those matches as numbers (this is valid
1053 submatch has the form of a number). @samp{\#} stands for the number 1054 when the match or submatch has the form of a numeral). @samp{\#} here
1054 of already-completed replacements. 1055 too stands for the number of already-completed replacements.
1055 1056
1056 Repeating our example to exchange @samp{x} and @samp{y}, we can thus 1057 Repeating our example to exchange @samp{x} and @samp{y}, we can thus
1057 do it also this way: 1058 do it also this way:
1058 1059
1059 @example 1060 @example
1060 M-x replace-regexp @key{RET} \(x\)\|y @key{RET} 1061 M-x replace-regexp @key{RET} \(x\)\|y @key{RET}
1061 \,(if \1 "y" "x") @key{RET} 1062 \,(if \1 "y" "x") @key{RET}
1062 @end example 1063 @end example
1063 1064
1064 The @code{format} function (@pxref{Formatting Strings,,,elisp, GNU 1065 For computing replacement strings for @samp{\,}, the @code{format}
1065 Emacs Lisp Reference Manual}) comes in handy for computing replacement 1066 function is often useful (@pxref{Formatting Strings,,, elisp, The Emacs
1066 strings for @samp{\,}. For example, to add consecutively numbered 1067 Lisp Reference Manual}). For example, to add consecutively numbered
1067 strings like @samp{ABC00042} to columns 73 @w{to 80} (unless they are 1068 strings like @samp{ABC00042} to columns 73 @w{to 80} (unless they are
1068 already occupied), you can use 1069 already occupied), you can use
1069 1070
1070 @example 1071 @example
1071 M-x replace-regexp @key{RET} ^.\@{0,72\@}$ @key{RET} 1072 M-x replace-regexp @key{RET} ^.\@{0,72\@}$ @key{RET}
1072 \,(format "%-72sABC%05d" \& \#) @key{RET} 1073 \,(format "%-72sABC%05d" \& \#) @key{RET}
1073 @end example 1074 @end example
1074 1075
1075 If you want to enter part of the replacement string by hand each 1076 If you want to enter part of the replacement string by hand each
1076 time, use @samp{\?} in the replacement string. Each replacement will 1077 time, use @samp{\?} in the replacement string. Each replacement will
1077 enter a recursive edit, with point at the position where the @samp{\?} 1078 ask you to edit the replacement string in the minibuffer, putting
1078 was. For example, 1079 point where the @samp{\?} was. For example,
1079 1080
1080 @example 1081 @example
1081 M-x replace-regexp @key{RET} \footnote@{ @key{RET} 1082 M-x replace-regexp @key{RET} \\footnote@{ @key{RET}
1082 \&\\label@{fn:\#\?@} @key{RET} 1083 \&\\label@{fn:\#\?@} @key{RET}
1083 @end example 1084 @end example
1084 1085
1085 @noindent 1086 @noindent
1086 will add labels starting with @samp{\label@{fn:0@}} to occurences of 1087 will add labels starting with @samp{\label@{fn:0@}} to occurrences of
1087 @samp{\footnote@{}, but letting you edit each replacement before 1088 @samp{\footnote@{}, but letting you edit each replacement before
1088 performing it. To number the labels starting at 1, use @samp{\,(1+ 1089 performing it. To number the labels starting at 1, use @samp{\,(1+
1089 \#)} instead of @samp{\#}. 1090 \#)} instead of @samp{\#}.
1090 1091
1091 @node Replacement and Case, Query Replace, Regexp Replace, Replace 1092 @node Replacement and Case, Query Replace, Regexp Replace, Replace
1282 point there and type @key{RET}; this switches to the buffer that was 1283 point there and type @key{RET}; this switches to the buffer that was
1283 searched and moves point to the original of the chosen occurrence. 1284 searched and moves point to the original of the chosen occurrence.
1284 @kbd{o} and @kbd{C-o} display the match in another window; @kbd{C-o} 1285 @kbd{o} and @kbd{C-o} display the match in another window; @kbd{C-o}
1285 does not select it. 1286 does not select it.
1286 1287
1288 Occur mode supports the @code{next-error} functionality described in
1289 in @ref{Compilation Mode}.
1290
1287 @item M-x list-matching-lines 1291 @item M-x list-matching-lines
1288 Synonym for @kbd{M-x occur}. 1292 Synonym for @kbd{M-x occur}.
1289 1293
1290 @item M-x multi-occur @key{RET} @var{buffers} @key{RET} @var{regexp} @key{RET} 1294 @item M-x multi-occur @key{RET} @var{buffers} @key{RET} @var{regexp} @key{RET}
1291 This function is just like @code{occur}, except it is able to search 1295 This function is just like @code{occur}, except it is able to search