all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Kastrup <dak@gnu.org>
Subject: Re: Different behaviour between M-x replace-regexp in function and in echo window
Date: Thu, 21 Apr 2005 11:54:55 +0200	[thread overview]
Message-ID: <85ll7ctpxs.fsf@lola.goethe.zz> (raw)
In-Reply-To: mailman.2365.1114076857.2895.help-gnu-emacs@gnu.org

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	other threads:[~2005-04-21  9:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <mailman.2365.1114076857.2895.help-gnu-emacs@gnu.org>
2005-04-21  9:54 ` David Kastrup [this message]
2005-04-21 13:21 ` Different behaviour between M-x replace-regexp in function and in echowindow Peter Tury
2005-04-21  9:35 Different behaviour between M-x replace-regexp in function and in echo window luca.spinacci
2005-04-21 10:29 ` Peter Dyballa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=85ll7ctpxs.fsf@lola.goethe.zz \
    --to=dak@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.