Subject: Re: bug#65929: 29.1; modification-hooks run when deleting after the overlay

From: Stefan Monnier <[email-masked]>
Date: Wed, 13 Sep 2023 18:52:33 -0400

I pushed the patch below to `emacs-29`.
It fixes the bug for the yasnippet test suite and adds a corresponding
regression test in our test suite.

        Stefan

diff --git a/src/buffer.c b/src/buffer.c
index 252231357bc..db362ffe7b0 100644
--- a/src/buffer.c
+++ b/src/buffer.c
@@ -4091,7 +4091,7 @@ report_overlay_modification (Lisp_Object start, Lisp_Object end, bool after,
 	    }
 	  /* Test for intersecting intervals.  This does the right thing
 	     for both insertion and deletion.  */
-	  if (! insertion || (end_arg > obegin && begin_arg < oend))
+	  if (end_arg > obegin && begin_arg < oend)
 	    {
 	      Lisp_Object prop = Foverlay_get (overlay, Qmodification_hooks);
 	      if (!NILP (prop))
diff --git a/test/src/buffer-tests.el b/test/src/buffer-tests.el
index 45914b2b6b0..aa30533c6a0 100644
--- a/test/src/buffer-tests.el
+++ b/test/src/buffer-tests.el
@@ -142,6 +142,7 @@ overlay-modification-hooks
                 (expected-calls . ((modification-hooks (nil 3 4))
                                    (modification-hooks (t 3 4 1)))))
                ((replace . "4"))
+               ((replace . "4") (overlay-beg . 4)) ;bug#65929
                ((replace . "12")
                 (expected-calls . ((modification-hooks (nil 1 3))
                                    (modification-hooks (t 1 2 2)))))