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

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

Re: Advanced query-replace-regexp in code


From: Barry Margolin
Subject: Re: Advanced query-replace-regexp in code
Date: Thu, 28 May 2009 03:04:26 -0400
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article <878wkhakp1.fsf@iki.fi>, Teemu Likonen <tlikonen@iki.fi> 
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 ***


reply via email to

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