* Re: Different behaviour between M-x replace-regexp in function and in echo window
[not found] <mailman.2365.1114076857.2895.help-gnu-emacs@gnu.org>
@ 2005-04-21 9:54 ` David Kastrup
2005-04-21 13:21 ` Different behaviour between M-x replace-regexp in function and in echowindow Peter Tury
1 sibling, 0 replies; 2+ messages in thread
From: David Kastrup @ 2005-04-21 9:54 UTC (permalink / raw)
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Different behaviour between M-x replace-regexp in function and in echowindow
[not found] <mailman.2365.1114076857.2895.help-gnu-emacs@gnu.org>
2005-04-21 9:54 ` Different behaviour between M-x replace-regexp in function and in echo window David Kastrup
@ 2005-04-21 13:21 ` Peter Tury
1 sibling, 0 replies; 2+ messages in thread
From: Peter Tury @ 2005-04-21 13:21 UTC (permalink / raw)
Hi,
consider this alternative:
(defun comment-formatting(start end)
(interactive "*r")
(save-excursion
(goto-char start)
(while (search-forward "//" end t)
(just-one-space))))
It inserts a SPC if needed. Hm?
Br,
P
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-04-21 13:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <mailman.2365.1114076857.2895.help-gnu-emacs@gnu.org>
2005-04-21 9:54 ` Different behaviour between M-x replace-regexp in function and in echo window David Kastrup
2005-04-21 13:21 ` Different behaviour between M-x replace-regexp in function and in echowindow Peter Tury
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).