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

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

Re: complex query replace using perform-replace with replace-re-search-f


From: Barry Margolin
Subject: Re: complex query replace using perform-replace with replace-re-search-function
Date: Fri, 15 Jun 2012 10:42:47 -0400
User-agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X)

In article 
<51b588c0-c619-4466-926e-91b26a2c7ad6@d17g2000vbv.googlegroups.com>,
 jack-mac <duthen.mac@gmail.com> wrote:

> [2] Also, when reading the code of `perform-replace', I found
> something strange (NOT related to my problem, I think, since I don't
> use the `delimited-flag').
> 
> It changes twice the `search-function' variable:
> 
> Once is ok for me (since it takes into account the value of the
> variable `replace-re-search-function'):
> 
>   (let* ([snip]
>          (search-function
>         (if regexp-flag
>             replace-re-search-function
>           replace-search-function))
>          [snip])
> 
> but the second one (when `delimited-flag' is t) seems to erase the
> previous value of `search-function' and does NOT take into account the
> value of the variable `replace-re-search-function'):
> 
>     (if delimited-flag
>       (setq search-function 're-search-forward
>             search-string (concat "\\b"
>                                   (if regexp-flag from-string
>                                     (regexp-quote from-string))
>                                   "\\b")))
> 
> Is this correct?

Yes.  Notice that the second one calls regexp-quote if regexp-flag was 
not set.  This escapes all the special regexp characters in the search 
string.  This allows it to use an RE search, but it will only find 
literal matches.

-- 
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***


reply via email to

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