all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Barry Margolin <barmar@alum.mit.edu>
To: help-gnu-emacs@gnu.org
Subject: Re: complex query replace using perform-replace with replace-re-search-function
Date: Fri, 15 Jun 2012 10:42:47 -0400	[thread overview]
Message-ID: <barmar-672C54.10424715062012@news.eternal-september.org> (raw)
In-Reply-To: 51b588c0-c619-4466-926e-91b26a2c7ad6@d17g2000vbv.googlegroups.com

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	other threads:[~2012-06-15 14:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-15 13:49 complex query replace using perform-replace with replace-re-search-function jack-mac
2012-06-15 14:42 ` Barry Margolin [this message]

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=barmar-672C54.10424715062012@news.eternal-september.org \
    --to=barmar@alum.mit.edu \
    --cc=help-gnu-emacs@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.