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: query-replace-regexp-eval is quite nice, but... Date: 02 Feb 2004 09:53:08 +0100 Sender: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Message-ID: NNTP-Posting-Host: deer.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1075714346 22618 80.91.224.253 (2 Feb 2004 09:32:26 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Mon, 2 Feb 2004 09:32:26 +0000 (UTC) Original-X-From: emacs-devel-bounces+emacs-devel=quimby.gnus.org@gnu.org Mon Feb 02 10:32:19 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 1AnaRH-0006Iq-00 for ; Mon, 02 Feb 2004 10:32:19 +0100 Original-Received: from monty-python.gnu.org ([199.232.76.173]) by quimby.gnus.org with esmtp (Exim 3.35 #1 (Debian)) id 1AnaRH-0002JQ-00 for ; Mon, 02 Feb 2004 10:32:19 +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 1AnaLd-00083D-Cs for emacs-devel@quimby.gnus.org; Mon, 02 Feb 2004 04:26:29 -0500 Original-Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.24) id 1AnaKw-00080x-N6 for emacs-devel@gnu.org; Mon, 02 Feb 2004 04:25:46 -0500 Original-Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.24) id 1AnaKQ-0007qf-Tz for emacs-devel@gnu.org; Mon, 02 Feb 2004 04:25:45 -0500 Original-Received: from [199.232.76.164] (helo=fencepost.gnu.org) by monty-python.gnu.org with esmtp (Exim 4.24) id 1AnaIQ-0007Fp-R5 for emacs-devel@gnu.org; Mon, 02 Feb 2004 04:23:10 -0500 Original-Received: from fencepost.gnu.org ([127.0.0.1] helo=lola.goethe.zz) by fencepost.gnu.org with esmtp (Exim 4.24) id 1AnaHA-0002vf-Sx for emacs-devel@gnu.org; Mon, 02 Feb 2004 04:21:53 -0500 Original-To: emacs-devel@gnu.org Original-Lines: 33 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:19644 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:19644 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. 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? -- David Kastrup, Kriemhildstr. 15, 44793 Bochum