From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#74276: 30.0.90; undo does not account for overlays now that markers are not used Date: Thu, 14 Nov 2024 10:36:22 -0500 Message-ID: References: <86jzdcsyc1.fsf@gmx.net> <86fro0omey.fsf@gnu.org> <865xowmmo8.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25920"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: karthikchikmagalur@gmail.com, 74276@debbugs.gnu.org, jimjoe@gmx.net To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Nov 14 16:37:30 2024 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 1tBbuT-0006Z6-EZ for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 14 Nov 2024 16:37:29 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tBbu8-0007uc-RV; Thu, 14 Nov 2024 10:37:09 -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 1tBbu4-0007uK-Fr for bug-gnu-emacs@gnu.org; Thu, 14 Nov 2024 10:37:05 -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 1tBbu3-0004YA-Ll for bug-gnu-emacs@gnu.org; Thu, 14 Nov 2024 10:37:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=GueT0dL8/bwW1nhA9t7wIEkzTw/nliVurkJ2OIbZujM=; b=PmAC4WSq6r5ROyaPthJgWlOa7dDstbUaCSo/80Zj5TWp2qVwyyolIFuqa+VguciTCFZH8U6kJfs5mjT/DSeAHNVx0UE6BjhAntI6HM6S3f5G78lFFvqVPRbGree6BASl4wKlzXt6hxayPNVYqu9p0ow17+6q9gpetl9Y2hpdbEFmcTORyj2qQQyFzVeI+LH3qLndyTo+fk1KL/cpmIAS9ICGXCXssERI8i1xNYlzgTSUnzpy72R/IAz2j9iQ40cAOxjq5YFu8vk7xLmyxfKukdr5oWPu1qYyurvEdK1vZlr6PWYtMAXHJSDvEqAVIERjiidxlXuWqIUv4ALNqhWiiQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tBbu2-0004xk-BE for bug-gnu-emacs@gnu.org; Thu, 14 Nov 2024 10:37:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 14 Nov 2024 15:37:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 74276 X-GNU-PR-Package: emacs Original-Received: via spool by 74276-submit@debbugs.gnu.org id=B74276.173159859219023 (code B ref 74276); Thu, 14 Nov 2024 15:37:02 +0000 Original-Received: (at 74276) by debbugs.gnu.org; 14 Nov 2024 15:36:32 +0000 Original-Received: from localhost ([127.0.0.1]:46802 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBbtY-0004wl-2J for submit@debbugs.gnu.org; Thu, 14 Nov 2024 10:36:32 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:20723) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tBbtV-0004wY-QZ for 74276@debbugs.gnu.org; Thu, 14 Nov 2024 10:36:30 -0500 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 32D7E100180; Thu, 14 Nov 2024 10:36:24 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1731598583; bh=d/6237MF6zqtQ/y+Iq5wrwXcn/3MyHTww6zIWLTncx0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=Fvijo3TJmBuEKIFTpxtvQeMdDt8M7Brf+oWy3y0dWhyhXFwmp0UE76jZZ/LIZ+nKt PLySUaAaK5ve0AJCymqvBnzWaMGZ5TiXSz/JSWcqdqKdjn0JU3ZlkLMcYLQPQGsoed eVlsArVpdiupvdG/Kce/pCdfUNv9jFfEOeEOYu8yldSmvmtd04Y5Ctr9PW4x5T3j5x PfWpWmIBEDHxyGUP1BUmW6kVjhrHuEyNHgKMKiQIblIR5qNP2gh2rHf1+u7LynJoLj JcApQRUdIk75rH8ZUTt65SOBYbKHFaCOkd+Hm7j+2UhextpSh6LKRzqf8dGLZ8M9D/ vuPuBU8xR0f4g== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 79885100043; Thu, 14 Nov 2024 10:36:23 -0500 (EST) Original-Received: from alfajor (modemcable005.21-80-70.mc.videotron.ca [70.80.21.5]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4E0D9120426; Thu, 14 Nov 2024 10:36:23 -0500 (EST) In-Reply-To: <865xowmmo8.fsf@gnu.org> (Eli Zaretskii's message of "Sat, 09 Nov 2024 17:50:15 +0200") 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:295335 Archived-At: >> > Stefan, does undo restore overlays, and if so, how? >> No, I don't think `undo` has ever tried to restore overlays. >> But it does attempt to restore marker positions, so I guess there can be >> cases where the switch to itree has caused overlays' boundaries to be >> restored less well than before. > Well, in this particular recipe Emacs 29 and 30 behave exactly like > Emacs 25, do at least in this case there was no regression. Which suggests that maybe the code we have to save/restore the position of markers in `buffer-undo-list` doesn't(didn't?) really do its job. > But maybe we should add to undo the capability of restoring the > overlays. Maybe. Stefan PS: Reading the `record_marker_adjustments` in Emacs-28, it seems that this code would happily add to the `buffer-undo-list` markers that were "internal" to overlays. That reminds me of a discussion many years ago where I suggested we add functions to return the begin/end markers of an overlay so that ELisp code could use `set-marker-insertion-type` to change the insertion type of the beginning/end of an overlay (which is currently otherwise fixed at creation). This was rejected because exposing such internals would be undesirable (e.g. making backward-incompatible the change we implemented in Emacs-29) and risky (allowing inconsistencies like overlays whose beg and end don't point to the same buffer). It turns out that such functions could have been hacked all along in ELisp by (ab)using this `record_marker_adjustments` code: (defun overlay-markers (ol) "Return the two markers of an overlay as (BEG . END)." (with-temp-buffer (insert "aa") (let ((beg (point)) (_ (insert "bbb")) (end (point))) (insert "cccc") (move-overlay ol beg end (current-buffer)) (let ((buffer-undo-list ())) (delete-region (point-min) (point-max)) (cons (car (rassq -2 buffer-undo-list)) (car (rassq -5 buffer-undo-list))))))) =F0=9F=99=82