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: complex query replace using perform-replace with replace-re-search-function Date: Fri, 15 Jun 2012 10:42:47 -0400 Organization: A noiseless patient Spider Message-ID: References: <51b588c0-c619-4466-926e-91b26a2c7ad6@d17g2000vbv.googlegroups.com> NNTP-Posting-Host: plane.gmane.org X-Trace: dough.gmane.org 1339771515 9121 80.91.229.3 (15 Jun 2012 14:45:15 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Fri, 15 Jun 2012 14:45:15 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Fri Jun 15 16:45:14 2012 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1SfXlw-0006Nc-Rm for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Jun 2012 16:45:12 +0200 Original-Received: from localhost ([::1]:55074 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfXlw-0003fg-QO for geh-help-gnu-emacs@m.gmane.org; Fri, 15 Jun 2012 10:45:12 -0400 Original-Path: usenet.stanford.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!news-2.dfn.de!news.dfn.de!feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help Original-Lines: 42 Injection-Info: barmar.motzarella.org; posting-host="ePtxJaRXJPFeIWBMlKfZaA"; logging-data="13124"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19KNRC70Njec5SAs05jcwI9" User-Agent: MT-NewsWatcher/3.5.3b3 (Intel Mac OS X) Cancel-Lock: sha1:thkkLNu3PhfkmC+TUMJ1lmGqSyQ= Original-Xref: usenet.stanford.edu gnu.emacs.help:192850 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:85251 Archived-At: In article <51b588c0-c619-4466-926e-91b26a2c7ad6@d17g2000vbv.googlegroups.com>, jack-mac 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 ***