From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Ihor Radchenko 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: Tue, 22 Aug 2023 09:30:47 +0000 Message-ID: <871qfv2zlk.fsf@localhost> 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="16710"; mail-complaints-to="usenet@ciao.gmane.io" To: 65451@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Aug 22 11:31:40 2023 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 1qYNjf-00048H-7w for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 22 Aug 2023 11:31:39 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qYNjN-0008IG-L1; Tue, 22 Aug 2023 05:31:22 -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 1qYNj1-0008ES-Ts for bug-gnu-emacs@gnu.org; Tue, 22 Aug 2023 05:31:10 -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 1qYNj1-0000Gh-Cx for bug-gnu-emacs@gnu.org; Tue, 22 Aug 2023 05:30:59 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qYNj4-0006Q5-1p for bug-gnu-emacs@gnu.org; Tue, 22 Aug 2023 05:31:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 22 Aug 2023 09:31:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 65451 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.169269663524642 (code B ref -1); Tue, 22 Aug 2023 09:31:01 +0000 Original-Received: (at submit) by debbugs.gnu.org; 22 Aug 2023 09:30:35 +0000 Original-Received: from localhost ([127.0.0.1]:58586 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qYNic-0006PN-TF for submit@debbugs.gnu.org; Tue, 22 Aug 2023 05:30:35 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:45354) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qYNia-0006P8-Fs for submit@debbugs.gnu.org; Tue, 22 Aug 2023 05:30:33 -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 1qYNiS-0007Wr-62 for bug-gnu-emacs@gnu.org; Tue, 22 Aug 2023 05:30:24 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qYNiO-0008Pw-VB for bug-gnu-emacs@gnu.org; Tue, 22 Aug 2023 05:30:23 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 4DF16240101 for ; Tue, 22 Aug 2023 11:30:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1692696618; bh=PK3Oda/wFPw5GWyEc+PUBvXRzmEm0++n+0AnyRAH5Wc=; h=From:To:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:From; b=XJ7sRH4fIHqcPw64YAnFVly5smAxm3n++Zkxb8x0Kk795hx4IUIF2bFqQsJU+O94L M50k6uBJeOVOAODkv15ObMIJSPue/wuavxd4HBwNcj8OpP4LJlhY6Va0kaxbeYoPAt FWKCzqCpnH9hXV/2N4m6CH5m+ts61kH6u2bmMTo2WjQoMdI9SItYISfrCWlHfqMEEp Rggw2mhfofg7T7YzSxPJayzpTisJEsiI+ytf/EUZpjGSY8kfWYFtcII3dWZLdg6ymr ERI0DBby+tgT3GVCXRKOOYW4OLA3xTXQFbLiF/O01tNUfvrjYYdQcyRabdE+G6jFjm cc90GqJUiNIeA== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4RVPG14vS7z6tw7 for ; Tue, 22 Aug 2023 11:30:17 +0200 (CEST) Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:268158 Archived-At: Consider the following reproducer: 1. Create /tmp/bug.el with the following contents (defun my/setup () (interactive) (defun my/before-change (beg end) (warn "Before: %d %d" beg end)) (add-hook 'before-change-functions #'my/before-change nil 'local) (defun my/after-change (beg end pre) (warn "After: %d %d delta: %d" beg end (- end beg pre))) (add-hook 'after-change-functions #'my/after-change nil 'local)) 2. Create /tmp/bug.org https://www.gnu.org/software/emacs/manual/html_node/emacs/Mode-Line.html -UUU: @**- F2 UTF-8-demo.txt Top (1,0) (Text s-/ WS Wrap) | string | meaning | note = | |--------+------------------------------------------+----------------------= ------------------------------------------------| | - | input method | = | | UUU | coding system (keyboard terminal buffer) | (U utf-8-unix) = | | : | end-of-line convention | (: LF) (/ CR) (\ CRLF= ) | | @ | emacsclient | = | | ** | buffer status | (-- unmodified) (** m= odified) (%% read-only) (%* read-only_modified) | | - | default-directory | (- local) (@ remote) = | | F2 | frame name | (F2 the-2nd-frame) = | | | | = | 3. emacs -Q -l /tmp/bug.el /tmp/bug.org 4. M-x my/setup 5. Move point to | F2 | frame name | (F2 the-2nd-frame) = | | | | = | 6. Insert "UTF" 7. M-x dabbrev-expand 8. Observe the following in the *Warnings* buffer =E2=9B=94 Warning (emacs): Before: 1278 1278 =E2=9B=94 Warning (emacs): After: 1278 1279 delta: 1 =E2=9B=94 Warning (emacs): Before: 1284 1285 =E2=9B=94 Warning (emacs): After: 1284 1284 delta: -1 =E2=9B=94 Warning (emacs): Before: 1279 1279 =E2=9B=94 Warning (emacs): After: 1279 1280 delta: 1 =E2=9B=94 Warning (emacs): Before: 1284 1285 =E2=9B=94 Warning (emacs): After: 1284 1284 delta: -1 =E2=9B=94 Warning (emacs): Before: 1280 1280 =E2=9B=94 Warning (emacs): After: 1280 1281 delta: 1 =E2=9B=94 Warning (emacs): Before: 1284 1285 =E2=9B=94 Warning (emacs): After: 1284 1284 delta: -1 =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 The last bit of the messages corresponds to dabbrev expansion of "UTF" to "utf-8-unix": =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 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". The order of after-change notifications thus do not correspond to the order of buffer changes. Org mode is relying upon the correct change order to update parser cache with buffer modifications. The same recipe using Emacs 27 yields the correct order <...> Warning (emacs): Before: 1278 1281 Warning (emacs): After: 1278 1288 delta: 7 Warning (emacs): Before: 1278 1288 Warning (emacs): After: 1278 1288 delta: 0 In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.38, cairo version 1.17.8) of 2023-08-14 built on localhost Repository revision: d483b38070120f17b1d00975081d27191d1deacc Repository branch: master Windowing system distributor 'The X.Org Foundation', version 11.0.12101008 System Description: Gentoo Linux --=20 Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at