[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Emacs-diffs] Changes to emacs/man/search.texi
From: |
David Kastrup |
Subject: |
[Emacs-diffs] Changes to emacs/man/search.texi |
Date: |
Fri, 25 Jun 2004 07:07:01 -0400 |
Index: emacs/man/search.texi
diff -c emacs/man/search.texi:1.45 emacs/man/search.texi:1.46
*** emacs/man/search.texi:1.45 Thu Jun 24 14:05:59 2004
--- emacs/man/search.texi Fri Jun 25 11:02:08 2004
***************
*** 1018,1029 ****
You can also use arbitrary Lisp expressions evaluated at replacement
time by placing @samp{\,} before them in the replacement string. Inside
! of those expressions, the symbols @samp{\&} and @address@hidden refer to
! match and submatch strings like described above (a submatch not matching
! anything will be @samp{nil}), and @samp{\&#} and @address@hidden to
! those strings converted to numbers. @samp{\#} is short for
! @samp{replace-count}, the number of already completed replacements.
! This particular shorthand can also be used outside of @samp{\,}.
Repeating our example to exchange @samp{x} and @samp{y}, we can thus
do it also this way:
--- 1018,1030 ----
You can also use arbitrary Lisp expressions evaluated at replacement
time by placing @samp{\,} before them in the replacement string. Inside
! of those expressions, the symbols @samp{\&} and @address@hidden refer to
! match and submatch strings like described above (though @var{n} may
! exceed 9 here, and you get @code{nil} if nothing matches). @samp{\#&}
! and @address@hidden refer to those strings converted to numbers.
! @samp{\#} is short for @samp{replace-count}, the number of already
! completed replacements. This particular shorthand can also be used
! outside of @samp{\,}.
Repeating our example to exchange @samp{x} and @samp{y}, we can thus
do it also this way:
***************
*** 1033,1043 ****
\,(if \1 "y" "x") @key{RET}
@end example
Another feature you can use in the replacement string of Regexp
commands is @samp{\?}. In that case you will be allowed to edit the
replacement string at the given position before the replacement gets
! performed. Lisp style replacements have already been done before
! @samp{\?} is executed. For example,
@example
M-x replace-regexp @key{RET} address@hidden @key{RET}
--- 1034,1054 ----
\,(if \1 "y" "x") @key{RET}
@end example
+ One function that comes handy in Lisp replacements is @samp{format}
+ (@pxref{Formatting Strings,,,elisp, GNU Emacs Lisp Reference Manual}).
+ For example, to add consecutively numbered strings like @samp{ABC00042}
+ to columns 73 @w{to 80} (unless they are already occupied), you can use
+
+ @example
+ M-x replace-regexp @key{RET} address@hidden,address@hidden @key{RET}
+ \,(format "%-72sABC%05d" \& \#) @key{RET}
+ @end example
+
Another feature you can use in the replacement string of Regexp
commands is @samp{\?}. In that case you will be allowed to edit the
replacement string at the given position before the replacement gets
! performed. Lisp style replacements are performed before @samp{\?} gets
! executed. For example,
@example
M-x replace-regexp @key{RET} address@hidden @key{RET}
***************
*** 1050,1064 ****
performing it. If you want labels starting at 1, use @samp{\,(1+ \#)}
instead of @samp{\#}.
- As another example, to add consecutively numbered strings like
- @samp{ABC00042} to column 73 to~80 (unless they are already occupied),
- you can use
-
- @example
- M-x replace-regexp @key{RET} address@hidden,address@hidden @key{RET}
- \,(format "%-72sABC%05d" \& \#) @key{RET}
- @end example
-
@node Replacement and Case, Query Replace, Regexp Replace, Replace
@subsection Replace Commands and Case
--- 1061,1066 ----