From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: David Kastrup Newsgroups: gmane.emacs.devel Subject: Re: query-replace-interactive not documented Date: 16 Jun 2004 11:01:13 +0200 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: <20040528.181649.25475113.wl@gnu.org> <200405291737.i4THbPJ06689@raven.dms.auburn.edu> <873c5jug73.fsf@mail.jurta.org> <87oenqa4lu.fsf@mail.jurta.org> <873c51w5rq.fsf@mail.jurta.org> <87659snbd8.fsf@mail.jurta.org> <878yeoadpd.fsf@mail.jurta.org> <87smcvex2v.fsf@mail.jurta.org> NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1087376530 3771 80.91.224.253 (16 Jun 2004 09:02:10 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 16 Jun 2004 09:02:10 +0000 (UTC) Cc: Andreas Schwab , emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Wed Jun 16 11:01:57 2004 Return-path: Original-Received: from quimby.gnus.org ([80.91.224.244]) by deer.gmane.org with esmtp (Exim 3.35 #1 (Debian)) id 1BaWIv-0007Gw-00 for ; Wed, 16 Jun 2004 11:01:57 +0200 Original-Received: from lists.gnu.org ([199.232.76.165]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1BaWIv-0007hR-00 for ; Wed, 16 Jun 2004 11:01:57 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BaWJu-0007bj-0e for emacs-devel@quimby.gnus.org; Wed, 16 Jun 2004 05:02:58 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.33) id 1BaWJS-0007QA-Qy for emacs-devel@gnu.org; Wed, 16 Jun 2004 05:02:30 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.33) id 1BaWJR-0007Pf-Ai for emacs-devel@gnu.org; Wed, 16 Jun 2004 05:02:30 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.33) id 1BaWJR-0007Pc-80 for emacs-devel@gnu.org; Wed, 16 Jun 2004 05:02:29 -0400 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.34) id 1BaWIH-0002Kl-2c for emacs-devel@gnu.org; Wed, 16 Jun 2004 05:01:17 -0400 Original-Received: from localhost ([127.0.0.1] helo=lola.goethe.zz) by fencepost.gnu.org with esmtp (Exim 4.34) id 1BaWIG-00081A-7u; Wed, 16 Jun 2004 05:01:16 -0400 Original-To: Juri Linkov In-Reply-To: <87smcvex2v.fsf@mail.jurta.org> Original-Lines: 32 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Xref: main.gmane.org gmane.emacs.devel:25024 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:25024 Juri Linkov writes: > Andreas Schwab writes: > >> + (if (string-match "\\\\'" to-string) > >> + (let (to expr) > >> + (while (string-match "\\\\'" to-string) > > > > That needs more careful treatment, to handle cases like "\\\\'" where one > > wants to substitute a backslash followed by a single quote. > > It seems the regexp from David's version handles it right: > > (string-match "\\(\\`\\|[^\\]\\)\\(\\\\\\\\\\)*\\\\`") > > Do you see any problems with it? Somebody has a pattern matching problem. He says "I know, I'll use regular expressions for it". Now he has two problems. SCNR. In short: it is not beautiful, but I don't see how this could be improved. And a problem with the above is that \` only matches at position 0 of a string, not at the point where you start matching. So you need to explicitly digest the string with "substring" while parsing to keep this working. Perhaps the starting index of a string match should match on \= in analogy to the "starting index" of a buffer match? But that's just an aside note. -- David Kastrup, Kriemhildstr. 15, 44793 Bochum