From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Lawrence Mitchell Newsgroups: gmane.emacs.bugs Subject: bug#8161: 24.0.50; query-replace-regexp fails with interactive replacement text Date: Thu, 03 Mar 2011 16:21:47 +0000 Message-ID: References: <20110303005937.1804abf6@bhishma.homelinux.net> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: dough.gmane.org 1299170238 14699 80.91.229.12 (3 Mar 2011 16:37:18 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Thu, 3 Mar 2011 16:37:18 +0000 (UTC) To: bug-gnu-emacs@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Thu Mar 03 17:37:14 2011 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1PvBWb-0008JQ-NZ for geb-bug-gnu-emacs@m.gmane.org; Thu, 03 Mar 2011 17:37:14 +0100 Original-Received: from localhost ([127.0.0.1]:54494 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PvBWb-0001O2-2G for geb-bug-gnu-emacs@m.gmane.org; Thu, 03 Mar 2011 11:37:13 -0500 Original-Received: from [140.186.70.92] (port=33594 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PvBWM-0001Iw-JY for bug-gnu-emacs@gnu.org; Thu, 03 Mar 2011 11:37:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PvBWH-0007dB-Ba for bug-gnu-emacs@gnu.org; Thu, 03 Mar 2011 11:36:58 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:46541) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PvBWH-0007d6-9k for bug-gnu-emacs@gnu.org; Thu, 03 Mar 2011 11:36:53 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.69) (envelope-from ) id 1PvBIs-0005fk-JP; Thu, 03 Mar 2011 11:23:02 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <20110303005937.1804abf6@bhishma.homelinux.net> Resent-From: Lawrence Mitchell Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-To: owner@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 03 Mar 2011 16:23:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 8161 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by submit@debbugs.gnu.org id=B.129916934921758 (code B ref -1); Thu, 03 Mar 2011 16:23:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 3 Mar 2011 16:22:29 +0000 Original-Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PvBIK-0005er-Su for submit@debbugs.gnu.org; Thu, 03 Mar 2011 11:22:29 -0500 Original-Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1PvBII-0005ef-Oa for submit@debbugs.gnu.org; Thu, 03 Mar 2011 11:22:28 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PvBI5-0003FG-Vy for submit@debbugs.gnu.org; Thu, 03 Mar 2011 11:22:21 -0500 Original-Received: from lists.gnu.org ([199.232.76.165]:45426) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PvBI5-0003FC-Tf for submit@debbugs.gnu.org; Thu, 03 Mar 2011 11:22:13 -0500 Original-Received: from [140.186.70.92] (port=41004 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PvBI0-0003WA-Ik for bug-gnu-emacs@gnu.org; Thu, 03 Mar 2011 11:22:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PvBHv-0003C0-Dr for bug-gnu-emacs@gnu.org; Thu, 03 Mar 2011 11:22:08 -0500 Original-Received: from lo.gmane.org ([80.91.229.12]:49240) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PvBHv-0003Bg-2J for bug-gnu-emacs@gnu.org; Thu, 03 Mar 2011 11:22:03 -0500 Original-Received: from list by lo.gmane.org with local (Exim 4.69) (envelope-from ) id 1PvBHt-0008FU-U5 for bug-gnu-emacs@gnu.org; Thu, 03 Mar 2011 17:22:01 +0100 Original-Received: from e4300lm.epcc.ed.ac.uk ([129.215.63.156]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 03 Mar 2011 17:22:01 +0100 Original-Received: from wence by e4300lm.epcc.ed.ac.uk with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 03 Mar 2011 17:22:01 +0100 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 60 Original-X-Complaints-To: usenet@dough.gmane.org X-Gmane-NNTP-Posting-Host: e4300lm.epcc.ed.ac.uk User-Agent: Gnus/5.110012 (No Gnus v0.12) Emacs/24.0.50 (gnu/linux) Cancel-Lock: sha1:cHafB3doPJrJq2lLclokLo97jcs= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list Resent-Date: Thu, 03 Mar 2011 11:23:02 -0500 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:44580 Archived-At: Suvayu Ali wrote: > Hi Emacs devs, > I wanted to replace interactively all numbers in the text of an document > with the number in words, so I tried: > `C-M-% [0-9]+ RET \? RET' > But this gives me an error like this: >> Debugger entered--Lisp error: (error "Invalid use of `\\' in >> replacement text") replace-match("\\?" nil nil #("1" 0 1 (fontified >> t)) nil) match-substitute-replacement("\\?" nil nil) >> perform-replace("[0-9]+" "\\?" t t nil nil nil nil nil) >> query-replace-regexp("[0-9]+" "\\?" nil nil nil) >> call-interactively(query-replace-regexp nil nil) > Since the doc string of `query-replace-regexp' says the following: This has been broken since Author: Juri Linkov Date: Sat Nov 10 21:48:46 2007 +0000 (query-replace-show-replacement): New defcustom. (perform-replace): Use `match-substitute-replacement' if `query-replace-show-replacement' is non-nil. replace-match (used by match-substitute-replacement) doesn't know about \? and therefore barfs. This patch just passes \\? unchanged through replace-match. I'm not sure if this is a reasonable fix, although minimal testing suggests it all works correctly. diff --git a/src/search.c b/src/search.c index 1e2036f..c9fd71b 100644 --- a/src/search.c +++ b/src/search.c @@ -2373,6 +2373,7 @@ Otherwise treat `\\' as special: `\\N' means substitute what matched the Nth `\\(...\\)'. If Nth parens didn't match, substitute nothing. `\\\\' means insert one `\\'. + `\\?' (as in `query-replace-regexp') is passed through unchanged. Case conversion does not apply to these substitutions. FIXEDCASE and LITERAL are optional arguments. @@ -2575,6 +2576,8 @@ since only regular expressions have distinguished subexpressions. */) } else if (c == '\\') delbackslash = 1; + else if (c == '?') + ; /* do nothing (dealt with at lisp level) */ else error ("Invalid use of `\\' in replacement text"); } Lawrence -- Lawrence Mitchell