From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha 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 23:28:35 +0900 Message-ID: <87tvr3zpm4.fsf@gmail.com> References: <8736yp14c7.fsf@gmail.com> <838t8hhwwu.fsf@gnu.org> <837eo1huji.fsf@gnu.org> <83zi0wgk3d.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1526740030 9517 195.159.176.226 (19 May 2018 14:27:10 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sat, 19 May 2018 14:27:10 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 31492@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat May 19 16:27:05 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 1fK2p6-0002Jm-IJ for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 May 2018 16:27:04 +0200 Original-Received: from localhost ([::1]:43329 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fK2rB-0004nO-Tn for geb-bug-gnu-emacs@m.gmane.org; Sat, 19 May 2018 10:29:13 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:54968) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fK2r3-0004m5-5b for bug-gnu-emacs@gnu.org; Sat, 19 May 2018 10:29:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fK2r0-00011o-1F for bug-gnu-emacs@gnu.org; Sat, 19 May 2018 10:29:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:33253) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fK2qz-00011e-T9 for bug-gnu-emacs@gnu.org; Sat, 19 May 2018 10:29:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1fK2qz-0000k2-KK for bug-gnu-emacs@gnu.org; Sat, 19 May 2018 10:29:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Tino Calancha Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 19 May 2018 14:29: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.15267401272831 (code B ref 31492); Sat, 19 May 2018 14:29:01 +0000 Original-Received: (at 31492) by debbugs.gnu.org; 19 May 2018 14:28:47 +0000 Original-Received: from localhost ([127.0.0.1]:41150 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fK2ql-0000jZ-CX for submit@debbugs.gnu.org; Sat, 19 May 2018 10:28:47 -0400 Original-Received: from mail-pl0-f44.google.com ([209.85.160.44]:40945) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fK2qk-0000jO-65 for 31492@debbugs.gnu.org; Sat, 19 May 2018 10:28:46 -0400 Original-Received: by mail-pl0-f44.google.com with SMTP id t12-v6so6232201plo.7 for <31492@debbugs.gnu.org>; Sat, 19 May 2018 07:28:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=MbaGwwT1UHsNpr5fxK7vuW9Lm01luXhQ7ftnZXaQocw=; b=n2h4qxFna32RAfUsV7h4UsRxRlZ1ImsI3sCgu4EewhtdGGIyjKcxxp64uSemC7+EdZ fH4i0H8JvcUzguIun0NlKnwfkDENl1Ia5A1/IRYWxGe20OzsbEiRet+uUkYW0MkNW6/c 5l4FifRUj62culwg1usMYZrgpBRw3K/nJ3GygmrHfKr5EQyWJ96jNIVgB0iu1ZFt+bpG SMlt8ZxETq6zMxEwNF3KKhPAXIMKB6sfAApOn2FdRRAXQ+P3yCoQZTk6ixmC/zCHUDr7 uQnWWCVFWcZdcpfeLZRHhx1qCVvsORCBd7/tW4e14PBnLMRGkRrww/+R18QWXWOo5Tz5 NanA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=MbaGwwT1UHsNpr5fxK7vuW9Lm01luXhQ7ftnZXaQocw=; b=kezKqdpmGLS61I8ca9OAyOBnHnjI6r+ZJGnb4cZ2P+74RM34M1zwnw7qU4wrRx0Kmm icnxAulq33fmi+IJmtY37Hw/PPhiryWbPfnw4NWz9UNwSiFkMNLO0JlZQGeluQAPvy8e jtfRcnQVs6EOpachQ2I3GxbVNq1wT8EngbdrvRQC/6XILlHklIiiGJXGDFrd5kaPlDu9 f6lgBER3rj0eQlZza/vRZ7vtq43zgd8Upty+WDgF0zjcC7LaIcyqwZ2LUl3T3M12koYU TuTIOTRtOYdBou83enSUw/knb6LEMSeab4xta4dCl4g/HM4sJSApjTtEaFCfP2O9UC/5 Cxdg== X-Gm-Message-State: ALKqPwecOx7Q6X9SD9cpyxdfeesYd+koKNdK7bUjoWbmBnFozCXkOnH8 mPHJX4Sghjeb5QXB47YnJwwNzw== X-Google-Smtp-Source: AB8JxZrwv2J2kBIaDlk3jt1xpgUneKLt/VR0x9uoLouVtxuqogGbBiw5Vyretzaps186+AISmVbOrg== X-Received: by 2002:a17:902:8a95:: with SMTP id p21-v6mr13911840plo.325.1526740120224; Sat, 19 May 2018 07:28:40 -0700 (PDT) Original-Received: from calancha-pc (228.225.128.101.dy.bbexcite.jp. [101.128.225.228]) by smtp.gmail.com with ESMTPSA id m11-v6sm12570433pgv.48.2018.05.19.07.28.38 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 19 May 2018 07:28:39 -0700 (PDT) In-Reply-To: <83zi0wgk3d.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 19 May 2018 10:50:30 +0300") 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:146293 Archived-At: Eli Zaretskii writes: > Thanks, I see the problem now. > > However, isn't the root cause in replace--push-stack? I am not sure; there is something else (see below). > 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. Yes, that is the logic. The thing is, for some unknown reason to me, the reported match-data is inexact when there are no printable chars in the regexp (maybe it's expected and I am wrong on my assumptions). > IOW, I'm afraid the looking-back solution is ad-hoc, and might not > work in general, because the real problem is elsewhere. WDYT? Look what happen in these examples: (with-temp-buffer (insert "foo") (goto-char 1) (progn (re-search-forward "o$" nil t) (save-match-data (replace-match "oZZZ")) (list (point) (match-beginning 0) (match-end 0)))) => (7 3 7) ;; Now, a regexp with no printable chars (with-temp-buffer (insert "foo") (goto-char 1) (progn (re-search-forward "$" nil t) (save-match-data (replace-match "ZZZ")) (list (point) (match-beginning 0) (match-end 0)))) => (7 7 7) ;; If this would be (7 4 7), then we could use `looking-at'; we are to ;; the right of the replacement, then we use `looking-back'. ;; But the match was at 4 not at 7 (with-temp-buffer (insert "foo") (goto-char 1) (progn (re-search-forward "$" nil t) (list (point) (match-beginning 0) (match-end 0)))) => (4 4 4) ;; We lost the information about the beginning of the match when ;; the regexps lack of printable characters.