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: Thu, 24 Aug 2023 13:27:02 +0000 Message-ID: <87cyzck1uh.fsf@localhost> 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> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="2531"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, 65451@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Aug 24 15:27:22 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 1qZAMs-0000Rl-Jj for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 24 Aug 2023 15:27:22 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZAMY-00041m-A4; Thu, 24 Aug 2023 09:27:02 -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 1qZAMV-00041O-Hn for bug-gnu-emacs@gnu.org; Thu, 24 Aug 2023 09:27:00 -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 1qZAMT-00048m-V7 for bug-gnu-emacs@gnu.org; Thu, 24 Aug 2023 09:26:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qZAMX-0005k2-SQ for bug-gnu-emacs@gnu.org; Thu, 24 Aug 2023 09:27:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Ihor Radchenko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 24 Aug 2023 13:27:01 +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.169288360722046 (code B ref 65451); Thu, 24 Aug 2023 13:27:01 +0000 Original-Received: (at 65451) by debbugs.gnu.org; 24 Aug 2023 13:26:47 +0000 Original-Received: from localhost ([127.0.0.1]:36375 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZAMI-0005jW-KF for submit@debbugs.gnu.org; Thu, 24 Aug 2023 09:26:47 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]:57239) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZAMG-0005jJ-7D for 65451@debbugs.gnu.org; Thu, 24 Aug 2023 09:26:44 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 2B86D240103 for <65451@debbugs.gnu.org>; Thu, 24 Aug 2023 15:26:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1692883594; bh=Exv7Ico7UfYg0MVfQqNHnPY3JtgyWbPTvcE+9KBOmZc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=G1IgEE+hPZIJ8kTpFcrtn8hCQE2sI3FKB5f9zxojKcx3mHgT0JbWgIp7Yq/zJ22Nn CSxgibCKSBsWo5isIpVq5+oGPtIVReCRin3rb+yidVA2SpQ3LSo1ffFuCd0S4lXogr B0wecKp7AJrwuqjU+2I4VZjwG9T9AwnoWiK6JAT8Qh/29e2N8pU7S/TMPho2i5eRUT khCIA9yR8hxU90vkuXU0cBsk9OMEHCiWyatMUYAllXt66xpbhRcIBRl/88iHRK+NV2 Z4Jt+b5pSNgDqA5G72ZIsfOyNsLAYUj9IyjTkrL+U2dvWn+QDZKO+9hp3en79QtbRC FHMBa2vWibl+w== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4RWkPj2SQ0z6tm4; Thu, 24 Aug 2023 15:26:33 +0200 (CEST) In-Reply-To: <83r0nsprrk.fsf@gnu.org> 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:268337 Archived-At: Eli Zaretskii writes: >> Would it be acceptable to accumulate treesit_record_change transactions >> into a queue, combine them later, and run the Elisp hook only when it is >> safe (around the same place `after-change-functions' is called, but only >> when actual edit is made to the buffer text)? >> >> That way, we can have a hook that will run strictly less frequently >> compared to `after-change-functions'. > > 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. Elements of the list will be like [:buffer-chars-modified-tick :region-beginning :region-end-before-edit :region-end-after-edit] -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at