GNU bug report logs - #77607
31.0.50; replace-region-contents moves point

Previous Next

Package: emacs;

Reported by: "Paul D. Nelson" <ultrono <at> gmail.com>

Date: Mon, 7 Apr 2025 12:10:02 UTC

Severity: normal

Found in version 31.0.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

Full log


Message #16 received at 77607-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 77607-done <at> debbugs.gnu.org, "Paul D. Nelson" <ultrono <at> gmail.com>
Subject: Re: bug#77607: 31.0.50; replace-region-contents moves point
Date: Mon, 07 Apr 2025 11:54:22 -0400
>>> (with-temp-buffer
>>>   (insert "abc")
>>>   (replace-region-contents (- (point) 3) (- (point) 2) (lambda () "A"))
>>>   (char-to-string (char-before)))
>>>
>>> now returns "A", but I believe that it previously returned "c".

I installed the patch below which should fix it.


        Stefan


diff --git a/src/editfns.c b/src/editfns.c
index 9590b49dc25..669d3cdb140 100644
--- a/src/editfns.c
+++ b/src/editfns.c
@@ -1968,6 +1968,7 @@ DEFUN ("replace-region-contents", Freplace_region_contents,
   if (FUNCTIONP (source))
     {
       specpdl_ref count = SPECPDL_INDEX ();
+      record_unwind_protect_excursion ();
       record_unwind_protect (save_restriction_restore,
 			     save_restriction_save ());
       Fnarrow_to_region (beg, end);
@@ -2119,7 +2120,6 @@ DEFUN ("replace-region-contents", Freplace_region_contents,
 
   Fundo_boundary ();
   bool modification_hooks_inhibited = false;
-  record_unwind_protect_excursion ();
 
   /* We are going to make a lot of small modifications, and having the
      modification hooks called for each of them will slow us down.





This bug report was last modified 43 days ago.

Previous Next


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