help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Different behaviour between M-x replace-regexp in function and in ec


From: David Kastrup
Subject: Re: Different behaviour between M-x replace-regexp in function and in echo window
Date: Thu, 21 Apr 2005 11:54:55 +0200
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux)

luca.spinacci@seleniacomms.com writes:

> If I use M-x replace-regexp followed by
> "\(//\)[[:space:]] *" <RET> "\1 " <RET>
> the behaviour is correct - replacing any space
> between '//' ed comment text
> Ex.
> //___Text... => //_Text...
> where '_' is a space
>
> If I use the same
> replace-regexp "\(//\)[[:space:]] *" "\1 "
> in a function no replacing is done - Replaced 0 occurences -
>
> (defun comment-formatting(start end)
>  (interactive "*r")
>   (save-excursion
>     (save-restriction
>       (narrow-to-region start end)
>       (goto-char start)
>       (replace-regexp "\(//\)[[:space:]] *" "\1 "))))
>
> So M-x comment-formatting has differnt behaviour. Why?

It hasn't.  Just use
C-x ESC ESC
after the manual replacement to get a peek at what this did.  You'll
notice that the backslashes in string syntax have to be doubled.

-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum


reply via email to

[Prev in Thread] Current Thread [Next in Thread]