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#65451: 30.0.50; `after-change-functions' are not triggered in the same order the changes are made Date: Sat, 30 Mar 2024 09:51:59 -0400 Message-ID: References: <871qfv2zlk.fsf@localhost> <83a5ujtgfo.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="21884"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Alan Mackenzie , Ihor Radchenko , 65451@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Mar 30 14:53:29 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 1rqZ9F-0005WS-6q for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 30 Mar 2024 14:53:29 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rqZ8o-0007zC-Vp; Sat, 30 Mar 2024 09:53:03 -0400 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 1rqZ8n-0007yT-3r for bug-gnu-emacs@gnu.org; Sat, 30 Mar 2024 09:53:01 -0400 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 1rqZ8m-0006IF-S3 for bug-gnu-emacs@gnu.org; Sat, 30 Mar 2024 09:53:00 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rqZ8o-0001Dk-Gd for bug-gnu-emacs@gnu.org; Sat, 30 Mar 2024 09:53:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 30 Mar 2024 13:53:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65451 X-GNU-PR-Package: emacs Original-Received: via spool by 65451-submit@debbugs.gnu.org id=B65451.17118067324554 (code B ref 65451); Sat, 30 Mar 2024 13:53:02 +0000 Original-Received: (at 65451) by debbugs.gnu.org; 30 Mar 2024 13:52:12 +0000 Original-Received: from localhost ([127.0.0.1]:44244 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rqZ80-0001BO-2Q for submit@debbugs.gnu.org; Sat, 30 Mar 2024 09:52:12 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:31984) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rqZ7y-0001Aq-BQ for 65451@debbugs.gnu.org; Sat, 30 Mar 2024 09:52:11 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id B175D4413BA; Sat, 30 Mar 2024 09:52:02 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1711806721; bh=CukHSMFKxw0XwVfaBKULkiKoHdf/WWf/uV7/3eawy8M=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=mvZ8Gy9p6UuOTKJho/pXfxOghE8JKhnkSN0UjVXt3emB/8MrHs6Veo1OhTjuOz0LV 5YQixGUpAaltBivk4+mY+bNZQeepXTc3FoC1KRqW2pYrV7Y15SVwd5Fzby6xJ16ZBv tk9SWZYLY2dvTIQ5ZJhXAn65lMQamHuIJA8fr0lMsaPnZx77ORe3cubSVaXsv6HiXF dH23ieKI3WSvIJjvRre6JTdNQZEqX9A2boMs0Jx8Y61aCXN8FyugTTGKSHY6wu4Ji7 A7w9il2WmRFGXhAPFmgGIZdMY7JCRKkgpeoJ9gp/h3MVPd64SqQgY13R1940A0/JTr owAzAuLenzurw== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 5DCBE441388; Sat, 30 Mar 2024 09:52:01 -0400 (EDT) Original-Received: from pastel (unknown [45.72.201.215]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 2E87E120618; Sat, 30 Mar 2024 09:52:01 -0400 (EDT) In-Reply-To: <83a5ujtgfo.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 22 Aug 2023 15:22:35 +0300") 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:282369 Archived-At: >> =E2=9B=94 Warning (emacs): Before: 1278 1281 >> =E2=9B=94 Warning (emacs): Before: 1278 1288 >> =E2=9B=94 Warning (emacs): After: 1278 1288 delta: 0 >> =E2=9B=94 Warning (emacs): After: 1278 1288 delta: 7 >>=20 >> Note how "After: 1278 1288 delta: 0" reports a change of "utf-8-unix" >> that did not alter the buffer text size. It is trigerred _before_ >> "After: 1278 1288 delta: 7" that corresponds to replacing "UTF" with >> "utf-8-unix". Hmm... yes, that's bad. Alan, have you looked at this? I suspect the best option in the above case is to inhibit the inner calls to before/after (assuming we're sure they change only the "new text"), so we'd be down to: =E2=9B=94 Warning (emacs): Before: 1278 1281 =E2=9B=94 Warning (emacs): After: 1278 1288 delta: 7 > I think Org mode is relying on something it should not. This > particular use case aside, Emacs is allowed to call a function that > changes the buffer from a function that itself changes the buffer, and > it is allowed to call that inner function _before_ it did all the > changes it intended to do. AFAIK the above sequences breaks the promise we make about `before-change-functions` and `after-change-functions`. Almost all the non-trivial users of those hooks (i.e. basically those that need to use both hooks) have extra sanity and raise the heads up in despair when faced with things like the above (my `track-changes.el` lacks such sanity checks, but that's because it's a PoC). Stefan