From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#31492: 26.1; query-replace-regexp undo fails in regexps w/o printable chars Date: Sat, 19 May 2018 10:50:30 +0300 Message-ID: <83zi0wgk3d.fsf@gnu.org> References: <8736yp14c7.fsf@gmail.com> <838t8hhwwu.fsf@gnu.org> <837eo1huji.fsf@gnu.org> Reply-To: Eli Zaretskii NNTP-Posting-Host: blaine.gmane.org X-Trace: blaine.gmane.org 1526716148 20508 195.159.176.226 (19 May 2018 07:49:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 19 May 2018 07:49:08 +0000 (UTC) Cc: 31492@debbugs.gnu.org To: Tino Calancha Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat May 19 09:49:04 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fJwbu-00056d-86 for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 May 2018 09:49:02 +0200 Original-Received: from localhost ([::1]:42137 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fJwdz-0002EW-Tv for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 May 2018 03:51:11 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fJwdt-0002ER-AH for bug-gnu-emacs@gnu.org; Sat, 19 May 2018 03:51:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fJwdq-0002PS-8D for bug-gnu-emacs@gnu.org; Sat, 19 May 2018 03:51:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:60771) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fJwdq-0002PM-3g for bug-gnu-emacs@gnu.org; Sat, 19 May 2018 03:51:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fJwdp-0004Cf-Sp for bug-gnu-emacs@gnu.org; Sat, 19 May 2018 03:51:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 May 2018 07:51:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 31492 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 31492-submit@debbugs.gnu.org id=B31492.152671624316133 (code B ref 31492); Sat, 19 May 2018 07:51:01 +0000 Original-Received: (at 31492) by debbugs.gnu.org; 19 May 2018 07:50:43 +0000 Original-Received: from localhost ([127.0.0.1]:40435 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fJwdW-0004C9-Tc for submit@debbugs.gnu.org; Sat, 19 May 2018 03:50:43 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:43756) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fJwdV-0004Bx-Eu for 31492@debbugs.gnu.org; Sat, 19 May 2018 03:50:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fJwdN-0002K4-85 for 31492@debbugs.gnu.org; Sat, 19 May 2018 03:50:36 -0400 Original-Received: from fencepost.gnu.org ([2001:4830:134:3::e]:42314) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fJwdM-0002Jz-Vq; Sat, 19 May 2018 03:50:33 -0400 Original-Received: from [176.228.60.248] (port=1617 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1fJwdM-0000Ih-B1; Sat, 19 May 2018 03:50:32 -0400 In-reply-to: (message from Tino Calancha on Sat, 19 May 2018 10:46:10 +0900 (JST)) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.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: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:146285 Archived-At: > From: Tino Calancha > Date: Sat, 19 May 2018 10:46:10 +0900 (JST) > cc: Tino Calancha , 31492@debbugs.gnu.org > > The correct recipe is: > > M-< > C-M-% \b RET foo RET SPC SPC > U > ;; All 'foo' keep there :-( Thanks, I see the problem now. However, isn't the root cause in replace--push-stack? The relevant element of the replacement stack (whose structure, btw, seems not to be documented anywhere), is (4 4 *scratch*), whereas I'd expect to see (1 4 *scratch) instead, because the replacement was at position 1; then setting match-data from this would DTRT. IOW, I'm afraid the looking-back solution is ad-hoc, and might not work in general, because the real problem is elsewhere. WDYT? > This happen because the regexp "\b" has any printable character. Why does it matter for \b to match a non-empty string? The undo-all command matches text against the _replacement_ string, not against the original search string. And the replacement string, "foo", is not empty. The problem here, AFAICT, is that we are looking for it in the wrong place, and that happens because the replacement stack tells us to look at position 4 instead of position 1. Right? > If we try instead: > > M-< > C-M-% is\b RET foo RET SPC SPC > U > ;; Now all 'foo' are gone :-) Yes, because in this case the replacement stack has the correct data.