From unknown Mon Aug 18 21:32:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#65929: 29.1; modification-hooks run when deleting after the overlay Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Sep 2023 22:39:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 65929 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 65929@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.169464473619065 (code B ref -1); Wed, 13 Sep 2023 22:39:02 +0000 Received: (at submit) by debbugs.gnu.org; 13 Sep 2023 22:38:56 +0000 Received: from localhost ([127.0.0.1]:36290 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgYVb-0004xQ-AD for submit@debbugs.gnu.org; Wed, 13 Sep 2023 18:38:55 -0400 Received: from lists.gnu.org ([2001:470:142::17]:53186) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgYVW-0004x7-IO for submit@debbugs.gnu.org; Wed, 13 Sep 2023 18:38:53 -0400 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 1qgYVL-0003nw-8s for bug-gnu-emacs@gnu.org; Wed, 13 Sep 2023 18:38:39 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qgYVJ-0005j3-0D for bug-gnu-emacs@gnu.org; Wed, 13 Sep 2023 18:38:39 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id AEC451000E5 for ; Wed, 13 Sep 2023 18:38:35 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1694644709; bh=dYAvxKrGkPWRCWsD71xhDyppreHAdiOzM1NqAe7fVpw=; h=From:To:Subject:Date:From; b=VT2VB43ilrOQqgMF1pv1RDN7HMBrEX4gkVjihptXN1PA8Ys4Crl72/r5saSBX9HsO 4AZYrdFl8LsB3swSGA3TVRmQCZa/uvVHGUj3qUM+dCna66M+5NsVseNButbJoptJDZ 4qm4ildbbok7kIw9zLXgNdjVfBM/FhW5e6D7C/vMeOr9qvI1Iz4M1OOgKsaN7mwapS aXaWbh2xDijKStFka9aAw23ZmkLrxYFEPU7ZYYcBvRfKrUgxWxtH1rqvCFazIcLXee 6MctOcrBBrOjthI4QnWwCzl7AAQTuwsSeA/skgQPbYsD37n1L5BVhwe9l5X8RNk894 DjJFoZTUJlvYw== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id E98E41000A3 for ; Wed, 13 Sep 2023 18:38:29 -0400 (EDT) Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id D7E461202BE for ; Wed, 13 Sep 2023 18:38:29 -0400 (EDT) From: Stefan Monnier Date: Wed, 13 Sep 2023 18:37:12 -0400 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.076 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 0.0 (/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Package: Emacs Version: 29.1 As found via yasnippet's test suite, the new overlay code in Emacs-29 sometimes mistakenly runs the `modification-hooks` when the text *right after* an (empty) overlay is deleted. This can be seen in the attached trace obtained while running yasnippet's `delete-numberless-inner-snippet-issue-562` test. In that trace we see a call (yas--on-protection-overlay-modification # nil 1 5) i.e. a call where the `modification-hooks` function (`yas--on-protection-overlay-modification`) is called for a deletion of text between 1 and 5 while the overlay itself does not contain any of those characters since the overlay is empty, at BOB. According to the Texinfo doc: =E2=80=98modification-hooks=E2=80=99 This property=E2=80=99s value is a list of functions to be called = if any character within the overlay is changed or if text is inserted strictly within the overlay. The behavior in Emacs<29 obeys the Texinfo doc. Stefan --=-=-= Content-Type: text/plain Content-Disposition: inline; filename=yasnippet-tests-trace.txt 1 -> (yas-skip-and-clear-field) | 2 -> (yas-current-field) | 2 <- yas-current-field: #1=#s(yas--field nil # # #s(yas--field 3 # # nil nil nil nil #1#) nil nil nil #s(yas--exit # #s(yas--field 2 # # nil nil nil nil nil))) | 2 -> (yas--skip-and-clear #1=#s(yas--field nil # # #s(yas--field 3 # # nil nil nil nil #1#) nil nil nil #s(yas--exit # #s(yas--field 2 # # nil nil nil nil nil)))) | | 3 -> (yas--mark-this-and-children-modified #1=#s(yas--field nil # # #s(yas--field 3 # # nil nil nil nil #1#) nil nil nil #s(yas--exit # #s(yas--field 2 # # nil nil nil nil nil)))) | | 3 <- yas--mark-this-and-children-modified: nil | | 3 -> (delete-region # #) | | | 4 -> (yas--on-field-overlay-modification # nil 1 5) | | | | 5 -> (yas-active-snippets 1 5) | | | | | 6 -> (overlays-in 1 12) | | | | | 6 <- overlays-in: (# # # #) | | | | | 6 -> (overlays-in 1 5) | | | | | 6 <- overlays-in: (# # #) | | | | 5 <- yas-active-snippets: (#s(yas--snippet nil (#2=#s(yas--field 2 # # nil nil nil nil nil) #1=#s(yas--field 3 # # nil nil nil nil #3=#s(yas--field nil # # #1# nil nil t #4=#s(yas--exit # #2#))) #3#) #4# 6 # #3# nil nil)) | | | 4 <- yas--on-field-overlay-modification: (#s(yas--snippet nil (#2=#s(yas--field 2 # # nil nil nil nil nil) #1=#s(yas--field 3 # # nil nil nil nil #3=#s(yas--field nil # # #1# nil nil t #4=#s(yas--exit # #2#))) #3#) #4# 6 # #3# nil nil)) | | | 4 -> (yas--on-protection-overlay-modification # nil 1 5) | | | 4 <- yas--on-protection-overlay-modification: nil | | | 4 -> (yas--on-field-overlay-modification # t 1 1 4) | | | | 5 -> (yas-active-snippets 1 1) | | | | | 6 -> (overlays-in 1 8) | | | | | 6 <- overlays-in: (# # # #) | | | | | 6 -> (overlays-in 1 1) | | | | | 6 <- overlays-in: (# #) | | | | 5 <- yas-active-snippets: (#s(yas--snippet nil (#2=#s(yas--field 2 # # nil nil nil nil nil) #1=#s(yas--field 3 # # nil nil nil nil #3=#s(yas--field nil # # #1# nil nil t #4=#s(yas--exit # #2#))) #3#) #4# 6 # #3# nil nil)) | | | 4 <- yas--on-field-overlay-modification: (#s(yas--snippet nil (#2=#s(yas--field 2 # # nil nil nil nil nil) #1=#s(yas--field 3 # # nil nil nil nil #3=#s(yas--field nil # # #1# nil nil t #4=#s(yas--exit # #2#))) #3#) #4# 6 # #3# nil nil)) | | | 4 -> (yas--on-protection-overlay-modification # t 1 1 4) | | | | 5 -> (yas-active-snippets) | | | | | 6 -> (overlays-in 1 8) | | | | | 6 <- overlays-in: (# # # #) | | | | | 6 -> (overlays-in 1 2) | | | | | 6 <- overlays-in: (# # # #) | | | | 5 <- yas-active-snippets: (#s(yas--snippet nil (#2=#s(yas--field 2 # # nil nil nil nil nil) #1=#s(yas--field 3 # # nil nil nil nil #3=#s(yas--field nil # # #1# nil nil t #4=#s(yas--exit # #2#))) #3#) #4# 6 # #3# nil nil)) | | | | 5 -> (yas--commit-snippet #s(yas--snippet nil (#2=#s(yas--field 2 # # nil nil nil nil nil) #1=#s(yas--field 3 # # nil nil nil nil #3=#s(yas--field nil # # #1# nil nil t #4=#s(yas--exit # #2#))) #3#) #4# 6 # #3# nil nil)) | | | | 5 <- yas--commit-snippet: nil | | | 4 <- yas--on-protection-overlay-modification: nil | | 3 <- delete-region: nil --=-=-=-- From unknown Mon Aug 18 21:32:28 2025 X-Loop: help-debbugs@gnu.org Subject: bug#65929: 29.1; modification-hooks run when deleting after the overlay Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 13 Sep 2023 22:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65929 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 65929@debbugs.gnu.org Received: via spool by 65929-submit@debbugs.gnu.org id=B65929.169464564120755 (code B ref 65929); Wed, 13 Sep 2023 22:55:02 +0000 Received: (at 65929) by debbugs.gnu.org; 13 Sep 2023 22:54:01 +0000 Received: from localhost ([127.0.0.1]:36308 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgYkD-0005Oc-Dp for submit@debbugs.gnu.org; Wed, 13 Sep 2023 18:54:01 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:35672) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgYk7-0005OK-M6 for 65929@debbugs.gnu.org; Wed, 13 Sep 2023 18:54:00 -0400 Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 390A44426EC; Wed, 13 Sep 2023 18:53:44 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1694645622; bh=AQXYE3Ainq5OI6Qj7ooGFf5AahP5ubaBLFJBtegdeiQ=; h=From:To:Subject:In-Reply-To:References:Date:From; b=XSWytUt0WSu8XnzOgR3cmke7XRaaty6qnTT2bw8SmfbcPz87Jocf6qTtOIYdBWFZS 0ZSB3P6sCLmQu5WkWRkPkxIyJopWHVYiJKkEpEWbYIpA3HASnribuGx0mac3xebh2r C+u+NZEIj0Zqs04yez0fG31ocpY0nOpXkusCt0oGYUha4z743Xp0Ri2huTqXrKaPD0 dYqE6f3Z+8uaCvIVYR68OK+IC32Mz2uC5l2lLnDzAHL8/XaZ5bexRqoPdi3ST8WuQk cR3TRpyyClmSt3H1fAt6th+oIKLs7qguw6fmC89GVp7vDYVhncG4IUHN18j73PAi2d 1y5l0VsE/EBAQ== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id C1A3E4426D5; Wed, 13 Sep 2023 18:53:42 -0400 (EDT) Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id B34A3120432; Wed, 13 Sep 2023 18:53:42 -0400 (EDT) From: Stefan Monnier In-Reply-To: (GNU bug Tracking System's message of "Wed, 13 Sep 2023 22:39:02 +0000") Message-ID: References: Date: Wed, 13 Sep 2023 18:52:33 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.115 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) 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))))) From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 13 18:54:24 2023 Received: (at control) by debbugs.gnu.org; 13 Sep 2023 22:54:24 +0000 Received: from localhost ([127.0.0.1]:36312 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgYkZ-0005PT-QU for submit@debbugs.gnu.org; Wed, 13 Sep 2023 18:54:24 -0400 Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:54748) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qgYkX-0005PF-Ng for control@debbugs.gnu.org; Wed, 13 Sep 2023 18:54:22 -0400 Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id D64561000E5; Wed, 13 Sep 2023 18:54:10 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1694645649; bh=P88qlhmXA7fa7BfMpDQmXhCGnJOWGUYiVWFiOZ6KjEU=; h=From:To:Subject:In-Reply-To:References:Date:From; b=JtpKr+dys7VNcuAB9BN+N9VElgpR/Ue2991zP/yFga9P6KRgqkVtIIF1+KuWbe+1j m5+GBwQuPPAe9cVV18kuZCuduozmt7hQaOTIlbhRAgzcdVg5hSbY+v7ZdqA6wuhLAS ysceUijw39p1nAW7HP0ARsXA4+G1c1gKJuNrIoSSWZqSmWuHdtpQ/Gq+ckefQhGJkt 0UxOCMs6snwsHQ9lBdfik6Qwq1D4nmE11TXNmskSOZjxDFPaH29wej+xT2GMb5XnIO amcRyDxmyD6FmlzcJnll0y3gDTQMpXCK+Y3iBowgtnVoKxzrJEF8FFK0zzuYtpKO+a buFFJIjhOYuDA== Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id C93AF1000A3; Wed, 13 Sep 2023 18:54:09 -0400 (EDT) Received: from lechazo (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id AEAB3120329; Wed, 13 Sep 2023 18:54:09 -0400 (EDT) From: Stefan Monnier To: control@debbugs.gnu.org Subject: Re: bug#65929: Acknowledgement (29.1; modification-hooks run when deleting after the overlay) In-Reply-To: (GNU bug Tracking System's message of "Wed, 13 Sep 2023 22:39:02 +0000") Message-ID: References: Date: Wed, 13 Sep 2023 18:53:00 -0400 User-Agent: Gnus/5.13 (Gnus v5.13) MIME-Version: 1.0 Content-Type: text/plain X-SPAM-INFO: Spam detection results: 0 ALL_TRUSTED -1 Passed through trusted hosts only via SMTP AWL 0.070 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DKIM_SIGNED 0.1 Message has a DKIM or DK signature, not necessarily valid DKIM_VALID -0.1 Message has at least one valid DKIM or DK signature DKIM_VALID_AU -0.1 Message has a valid DKIM or DK signature from author's domain DKIM_VALID_EF -0.1 Message has a valid DKIM or DK signature from envelope-from domain X-SPAM-LEVEL: X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: control X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) close 65929