From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii 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: Thu, 24 Aug 2023 17:53:26 +0300 Message-ID: <83il94pk49.fsf@gnu.org> References: <871qfv2zlk.fsf@localhost> <83a5ujtgfo.fsf@gnu.org> <87jztn1c5x.fsf@localhost> <834jkrters.fsf@gnu.org> <87v8d7i48y.fsf@localhost> <83ttsrrroo.fsf@gnu.org> <874jkq87jl.fsf@localhost> <83y1i1r689.fsf@gnu.org> <87fs487uip.fsf@localhost> <83zg2gq2vj.fsf@gnu.org> <871qfsel8q.fsf@localhost> <83r0nsprrk.fsf@gnu.org> <87cyzck1uh.fsf@localhost> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21249"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, 65451@debbugs.gnu.org To: Ihor Radchenko Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 24 16:54:31 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 1qZBjD-0005LC-1J for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 24 Aug 2023 16:54:31 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZBij-0006xP-57; Thu, 24 Aug 2023 10:54:01 -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 1qZBig-0006wQ-U9 for bug-gnu-emacs@gnu.org; Thu, 24 Aug 2023 10:53:58 -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 1qZBig-0004k9-MA for bug-gnu-emacs@gnu.org; Thu, 24 Aug 2023 10:53:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qZBik-00008h-MA for bug-gnu-emacs@gnu.org; Thu, 24 Aug 2023 10:54:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 24 Aug 2023 14:54: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.1692888795456 (code B ref 65451); Thu, 24 Aug 2023 14:54:02 +0000 Original-Received: (at 65451) by debbugs.gnu.org; 24 Aug 2023 14:53:15 +0000 Original-Received: from localhost ([127.0.0.1]:38390 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZBhz-00007G-EI for submit@debbugs.gnu.org; Thu, 24 Aug 2023 10:53:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:48278) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZBhx-00006n-GL for 65451@debbugs.gnu.org; Thu, 24 Aug 2023 10:53:14 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZBhn-0004ga-49; Thu, 24 Aug 2023 10:53:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=kDbbLOsT5WDIh1UDWKoEYiZCctnViiMuOfnYIF7Umdg=; b=W+S6oma5uUe8 og9qRAkhkJ1EkRifV6eLJQnTS/331Crty0OcLqgYKPQBOa/7zmPVZY2qu+H7fYnvEy7p5x2QWPdWK PD1jUUbdMO/UtP3tmsu4l2XfUFEsX4lFK8qxD2VdrOLJ9H+/IlwCh+SrKx4xR4FaL/p0Jt2IOG2WZ +XJNcXR1aylOt+RxxRE2mULXIvzWsOaCGluDzOiYhQmQjaN8HOn9yKYMf5QWhyyy5gTX+OtsdiqI1 gTJgB2ABft/s5BJNZRWJeLRSwXQAqtDLLCq1kmWtSx1L68sZeNewkSgrEmAasyhkPKLAdkUQDrBAo lnYyJpaV5Rrj7zc8boByUA==; In-Reply-To: <87cyzck1uh.fsf@localhost> (message from Ihor Radchenko on Thu, 24 Aug 2023 13:27:02 +0000) 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:268346 Archived-At: > From: Ihor Radchenko > Cc: casouri@gmail.com, 65451@debbugs.gnu.org > Date: Thu, 24 Aug 2023 13:27:02 +0000 > > Eli Zaretskii writes: > > > When exactly do you need this to run? At the same time as > > after-change-functions doesn't sound like a good idea to me, but I > > think you don't need to run it there. What about running just before > > redisplay kicks in? > > Usually, we need to update AST when some other Elisp code needs Org > element API. And we update AST on idle timer to speed things up. > > What if we use no hooks at all? Instead, the edit transactions are > accumulated in a list that can be examined and processed by Elisp code > as needed. If you need that from timers, then yes, all you need is access from the timer function to a data structure that holds the accumulated transactions. Timers run approximately at the same time and under the same conditions as redisplay, so this mechanism will indeed ensure this data is accessed when Emacs is in a consistent state, and it is safe to access and use this data. > Elements of the list will be like > [:buffer-chars-modified-tick :region-beginning :region-end-before-edit :region-end-after-edit] If you really need buffer-chars-modified-tick, you will have to verify that it is updated before calling the function which updates the "transactions list".