From mboxrd@z Thu Jan 1 00:00:00 1970 Path: main.gmane.org!not-for-mail From: Andreas Schwab Newsgroups: gmane.emacs.devel Subject: Re: query-replace-regexp-eval is quite nice, but... Date: Mon, 02 Feb 2004 11:24:34 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: References: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: sea.gmane.org 1075718537 30720 80.91.224.253 (2 Feb 2004 10:42:17 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 2 Feb 2004 10:42:17 +0000 (UTC) Cc: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Mon Feb 02 11:42:10 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 1AnbWs-0001SE-00 for ; Mon, 02 Feb 2004 11:42:10 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1AnbWs-0003vi-00 for ; Mon, 02 Feb 2004 11:42:10 +0100 Original-Received: from localhost ([127.0.0.1] helo=monty-python.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AnbSn-00052Z-1k for emacs-devel@quimby.gnus.org; Mon, 02 Feb 2004 05:37:57 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AnbSe-00051v-TL for emacs-devel@gnu.org; Mon, 02 Feb 2004 05:37:48 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AnbR3-0004ds-Nj for emacs-devel@gnu.org; Mon, 02 Feb 2004 05:36:41 -0500 Original-Received: from [195.135.220.2] (helo=Cantor.suse.de) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.24) id 1AnbQU-0003x0-K7; Mon, 02 Feb 2004 05:35:34 -0500 Original-Received: from Hermes.suse.de (Hermes.suse.de [195.135.221.8]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (No client certificate requested) by Cantor.suse.de (Postfix) with ESMTP id 3592010C61E; Mon, 2 Feb 2004 11:24:36 +0100 (CET) Original-Received: by sykes.suse.de (Postfix, from userid 597) id C2D8815B7A2AF; Mon, 2 Feb 2004 11:24:35 +0100 (CET) Original-To: David Kastrup X-Yow: I'm not available for comment.. In-Reply-To: (David Kastrup's message of "02 Feb 2004 09:53:08 +0100") User-Agent: Gnus/5.1006 (Gnus v5.10.6) Emacs/21.3.50 (gnu/linux) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.2 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:19646 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:19646 David Kastrup writes: > The description tells us > > [...] > > TO-EXPR is a Lisp expression evaluated to compute each > replacement. It may reference `replace-count' to get the number > of replacements already made. If the result of TO-EXPR is not a > string, it is converted to one using `prin1-to-string' with the > NOESCAPE argument (which see). > > For convenience, when entering TO-EXPR interactively, you can use > `\&' or `\0' to stand for whatever matched the whole of REGEXP, > and `\N' (where N is a digit) to stand for whatever matched the > Nth `\(...\)' in REGEXP. Use `\#&' or `\#N' if you want a number > instead of a string. > > So the idea is to build your replacement string with Lisp, and this > is quite an excellent thing. It is completely defeated because the > replacement is then done non-literally. Which means that if > \0 > would have matched \footnote, replacing the string just with \0 (which > one would expect to do nothing in effect) will barf because the > regexp replacer will not know what \f is supposed to be. I agree this is a bug. > Is there anybody that would make a case for a non-literal > replacement? If not, is there anybody with enough of a clue to find > out how to fix this? I have taken a look at perform-replace, but it > does not seem to offer an option for literal replacement for > regexps. Should we add one? Currently, perform-replace uses literal replacement for all non-regexp searches, and non-literal otherwise. What we could do is offer a special version of match-string that quotes backslashes and use that in replace-match-string-symbols. Andreas. -- Andreas Schwab, SuSE Labs, schwab@suse.de SuSE Linux AG, Maxfeldstraße 5, 90409 Nürnberg, Germany Key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5 "And now for something completely different."