From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#67124: 26.3; query-replace Arg out of range with comma option (at end-buffer) Date: Thu, 16 Nov 2023 18:56:00 +0200 Message-ID: <83jzqhprhb.fsf@gnu.org> References: <020a72b2-b896-4ecf-abab-111a6c1c9eac@medialab.sissa.it> <83cywfuwta.fsf@gnu.org> <83pm0du49e.fsf@gnu.org> <83o7ftpx1w.fsf@gnu.org> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="28721"; mail-complaints-to="usenet@ciao.gmane.io" Cc: gabriele@medialab.sissa.it, 67124@debbugs.gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 16 17:57:20 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r3fg5-0007CD-6Z for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 16 Nov 2023 17:57:17 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r3ffs-0007O4-Te; Thu, 16 Nov 2023 11:57:04 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r3ffq-0007Nd-9U for bug-gnu-emacs@gnu.org; Thu, 16 Nov 2023 11:57:03 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1r3ffq-0004s2-15 for bug-gnu-emacs@gnu.org; Thu, 16 Nov 2023 11:57:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1r3ffp-0001iu-Jz for bug-gnu-emacs@gnu.org; Thu, 16 Nov 2023 11:57:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 16 Nov 2023 16:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 67124 X-GNU-PR-Package: emacs Original-Received: via spool by 67124-submit@debbugs.gnu.org id=B67124.17001537756568 (code B ref 67124); Thu, 16 Nov 2023 16:57:01 +0000 Original-Received: (at 67124) by debbugs.gnu.org; 16 Nov 2023 16:56:15 +0000 Original-Received: from localhost ([127.0.0.1]:57507 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r3ff4-0001hs-MQ for submit@debbugs.gnu.org; Thu, 16 Nov 2023 11:56:15 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56572) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1r3ff2-0001hf-Ms for 67124@debbugs.gnu.org; Thu, 16 Nov 2023 11:56:13 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r3fex-0004j0-9t; Thu, 16 Nov 2023 11:56:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=5UHBzteAXGjV77DZu8WZJvfqBL+eJrC6ymmpMLN1XJY=; b=VW5SrV5h5CMi qZPg3Rkikm9NB0UJdmgGE/ivYGjLmkXQFguGNnFHPW5zFRbI1bTEfKjYv2Hvr2zWtOO1NyOr9JO3e ZFJjIvci+kx5nk1TYal3zF/KPMW+zIWJb0mPBQOk0FTZEkps/js/mjJ9mD+YKH6U2awq9FhJTurTX R/Viv3CRdBnDz/V5/NHtGvEvMPWVv8HjRF0y57RAhROKbnd5sTOTSENWUGWG3KuRBha37QA/SLJPY l9Gbgo3i0ppda4n/j9zKNPqb3WQPun2TOYGhVRZ87Sk9leGzRDyG7zThkvJUZfsz5bDK7+d6Os/ZC aYlKCYB3A7w82sCwSPZBFQ==; In-Reply-To: (message from Stefan Monnier on Thu, 16 Nov 2023 11:15:56 -0500) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:274472 Archived-At: > From: Stefan Monnier > Cc: gabriele@medialab.sissa.it, 67124@debbugs.gnu.org > Date: Thu, 16 Nov 2023 11:15:56 -0500 > > > What are you trying to understand? > > Why you're saying that in > > ;; `replace-match' leaves point at the end of the replacement text, > ;; so move point to the beginning when replacing backward. > (when backward (goto-char (nth 0 match-data))) > > it is not true that > > and (nth 0 match-data) == (match-beginning 0), no? Because of markers vs positions, as I've tried to explain. The difference is minor, of course. > > What my kludge did is simply use a marker, so the adjusted position is > > not clobbered. > > I don't see that. E.g. if you change your code from > > (set-match-data (list (car match-data) (nth 1 (match-data)))) > to > (set-match-data (list (car match-data) (nth 1 (match-data t)))) > > it fixes the problem just as well, AFAICT. Yes, but match-data (the function) returns updated positions, which behave like markers across the replace-match call. > My understand is that what you patch does is use the match end as > adjusted by `replace-match` rather than the match end as provided by the > `match-end` argument (because that argument contains integers and hence > ends up pointing to the wrong place after the buffer was modified by > `replace-match`). Yes. > Basically, the purpose of the above `set-match-data` originally was to > correct the (match-beginning 0) info because `replace-match` adjusted it > incorrectly (i.e. it works around a bug in `update_search_regs`), but > while doing that it ended up messing up the (match-end 0), so your patch > refines that code so as to leave (match-end 0) unchanged while > correcting (match-beginning 0). Yes.