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 15:08:15 +0300 Message-ID: <83r0nsprrk.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> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40067"; 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 14:09:06 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 1qZ998-000AAn-Ae for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 24 Aug 2023 14:09:06 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZ992-0008CO-4n; Thu, 24 Aug 2023 08:09:00 -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 1qZ990-0008C2-Od for bug-gnu-emacs@gnu.org; Thu, 24 Aug 2023 08:08:59 -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 1qZ990-0004i7-Go for bug-gnu-emacs@gnu.org; Thu, 24 Aug 2023 08:08:58 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qZ994-0003e7-Du for bug-gnu-emacs@gnu.org; Thu, 24 Aug 2023 08:09: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 12:09: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.169287888313940 (code B ref 65451); Thu, 24 Aug 2023 12:09:02 +0000 Original-Received: (at 65451) by debbugs.gnu.org; 24 Aug 2023 12:08:03 +0000 Original-Received: from localhost ([127.0.0.1]:36302 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZ987-0003ck-EJ for submit@debbugs.gnu.org; Thu, 24 Aug 2023 08:08:03 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:41772) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qZ984-0003cH-SA for 65451@debbugs.gnu.org; Thu, 24 Aug 2023 08:08:01 -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 1qZ97v-0004d2-2z; Thu, 24 Aug 2023 08:07:51 -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=eTrDmLGP10kjtvPpCPGJSJXa1NsCrU4EkRbZUUtYlzY=; b=AgTzV5/V7YQa 39qzglV6+7AUcC0TcjgM3y0HE8kMIUIZjXcL036MhyTibro2ZbGE8iiaFhZ6lB36xpEuYfYLQGOJQ 4PzUZ1qKbqU8gIaoDaWQmnPWXsQzXNhx4GDIByL8uFkrDZ+rzduxVgBe+PSaR3Luf/9Ns0mvbeiHD F55qpdm/zipXx2HZhmYuWyhPgRk3mw7Y7O0RhveiqWyZZ0rGin6pwRz8EZF8x/INpoDsqsblTKh5G btPswb5EZlBJztbswrmCO6Nd2yZzjB6YTEQbllQbYhrYiFBBNi3aAOuRaTZA5ASW+u7wwe2ayUUcq o2pxbLuHG8tZ8e27bTirxg==; In-Reply-To: <871qfsel8q.fsf@localhost> (message from Ihor Radchenko on Thu, 24 Aug 2023 11:24:37 +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:268328 Archived-At: > From: Ihor Radchenko > Cc: casouri@gmail.com, 65451@debbugs.gnu.org > Date: Thu, 24 Aug 2023 11:24:37 +0000 > > Eli Zaretskii writes: > > > Exposing buffer text changes to Lisp is inherently dangerous, because > > Lisp code can do anything and everything in these hooks, and many > > packages already do. The fact that we allow this via those two hooks > > is unfortunate as it is, but adding more opportunities for Lisp to do > > potentially dangerous stuff, and doing that on a lower level, where > > the buffer object is sometimes in a state that is not 100% consistent, > > is unwise, to say the least. It will make Emacs much less stable. > > No, thanks. > > I can see the danger running lisp code while buffer state is transient. > > 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? Or how about explaining how is the (updated) AST used, i.e. who are the clients of the AST updates, and what do they do when the AST changes?