/[emacs]/emacs/man/search.texi
ViewVC logotype

Diff of /emacs/man/search.texi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.50 by teirllm, Sun Jul 18 14:01:57 2004 UTC revision 1.51 by rms, Sat Jul 24 21:44:45 2004 UTC
# Line 1038  text to replace with, you must enter @sa Line 1038  text to replace with, you must enter @sa
1038    You can also use Lisp expressions to calculate parts of the    You can also use Lisp expressions to calculate parts of the
1039  replacement string.  To do this, write @samp{\,} followed by the  replacement string.  To do this, write @samp{\,} followed by the
1040  expression in the replacement string.  Each replacement calculates the  expression in the replacement string.  Each replacement calculates the
1041  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
1042    it's a string, this means using the string's contents), and uses it in
1043  the replacement string in place of the expression itself.  If the  the replacement string in place of the expression itself.  If the
1044  expression is a symbol, one space in the replacement string after the  expression is a symbol, one space in the replacement string after the
1045  symbol name counts as part of the symbol name, so the value replaces  symbol name goes with the symbol name, so the value replaces them
1046  them both.  both.
1047    
1048    Inside such an expression, @samp{\&} and @samp{\@var{n}} used as    Inside such an expression, you can use some special sequences.
1049  subexpressions refer respectively to the entire match as a string, and  @samp{\&} and @samp{\@var{n}} refer here, as usual, to the entire
1050  to a submatch as a string.  @var{n} may exceed 9 here, and the value  match as a string, and to a submatch as a string.  @var{n} may be
1051  of @samp{\@var{n}} is @code{nil} if subexpression @var{n} did not  multiple digits, and the value of @samp{\@var{n}} is @code{nil} if
1052  match.  You can also use @samp{\#&} and @samp{\#@var{n}} refer to  subexpression @var{n} did not match.  You can also use @samp{\#&} and
1053  those matches converted to numbers (this is valid when the match or  @samp{\#@var{n}} to refer to those matches as numbers (this is valid
1054  submatch has the form of a number).  @samp{\#} stands for the number  when the match or submatch has the form of a numeral).  @samp{\#} here
1055  of already-completed replacements.  too stands for the number of already-completed replacements.
1056    
1057    Repeating our example to exchange @samp{x} and @samp{y}, we can thus    Repeating our example to exchange @samp{x} and @samp{y}, we can thus
1058  do it also this way:  do it also this way:
# Line 1061  M-x replace-regexp @key{RET} \(x\)\|y @k Line 1062  M-x replace-regexp @key{RET} \(x\)\|y @k
1062  \,(if \1 "y" "x") @key{RET}  \,(if \1 "y" "x") @key{RET}
1063  @end example  @end example
1064    
1065    The @code{format} function (@pxref{Formatting Strings,,,elisp, GNU    For computing replacement strings for @samp{\,}, the @code{format}
1066  Emacs Lisp Reference Manual}) comes in handy for computing replacement  function is often useful (@pxref{Formatting Strings,,,elisp, GNU Emacs
1067  strings for @samp{\,}.  For example, to add consecutively numbered  Lisp Reference Manual}).  For example, to add consecutively numbered
1068  strings like @samp{ABC00042} to columns 73 @w{to 80} (unless they are  strings like @samp{ABC00042} to columns 73 @w{to 80} (unless they are
1069  already occupied), you can use  already occupied), you can use
1070    
# Line 1074  M-x replace-regexp @key{RET} ^.\@{0,72\@ Line 1075  M-x replace-regexp @key{RET} ^.\@{0,72\@
1075    
1076    If you want to enter part of the replacement string by hand each    If you want to enter part of the replacement string by hand each
1077  time, use @samp{\?} in the replacement string.  Each replacement will  time, use @samp{\?} in the replacement string.  Each replacement will
1078  enter a recursive edit, with point at the position where the @samp{\?}  ask you to edit the replacement string in the minibuffer, putting
1079  was.  For example,  point where the @samp{\?} was.  For example,
1080    
1081  @example  @example
1082  M-x replace-regexp @key{RET} \footnote@{ @key{RET}  M-x replace-regexp @key{RET} \footnote@{ @key{RET}

Legend:
Removed from v.1.50  
changed lines
  Added in v.1.51

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26