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#59693: 29.0.50; treesitter in base buffer doesn't respond to modifications in indirect buffer correctly Date: Fri, 02 Dec 2022 10:33:31 +0200 Message-ID: <83y1rqfbms.fsf@gnu.org> References: <87r0xlbjg6.fsf@miha-pc> <5F7AE71F-0327-409E-BCE9-310E1980C17A@gmail.com> <8335a0lept.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="40162"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59693@debbugs.gnu.org, miha@kamnitnik.top To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 02 09:35:27 2022 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 1p11W3-000A9l-1V for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 02 Dec 2022 09:35:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p11Vo-0007UQ-3v; Fri, 02 Dec 2022 03:35:12 -0500 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 1p11Ve-0007TD-30 for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 03:35:05 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p11Vd-0004tb-Qq for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 03:35:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p11Vd-0003mx-Mp for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 03:35:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 02 Dec 2022 08:35:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59693 X-GNU-PR-Package: emacs Original-Received: via spool by 59693-submit@debbugs.gnu.org id=B59693.166997005714532 (code B ref 59693); Fri, 02 Dec 2022 08:35:01 +0000 Original-Received: (at 59693) by debbugs.gnu.org; 2 Dec 2022 08:34:17 +0000 Original-Received: from localhost ([127.0.0.1]:45333 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p11Uv-0003mK-8e for submit@debbugs.gnu.org; Fri, 02 Dec 2022 03:34:17 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:43584) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p11Up-0003mE-Sl for 59693@debbugs.gnu.org; Fri, 02 Dec 2022 03:34:15 -0500 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 1p11Uj-0004ja-0s; Fri, 02 Dec 2022 03:34:05 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From: Date; bh=1KjNOaG5rcLSh1Trp6NVK1E4IWTOmXCGXJnFbyopw44=; b=ZartiHCbRTQDWw4Ncnjh LdMHf6Rzb0Z41PYltNf1K1IE/G05pgNl17seul4cYMDk53mCyZltbWjVR3HwiHdtlAyZTCiCethM+ ym+hc6UL3TwE/zDuPzUknfkanMLAT4EIpwgQkQkJcC+7h81O8vqFt6EqcGnSAWTRbKzKiaLXQU2ic gwpbK5AYRSp3jbcITC9EoftdHa2eq6xD35QNRf9zkTjgdu47b+NXyip6jhbXtyh3FlxCnIjvmatgV vPTgf7G8mnrIFo652MRcxjPXNByCduWFxsQ/dsAy1LhEqyh+5Pq9WS4VwZK13DgrsLj4dT2GUDZE7 X+X6NucnUPLlBQ==; Original-Received: from [87.69.77.57] (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 1p11Ua-0001ZV-I4; Fri, 02 Dec 2022 03:34:04 -0500 In-Reply-To: (message from Yuan Fu on Thu, 1 Dec 2022 21:05:43 -0800) 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:249719 Archived-At: > From: Yuan Fu > Date: Thu, 1 Dec 2022 21:05:43 -0800 > Cc: miha@kamnitnik.top, > 59693@debbugs.gnu.org > > > In the insdel.c hooks where you record changes to buffer text, you should > > see if the buffer has a base_buffer, and if so, update any parsers of the > > base buffer as well. > > Actually there’s a little bit of problem. When we edit the base buffer, we would want to update the parsers in all of its indirect buffers as well, and AFAICT there is no pointer from base buffer to the indirect buffer, only the other way around. That's not the problem presented by the OP, though. > We don’t want indirect buffer and base buffers to share parsers, since they can have different narrowing, and semantically indirect buffers should share anything but the text with the base buffer. Yes, the parsers should not be shared. > How about this: we change current_buffer->parser_list from a plain list of parsers to a cons (PARSER-LIST . INDIRECT-PARSER-LIST), where PARSER-LIST is as before. But for base buffers, INDIRECT-PARSER-LIST includes all the parsers of its indirect buffers; and for indirect buffers, INDIRECT-PARSER-LIST is nil. You can maybe have the indirect buffers in the list, not their parsers. That could make it easier to access other treesit-related information of the indirect buffers, if needed.