From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.help Subject: Re: multiple search strings in query-replace-regexp Date: Tue, 10 Oct 2006 00:21:16 +0200 Organization: Organization?!? Message-ID: <85zmc5xh9f.fsf@lola.goethe.zz> References: <1160133442.016714.5230@m7g2000cwm.googlegroups.com> <85wt7cwkwc.fsf@lola.goethe.zz> NNTP-Posting-Host: main.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1160433684 13217 80.91.229.2 (9 Oct 2006 22:41:24 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 9 Oct 2006 22:41:24 +0000 (UTC) Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Oct 10 00:41:21 2006 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by ciao.gmane.org with esmtp (Exim 4.43) id 1GX3nv-0002HM-VV for geh-help-gnu-emacs@m.gmane.org; Tue, 10 Oct 2006 00:41:00 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1GX3nv-0007Se-EP for geh-help-gnu-emacs@m.gmane.org; Mon, 09 Oct 2006 18:40:59 -0400 Original-Path: shelby.stanford.edu!newsfeed.stanford.edu!headwall.stanford.edu!newsfeed.news2me.com!newsfeed.icl.net!newsfeed.freenet.de!newsfeed01.chello.at!newsfeed.arcor.de!newsspool1.arcor-online.net!news.arcor.de.POSTED!not-for-mail Original-Newsgroups: gnu.emacs.help X-Face: 2FEFf>]>q>2iw=B6, xrUubRI>pR&Ml9=ao@P@i)L:\urd*t9M~y1^:+Y]'C0~{mAl`oQuAl \!3KEIp?*w`|bL5qr,H)LFO6Q=qx~iH4DN; i"; /yuIsqbLLCh/!U#X[S~(5eZ41to5f%E@'ELIi$t^ Vc\LWP@J5p^rst0+('>Er0=^1{]M9!p?&:\z]|;&=NP3AhB!B_bi^]Pfkw User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) Cancel-Lock: sha1:1RQKfcoQoQq8TW2d7HxXXmaMaFc= Original-Lines: 41 Original-NNTP-Posting-Date: 10 Oct 2006 00:21:49 CEST Original-NNTP-Posting-Host: a7cf8fb9.newsspool4.arcor-online.net Original-X-Trace: DXC=UYSC4?cfJX@=8m7nZkdN^@4IUK 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:37936 Archived-At: Ilya Zakharevich writes: > [A complimentary Cc of this posting was sent to > Stefan Monnier > ], who wrote in article : >> > How about rereading what I wrote above? "To make it useful, one needs >> > a function to count the number of parentheses in a given regular >> > expression. Is there?" >> >> `regexp-opt-depth' claims to do that. I believe the version in Emacs-CVS is >> pretty reliable. > > Thanks; still, when combining several regexps into one, one needs to > fixup backreferences. Given the horrible ELisp regexp syntax, this > requires some dirty backwacking... E.g., I'm not sure I would be able > to do it right first time (hint: the newer CPerl facification of > RegExps would do it very easy with Perl regexps; much harder to do it > with ELisp...). > > Hmm, I see that at least in Elist v19, backreferences went only up to > 9; sigh... Well, this is not needed very often, one could just > > (error > "RegExp limitation hit, try to make pattern(s) with backreferences first") > > or some such. > > ------- > > Additionally, when interpolating replacement string, one should also > shift match-group references by corresponding amount; but this is > easier done in the code of interpolator (I hope it is in ELisp, not in > C). Your quoting does not make it clear who wrote what. Anyway, you could just use match-data, nthcdr, set-match-data and some other stuff to just shift the match data appropriately before performing the replacement. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum