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.devel Subject: Re: Exposing buffer text modifications to Lisp (was: Tree-sitter integration on feature/tree-sitter) Date: Sat, 18 Jun 2022 10:44:38 +0300 Message-ID: <83k09eo1p5.fsf@gnu.org> References: <2c2746e5f2558a87e8eab6f0914264a020173a9d.camel@pm.me> <27630AA3-8026-4E24-8852-ACCD9325B99D@gmail.com> <0E9E702B-B07C-4794-8498-29B9320E14CC@gmail.com> <871qvorqvv.fsf@localhost> <83tu8jq2vl.fsf@gnu.org> <87sfo37etn.fsf@localhost> <834k0jplcm.fsf@gnu.org> <878rpuwm9w.fsf@localhost> <83mteao3oj.fsf@gnu.org> <87edzmv3i0.fsf@localhost> Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15450"; mail-complaints-to="usenet@ciao.gmane.io" Cc: casouri@gmail.com, emacs-devel@gnu.org To: Ihor Radchenko Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Jun 18 09:46:08 2022 Return-path: Envelope-to: ged-emacs-devel@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 1o2T9k-0003qo-5L for ged-emacs-devel@m.gmane-mx.org; Sat, 18 Jun 2022 09:46:08 +0200 Original-Received: from localhost ([::1]:48162 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o2T9i-0000p0-Az for ged-emacs-devel@m.gmane-mx.org; Sat, 18 Jun 2022 03:46:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:60342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2T8N-0008Sz-A4 for emacs-devel@gnu.org; Sat, 18 Jun 2022 03:44:43 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:59504) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2T8M-0007PT-Px; Sat, 18 Jun 2022 03:44:42 -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=JMUExHBO/9JkV3WiDUz+VFXUAZEu8G6h9X5dsnImjrY=; b=kgDj79LFJfzF 8KeIY2bMmJW//iZn57SPQbYBsqMlV9gsdi6XWYv9nRyEsUig1Xlr9pYlo3L8RKqqCRaatDdaNAsYh mEYxrR7Vb02Z7J5FfeZwEHzjLBMMOrxjM2G8SGGuXMjHri89cosBzJYy1vHy8YrJK/W04m8B6gfIY lXlLw2IUNGA1P1FAD5pppkG6FE/zsZAxPn8PtAgmGHXPY9pbMfbGmDGzNMZRUN2hxDhm95rmXlAOS C2/+ttSJpKLZLyuR6gHBizd1u8tQdGyPrB+fRm8md0j1ejB3bf4hHFnj5l6HuBPcovvvd44AamNcV A/+VUmKQQ+foo1FStha3KA==; Original-Received: from [87.69.77.57] (port=1146 helo=home-c4e4a596f7) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o2T8L-0003Fm-Vq; Sat, 18 Jun 2022 03:44:42 -0400 In-Reply-To: <87edzmv3i0.fsf@localhost> (message from Ihor Radchenko on Sat, 18 Jun 2022 15:23:51 +0800) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:291342 Archived-At: > From: Ihor Radchenko > Cc: casouri@gmail.com, emacs-devel@gnu.org > Date: Sat, 18 Jun 2022 15:23:51 +0800 > > > Where you care about changes in buffer positions of the AST elements, > > markers should take care of most, if not all, of them. I presume you > > already do use markers wherever possible? if not, why not? Or what am > > I missing? > > Because lots of markers degrade Emacs regex search performance > tremendously. > > See https://list.orgmode.org/orgmode/scedec$2g0$1@ciao.gmane.io/ > and https://orgmode.org/list/87y21wkdwu.fsf@localhost AFAIU, the right fix for this is to fix performance degradation when a buffer has many markers, not avoiding the use of markers. Here's one conclusion from this discussion that indicates changes required to be done in core (other than a low-level modification hook for buffer text) to take care of your AST implementation. We already have a TODO item for making markers more efficient; any takers? > > Why would you miss significant changes if you base your implementation > > on buffer-modification hooks? If there are some situations where > > buffer text is modified in ways that are significant for the update > > of the AST, but buffer-modification hooks are NOT called, please > > describe some of those situations, so we will have something concrete > > to talk about. > > The situation is third-party code doing bloody murder with > > (with-silent-modifications > (insert "Some text not triggering modification hooks)) > > Another scenario is modifying text in indirect buffers created with > make-indirect-buffer. (where there is no chance to install > before/after-change-functions via clone-indirect-buffer-hook). In at least the latter case the idea for a proper solution was outlined by Stefan. For other cases, I think a careful discussion on a case by case basis will show the path towards solving each one of them. It is possible that some of them require further changes in core, but we won't know until we discuss the details of each case.