From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Barry Margolin Newsgroups: gmane.emacs.help Subject: Re: Advanced query-replace-regexp in code Date: Thu, 28 May 2009 03:04:26 -0400 Organization: A noiseless patient Spider Message-ID: References: <878wkhakp1.fsf@iki.fi> NNTP-Posting-Host: lo.gmane.org X-Trace: ger.gmane.org 1243496543 16483 80.91.229.12 (28 May 2009 07:42:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 28 May 2009 07:42:23 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu May 28 09:42:21 2009 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1M9aFm-0007DX-Gy for geh-help-gnu-emacs@m.gmane.org; Thu, 28 May 2009 09:42:20 +0200 Original-Received: from localhost ([127.0.0.1]:45579 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M9aFl-0002Ud-3R for geh-help-gnu-emacs@m.gmane.org; Thu, 28 May 2009 03:42:17 -0400 Original-Path: news.stanford.edu!headwall.stanford.edu!news.glorb.com!news2.glorb.com!weretis.net!feeder2.news.weretis.net!feeder.motzarella.org!news.motzarella.org!news.eternal-september.org!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 38 Original-X-Trace: news.eternal-september.org U2FsdGVkX192t5kYvqp1ZS3X+Pot1EF/YC6e33oL0XbREJWVVqJ05DmvLVpFF1kkkj00bVHgw0AxVXRLmPv9dIw3nBP1VQrSTa80JVeVG0FxBNpSkISxrWvRZujSXc69HHvfulDUnQASbVRiDiPtfg== Original-X-Complaints-To: abuse@eternal-september.org Original-NNTP-Posting-Date: Thu, 28 May 2009 07:04:26 +0000 (UTC) X-Auth-Sender: U2FsdGVkX1+oKuMh7pmpHXI/cA8n/O4ygxCDsdvo8Wk= Cancel-Lock: sha1:R+eQfTo5UH6l1ndRGSxt2j4SmOM= User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Mail-Copies-To: nobody Original-Xref: news.stanford.edu gnu.emacs.help:169558 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:64791 Archived-At: In article <878wkhakp1.fsf@iki.fi>, Teemu Likonen wrote: > On 2009-05-27 21:19 (-0400), Barry Margolin wrote: > > > In interactive calls, the replacement text may contain `\,' > > > > It's a special extension just for interactive use. I'm not sure why it > > was restricted this way. > > I think in Lisp programs it's much easier and more problem-free to > evaluate Lisp expressions normal Lisp-way than to write expressions > inside strings and use the "\\,expression" form there. > > Interactive replace string > > \,(capitalize \1) > > can be written as > > (capitalize (match-string 1)) > > in programs. With functions like "concat" or "format" the latter > expression can be concatenated with the surrounding replace string. In that case, why allow programs to call replace-regexp in the first place? If they can call it, why shouldn't they be able to use all the features? replace-regexp also does the searching and looping for you. So instead of a simple, concise one-liner, you have to code everything, with the potential to screw up. -- Barry Margolin, barmar@alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group ***