GNU bug report logs - #42424
27.0.90; replace-match: point is NOT left at the end of replacement

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Ren Victor <victorhge@HIDDEN>; dated Sun, 19 Jul 2020 05:53:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 42424 <at> debbugs.gnu.org:


Received: (at 42424) by debbugs.gnu.org; 18 Oct 2020 08:24:32 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Oct 18 04:24:32 2020
Received: from localhost ([127.0.0.1]:36145 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kU3zU-0006Ux-7z
	for submit <at> debbugs.gnu.org; Sun, 18 Oct 2020 04:24:32 -0400
Received: from quimby.gnus.org ([95.216.78.240]:48792)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1kU3zS-0006Uk-7q
 for 42424 <at> debbugs.gnu.org; Sun, 18 Oct 2020 04:24:30 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=PK6CNu/Xy70A+DFTULuAJElasrx1T0ENXc9pwWN47GU=; b=iQ8tmsceItKafNHISSGLJjf4p6
 M2P6D92vn0npnzfXbFZnglAk59Sm6q5khjxnooGJMgx04BXmFJNKGN7avUfTmeYIKaKG7vCv0nSjc
 bYN7GX6T51L9Z2pla1/mi4YYW/yws8eB/FR89ljqVqqMLGKn8XZSeCfhr1kmtrnrtIcg=;
Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1kU3zJ-0006PN-75; Sun, 18 Oct 2020 10:24:23 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#42424: 27.0.90; replace-match: point is NOT left at the end
 of replacement
References: <CAMks0JH0N=BAEjBnGrU-jfT=aryrC4jEZDOuJMxAd5N3UpSVbg@HIDDEN>
 <87zh4ltc5l.fsf@HIDDEN> <83tuussr1v.fsf@HIDDEN>
Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAABGdBTUEAALGPC/xhBQAAACBj
 SFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAFVBMVEVDNUhYT2KHdIYf
 GCT0zK+oXWX////KAn60AAAAAWJLR0QGYWa4fQAAAAd0SU1FB+QKEgciIGgyBOwAAAG7SURBVDjL
 XZRBcsMgDEWlquzBHvY2SfakTA/Qjr13Oub+V6mEwNAyWWT0pP9BCAMAoHV1TZQSB6z8Iv+BC9yS
 LECnoFVMISRdkg14FTgXbqmhCBYHsAzAdXMX1g6InTq4UwMp4VhxXzqA0eP+TQ1E7CCE+zZ386sk
 CLhdQCuwgu/5OmIBVk4Z2GNu5qjnsKI3jQcEBQQqlkYgyaCdWUZQmkjFy7awycXcWqBS0uJ+24oU
 WydJqDuKHFeA5V7AaTfAnwr6BZd05/N2ASpAlPBV8qsUJQHISv5lNN5AqWPXPNd4ATMUQNHl/Lnl
 LkUVPH0+TB6kSDdFbz4TXlLcQQUoIJpt8KCyW5yRwXsHFitIi8/QAceoaGGyJhszANSOTOTM8e4H
 DwbiFGg1x3mMB+Qbj8iPZkV77gOQKREaA1q//QM8IPNHsHB5XyC4eXossfV2yxVMqyOew96RrHfq
 pgViCKuFP8AKwGd4vJz1/yr4UcXw+Fmduu/b0QDPFLKWU5PcgeMR4We+Kjh3HajyDig9xV7BVywf
 DlAgYk7c9/OQgUYlc5m2qQJTkgWgTnpEnsM9v7wagzyoOtEK8i+W2o66dNtRxAAAACV0RVh0ZGF0
 ZTpjcmVhdGUAMjAyMC0xMC0xOFQwNzozNDozMiswMDowMGkk31EAAAAldEVYdGRhdGU6bW9kaWZ5
 ADIwMjAtMTAtMThUMDc6MzQ6MzIrMDA6MDAYeWftAAAAAElFTkSuQmCC
X-Now-Playing: Rocket To The Sky's _Cigars_: "Cigars"
Date: Sun, 18 Oct 2020 10:24:19 +0200
In-Reply-To: <83tuussr1v.fsf@HIDDEN> (Eli Zaretskii's message of "Sat, 17 Oct
 2020 20:25:32 +0300")
Message-ID: <87tuusj618.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: Eli Zaretskii <eliz@HIDDEN> writes: >> Uhm... is that
 comment
 wrong? Aren't we moving point to the end of the >> inserted replacement?
 > > Yes, it should say "end", not "start". Fixed now. 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 42424
Cc: 42424 <at> debbugs.gnu.org, victorhge@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Eli Zaretskii <eliz@HIDDEN> writes:

>> Uhm...  is that comment wrong?  Aren't we moving point to the end of the
>> inserted replacement?
>
> Yes, it should say "end", not "start".

Fixed now.

> Personally, I wonder what was expected here.  If the modification
> hooks modify the replaced text behind our back, how can the Lisp
> program which does that expect to have point where it belongs?  Am I
> missing something?

No, the semantics are pretty unclear, and it's not obvious whether we
can guarantee anything here.  But the bug reporter notes:

> Other types of modification (insert or delete) do not have this issue.
> `point' is adjusted before running modification hooks.

So I think the suggestion is to move point to the end of the replacement
before running the modification hooks, i.e., move the point logic to
replace_range.  But I'm not actually sure where the modification hooks
are being run from...

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#42424; Package emacs. Full text available.

Message received at 42424 <at> debbugs.gnu.org:


Received: (at 42424) by debbugs.gnu.org; 17 Oct 2020 17:25:43 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 17 13:25:43 2020
Received: from localhost ([127.0.0.1]:35459 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kTpxf-0001XK-D5
	for submit <at> debbugs.gnu.org; Sat, 17 Oct 2020 13:25:43 -0400
Received: from eggs.gnu.org ([209.51.188.92]:58150)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1kTpxd-0001X5-2m
 for 42424 <at> debbugs.gnu.org; Sat, 17 Oct 2020 13:25:42 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:58803)
 by eggs.gnu.org with esmtp (Exim 4.90_1)
 (envelope-from <eliz@HIDDEN>)
 id 1kTpxX-0000Q1-9T; Sat, 17 Oct 2020 13:25:35 -0400
Received: from [176.228.60.248] (port=2103 helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.82) (envelope-from <eliz@HIDDEN>)
 id 1kTpxV-00081f-54; Sat, 17 Oct 2020 13:25:34 -0400
Date: Sat, 17 Oct 2020 20:25:32 +0300
Message-Id: <83tuussr1v.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Lars Ingebrigtsen <larsi@HIDDEN>
In-Reply-To: <87zh4ltc5l.fsf@HIDDEN> (message from Lars Ingebrigtsen on Sat, 
 17 Oct 2020 11:49:42 +0200)
Subject: Re: bug#42424: 27.0.90;
 replace-match: point is NOT left at the end of replacement
References: <CAMks0JH0N=BAEjBnGrU-jfT=aryrC4jEZDOuJMxAd5N3UpSVbg@HIDDEN>
 <87zh4ltc5l.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 42424
Cc: 42424 <at> debbugs.gnu.org, victorhge@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Lars Ingebrigtsen <larsi@HIDDEN>
> Date: Sat, 17 Oct 2020 11:49:42 +0200
> Cc: 42424 <at> debbugs.gnu.org
> 
>   /* Put point back where it was in the text, if possible.  */
>   TEMP_SET_PT (clip_to_bounds (BEGV, opoint + (opoint <= 0 ? ZV : 0), ZV));
>   /* Now move point "officially" to the start of the inserted replacement.  */
>   move_if_not_intangible (newpoint);
> 
> Uhm...  is that comment wrong?  Aren't we moving point to the end of the
> inserted replacement?

Yes, it should say "end", not "start".

>   /* The replace_range etc. functions can trigger modification hooks
>      (see signal_before_change and signal_after_change).  Try to error
>      out if these hooks clobber the match data since clobbering can
>      result in confusing bugs.  Although this sanity check does not
>      catch all possible clobberings, it should catch many of them.  */
>   if (! (search_regs.num_regs == num_regs
> 	 && search_regs.start[sub] == newstart
> 	 && search_regs.end[sub] == newpoint))
>     error ("Match data clobbered by buffer modification hooks");
> 
> So replace_match is already signalling some errors on buffer
> modification hooks, but not here.  So is this a bug or just something
> that should be documented better?

Personally, I wonder what was expected here.  If the modification
hooks modify the replaced text behind our back, how can the Lisp
program which does that expect to have point where it belongs?  Am I
missing something?




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#42424; Package emacs. Full text available.

Message received at 42424 <at> debbugs.gnu.org:


Received: (at 42424) by debbugs.gnu.org; 17 Oct 2020 09:49:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 17 05:49:55 2020
Received: from localhost ([127.0.0.1]:33362 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1kTiqZ-0002Oc-9A
	for submit <at> debbugs.gnu.org; Sat, 17 Oct 2020 05:49:55 -0400
Received: from quimby.gnus.org ([95.216.78.240]:38346)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <larsi@HIDDEN>) id 1kTiqX-0002OO-Af
 for 42424 <at> debbugs.gnu.org; Sat, 17 Oct 2020 05:49:53 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org;
 s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date:
 References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:
 Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender:
 Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:
 List-Subscribe:List-Post:List-Owner:List-Archive;
 bh=nhHZ1pGYzn9tEhB71/lvc+a5OlFoTw/u30iAzKFmceQ=; b=Z9Jr/h5OXqFWntt2sE1GEmOZlP
 7iYmjjrFR52s1I0Mtr+wLdQ1Bjcn8867KDDPzqCYJUpuVhMGXxTj5FzGraoLjMhL5MmT20s9thAAu
 BZ7ya7JBbprzA1mSnZTp0fTPHvKzdoa/Scak51MWL+gtNXtfiHRlVBCbFIIyHqbjaf24=;
Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo)
 by quimby.gnus.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.92) (envelope-from <larsi@HIDDEN>)
 id 1kTiqO-0002Bt-69; Sat, 17 Oct 2020 11:49:46 +0200
From: Lars Ingebrigtsen <larsi@HIDDEN>
To: Ren Victor <victorhge@HIDDEN>
Subject: Re: bug#42424: 27.0.90; replace-match: point is NOT left at the end
 of replacement
References: <CAMks0JH0N=BAEjBnGrU-jfT=aryrC4jEZDOuJMxAd5N3UpSVbg@HIDDEN>
X-Now-Playing: Machinedrum's _Vapor City Citizenship Programme_: "Vapor City
 - Vizion Centre Mix"
Date: Sat, 17 Oct 2020 11:49:42 +0200
In-Reply-To: <CAMks0JH0N=BAEjBnGrU-jfT=aryrC4jEZDOuJMxAd5N3UpSVbg@HIDDEN>
 (Ren Victor's message of "Sun, 19 Jul 2020 13:50:51 +0800")
Message-ID: <87zh4ltc5l.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Report: Spam detection software, running on the system "quimby.gnus.org",
 has NOT identified this incoming email as spam.  The original
 message has been attached to this so you can view it or label
 similar future email.  If you have any questions, see
 @@CONTACT_ADDRESS@@ for details.
 Content preview: Ren Victor <victorhge@HIDDEN> writes: > In `replace_range',
 the point is also relocated. I am not sure why it has > to be moved again
 just before returning from `replace-match'. I can reproduce this error on
 Emacs 28. 
 Content analysis details:   (-2.9 points, 5.0 required)
 pts rule name              description
 ---- ---------------------- --------------------------------------------------
 -1.0 ALL_TRUSTED            Passed through trusted hosts only via SMTP
 -1.9 BAYES_00               BODY: Bayes spam probability is 0 to 1%
 [score: 0.0000]
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 42424
Cc: 42424 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Ren Victor <victorhge@HIDDEN> writes:

> In `replace_range', the point is also relocated.  I am not sure why it has
> to be moved again just before returning from `replace-match'.

I can reproduce this error on Emacs 28.

The problem seems to be this in Freplace_match?  

  /* Put point back where it was in the text, if possible.  */
  TEMP_SET_PT (clip_to_bounds (BEGV, opoint + (opoint <= 0 ? ZV : 0), ZV));
  /* Now move point "officially" to the start of the inserted replacement.  */
  move_if_not_intangible (newpoint);

Uhm...  is that comment wrong?  Aren't we moving point to the end of the
inserted replacement?

Anyway, removing that move makes the suggested test not fail, but it
leads to a bunch of other tests failing, so it's doing something right,
at least.

However, just before that, there's this:

  /* The replace_range etc. functions can trigger modification hooks
     (see signal_before_change and signal_after_change).  Try to error
     out if these hooks clobber the match data since clobbering can
     result in confusing bugs.  Although this sanity check does not
     catch all possible clobberings, it should catch many of them.  */
  if (! (search_regs.num_regs == num_regs
	 && search_regs.start[sub] == newstart
	 && search_regs.end[sub] == newpoint))
    error ("Match data clobbered by buffer modification hooks");

So replace_match is already signalling some errors on buffer
modification hooks, but not here.  So is this a bug or just something
that should be documented better?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#42424; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 19 Jul 2020 05:52:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jul 19 01:52:11 2020
Received: from localhost ([127.0.0.1]:59868 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1jx2F9-0001cO-Bh
	for submit <at> debbugs.gnu.org; Sun, 19 Jul 2020 01:52:11 -0400
Received: from lists.gnu.org ([209.51.188.17]:55122)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <victorhge@HIDDEN>) id 1jx2F7-0001cG-Sl
 for submit <at> debbugs.gnu.org; Sun, 19 Jul 2020 01:52:10 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:47414)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <victorhge@HIDDEN>)
 id 1jx2F7-0002w0-KD
 for bug-gnu-emacs@HIDDEN; Sun, 19 Jul 2020 01:52:09 -0400
Received: from mail-io1-xd32.google.com ([2607:f8b0:4864:20::d32]:34751)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <victorhge@HIDDEN>)
 id 1jx2F5-0000WC-Kq
 for bug-gnu-emacs@HIDDEN; Sun, 19 Jul 2020 01:52:09 -0400
Received: by mail-io1-xd32.google.com with SMTP id q74so14431921iod.1
 for <bug-gnu-emacs@HIDDEN>; Sat, 18 Jul 2020 22:52:06 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;
 h=mime-version:from:date:message-id:subject:to;
 bh=hluyL3EFDNOIPxxJBZ9RlYB4uvv+Fm0elca/nTOA9CQ=;
 b=oaPEre84GoyiyYTc/Sa4L8wjUlX0v79xkdLV5tpZ0Hi4SZj0od3oz9uxpF6hQd6HHE
 dfnuGBX1MiuLiqoFtEfQTVVsKbPwwZlTQxlJ1eDasZ80Qa4ATxeclXS5TcBnEUJYp92h
 fWBJ8ztXOnLJF9L9fKqF7quwCR+Zq48gT5BAyoBvkTPgsdyrq9ZgkvuJjILhtHrKW0wM
 IQTiv4eA0aDZ57Jx2WtbhL1qE06vntg9QGqxv1PU1Eq5fj4PdwpvMD/7RbAft/MGFPz9
 PzEo2XxxeQ+rKteTKvWvDdzgnJ/iHmWzhxKKR/RpWnTInxULQ8CKsGzCIf5Zm/58rES7
 fL0Q==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=hluyL3EFDNOIPxxJBZ9RlYB4uvv+Fm0elca/nTOA9CQ=;
 b=gZPzNfSmoHl2gWrjgi0Agl2fLQg1wabM41P8WWS9QNEthUONmE+NqpKlW+6nOBpMkA
 jhSnXPIds2sZKpr9AtVIqgL0gy4ZUzTiyfh2h81WIGoiLlk0O6qNjRKDWKy/JeH+I0dG
 YCedYTUrXOvW5cVSxQrhpT6Pq3HJyXrtUgW7Nes1rI+dVRmGa+6SPb1YKJuBGdlaCNoO
 GCJWInAWj6YxiVnH28j5Dm2TgBLn+3j0D5J7lcRXw2W9lhuEuMBDgvwf7sJpBtdL/kNP
 wQN9+UsXXpVfA61uazizOPeBKzhvxvUcfnoy/KbX/21zywcFcexl7ZwUhRAh0ed/fyym
 c+oA==
X-Gm-Message-State: AOAM531iBNc7tRQlWR+cTlsObUiCeBKaT9Or+FdovBNAFqz2rfZyETPV
 JBFvDnA8H/egLYLfdvG12/Hccbkve7J/mW7UPsI4xNlY
X-Google-Smtp-Source: ABdhPJwSdhcIhlJB5sA2OksIUgDo9N0kIYvjdiKUAbaypt9iL/XQqSoPnQi2fPtBQqQ6P+fYc864bPt76Iwz7WlZs4w=
X-Received: by 2002:a05:6602:1491:: with SMTP id
 a17mr16981363iow.198.1595137925721; 
 Sat, 18 Jul 2020 22:52:05 -0700 (PDT)
MIME-Version: 1.0
From: Ren Victor <victorhge@HIDDEN>
Date: Sun, 19 Jul 2020 13:50:51 +0800
Message-ID: <CAMks0JH0N=BAEjBnGrU-jfT=aryrC4jEZDOuJMxAd5N3UpSVbg@HIDDEN>
Subject: 27.0.90; replace-match: point is NOT left at the end of replacement
To: bug-gnu-emacs@HIDDEN
Content-Type: multipart/mixed; boundary="0000000000006ed3d005aac4fd8c"
Received-SPF: pass client-ip=2607:f8b0:4864:20::d32;
 envelope-from=victorhge@HIDDEN; helo=mail-io1-xd32.google.com
X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache.
 That's all we know.
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

--0000000000006ed3d005aac4fd8c
Content-Type: text/plain; charset="UTF-8"

I attach an ert case to show the recipe.

This issue happens when modification hooks modify the text before the
end of replacement text.

`replace-match' calls `replace_range' to do the actual replacement,
which can trigger modification hooks.  Before calling `replace_range',
the position of the end of replacement is saved. After `replace_range',
the point is moved to the saved position.

But the end of replacement might be changed inside of
`replace_range'.  So the final movement of point may end up to a wrong
place.

Other types of modification (insert or delete) do not have this issue.
`point' is adjusted before running modification hooks.

In `replace_range', the point is also relocated.  I am not sure why it has
to be moved again just before returning from `replace-match'.

This is not a new issue.  It is in Emacs24 at least.


In GNU Emacs 27.0.90 (build 1, x86_64-pc-cygwin)
 of 2020-03-04 built on moufang2
Repository revision: afff43a72e96fcccabe77ff63226cddd540e068d
Repository branch: master
Windowing system distributor 'Microsoft Corp.', version 10.0.19041
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Quit
ert
next-line: End of buffer [3 times]
test-replace-match
Ran 1 tests, 0 results were as expected, 1 unexpected
next-line: End of buffer
previous-line: Beginning of buffer [13 times]
previous-line: Beginning of buffer
Configured using:
 'configure
 --srcdir=/home/kbrown/src/cygpackages/emacs/emacs-27.0.90-1.x86_64/src/emacs-27.0.90
 --prefix=/usr --exec-prefix=/usr --localstatedir=/var --sysconfdir=/etc
 --docdir=/usr/share/doc/emacs --htmldir=/usr/share/doc/emacs/html -C
 --with-w32 'CFLAGS=-ggdb -O2 -pipe -Wall -Werror=format-security
 -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector-strong
 --param=ssp-buffer-size=4
 -fdebug-prefix-map=/home/kbrown/src/cygpackages/emacs/emacs-27.0.90-1.x86_64/build=/usr/src/debug/emacs-27.0.90-1
 -fdebug-prefix-map=/home/kbrown/src/cygpackages/emacs/emacs-27.0.90-1.x86_64/src/emacs-27.0.90=/usr/src/debug/emacs-27.0.90-1'
 CPPFLAGS= LDFLAGS='

Configured features:
XPM JPEG TIFF GIF PNG SOUND DBUS GLIB NOTIFY GFILENOTIFY ACL GNUTLS
LIBXML2 HARFBUZZ ZLIB TOOLKIT_SCROLL_BARS XIM MODULES THREADS JSON
PDUMPER LCMS2 GMP

Important settings:
  value of $LANG: en_US.UTF-8
  locale-coding-system: utf-8-unix

Major mode: Emacs-Lisp

Minor modes in effect:
  tooltip-mode: t
  global-eldoc-mode: t
  eldoc-mode: t
  electric-indent-mode: t
  mouse-wheel-mode: t
  tool-bar-mode: t
  menu-bar-mode: t
  file-name-shadow-mode: t
  global-font-lock-mode: t
  font-lock-mode: t
  blink-cursor-mode: t
  auto-composition-mode: t
  auto-encryption-mode: t
  auto-compression-mode: t
  line-number-mode: t
  transient-mark-mode: t

Load-path shadows:
None found.

Features:
(shadow sort mail-extr emacsbug message rmc puny dired dired-loaddefs
format-spec rfc822 mml mml-sec password-cache epa derived epg epg-config
gnus-util rmail rmail-loaddefs text-property-search time-date subr-x
mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils
mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr
mail-utils cl-seq cl-extra seq byte-opt bytecomp byte-compile cconv
cl-macs gv ert pp ewoc debug backtrace help-mode find-func vc-git
diff-mode easymenu easy-mmode cl-loaddefs cl-lib tooltip eldoc electric
uniquify ediff-hook vc-hooks lisp-float-type mwheel disp-table
term/w32-win w32-win w32-vars term/common-win tool-bar dnd fontset image
regexp-opt fringe tabulated-list replace newcomment text-mode elisp-mode
lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch
timer select scroll-bar mouse jit-lock font-lock syntax facemenu
font-core term/tty-colors frame minibuffer cl-generic cham georgian
utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean
japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european
ethiopic indian cyrillic chinese composite charscript charprop
case-table epa-hook jka-cmpr-hook help simple abbrev obarray
cl-preloaded nadvice loaddefs button faces cus-face macroexp files
text-properties overlay sha1 md5 base64 format env code-pages mule
custom widget hashtable-print-readable backquote threads dbusbind
gfilenotify w32 lcms2 multi-tty make-network-process emacs)

Memory information:
((conses 16 62659 8699)
 (symbols 48 7750 1)
 (strings 32 21627 1406)
 (string-bytes 1 668356)
 (vectors 16 12971)
 (vector-slots 8 156156 9450)
 (floats 8 40 94)
 (intervals 56 307 1)
 (buffers 1000 14))

--0000000000006ed3d005aac4fd8c
Content-Type: application/octet-stream; name="test_replace_match.el"
Content-Disposition: attachment; filename="test_replace_match.el"
Content-Transfer-Encoding: base64
Content-ID: <f_kcsnspgk0>
X-Attachment-Id: f_kcsnspgk0

KHJlcXVpcmUgJ2VydCkKCihlcnQtZGVmdGVzdCB0ZXN0LXJlcGxhY2UtbWF0Y2ggKCkKICAiVGVz
dCBmb3IgYnVnLiIKICAobGV0ICgoY2hlY2stcG9pbnQgbmlsKQoJKG92LXNldCBuaWwpKQogICAg
KHdpdGgtdGVtcC1idWZmZXIKICAgICAgKGluc2VydCAiYSBhYmMiKQogICAgICAoc2V0cSBvdi1z
ZXQgKG1ha2Utb3ZlcmxheSAzIDUpKQogICAgICAob3ZlcmxheS1wdXQKCSAgIG92LXNldCAnbW9k
aWZpY2F0aW9uLWhvb2tzCgkgICAobGlzdCAobGFtYmRhIChvIGFmdGVyICZyZXN0IF9hcmdzKQoJ
CQkgICAod2hlbiBhZnRlcgoJCQkJIChsZXQgKChpbmhpYml0LW1vZGlmaWNhdGlvbi1ob29rcyB0
KSkKCQkJCSAgIChzYXZlLWV4Y3Vyc2lvbgoJCQkJCSAoZ290by1jaGFyIDIpCgkJCQkJIChpbnNl
cnQgImJjZCIpKSkpKSkpCiAgICAgIChnb3RvLWNoYXIgMykKCSAgKGlmIChzZWFyY2gtZm9yd2Fy
ZCAiYmMiKQoJCSAgKHJlcGxhY2UtbWF0Y2ggImJjZCIpKQogICAgICAoc2hvdWxkIChlcSAocG9p
bnQpIDEwKSkpKSkK
--0000000000006ed3d005aac4fd8c--




Acknowledgement sent to Ren Victor <victorhge@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#42424; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sun, 18 Oct 2020 08:30:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.