From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.help Subject: Re: Different behaviour between M-x replace-regexp in function and in echo window Date: Thu, 21 Apr 2005 11:54:55 +0200 Organization: Organization?!? Message-ID: <85ll7ctpxs.fsf@lola.goethe.zz> References: NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1114077492 16905 80.91.229.2 (21 Apr 2005 09:58:12 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Thu, 21 Apr 2005 09:58:12 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Apr 21 11:58:10 2005 Return-path: Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1DOYRS-0002f7-7T for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Apr 2005 11:57:50 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1DOYW8-0001w2-Eg for geh-help-gnu-emacs@m.gmane.org; Thu, 21 Apr 2005 06:02:40 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!newsmi-us.news.garr.it!newsmi-eu.news.garr.it!NewsITBone-GARR!newsserver.news.garr.it!newscore.univie.ac.at!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor.de!news.arcor.de!not-for-mail Original-Newsgroups: gnu.emacs.help X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:gOO5Wii2BCxZAd1HQC6m6svCJbM= Original-Lines: 31 Original-NNTP-Posting-Date: 21 Apr 2005 11:55:08 MEST Original-NNTP-Posting-Host: d553c52d.newsread2.arcor-online.net Original-X-Trace: DXC=_Z2:CK34@`6g0XoR1BOW]\JAZH0Ec?`[F:Wf@NmY03 Original-X-Complaints-To: abuse@arcor.de Original-Xref: shelby.stanford.edu gnu.emacs.help:130303 Original-To: help-gnu-emacs@gnu.org X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:25874 X-Report-Spam: http://spam.gmane.org/gmane.emacs.help:25874 luca.spinacci@seleniacomms.com writes: > If I use M-x replace-regexp followed by > "\(//\)[[:space:]] *" "\1 " > 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