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: Sun, 04 Dec 2022 09:46:13 +0200 Message-ID: <83sfhvbohm.fsf@gnu.org> References: <87r0xlbjg6.fsf@miha-pc> <5F7AE71F-0327-409E-BCE9-310E1980C17A@gmail.com> <8335a0lept.fsf@gnu.org> <83y1rqfbms.fsf@gnu.org> <5AEFFFF0-9788-4006-87A6-89AF741A33C4@gmail.com> 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="29494"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59693@debbugs.gnu.org, miha@kamnitnik.top To: Yuan Fu , Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Dec 04 08:47:26 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 1p1jig-0007RF-JJ for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 04 Dec 2022 08:47:26 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p1jiK-0005wH-PF; Sun, 04 Dec 2022 02:47:04 -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 1p1jiI-0005vt-Se for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 02:47:03 -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 1p1jiI-0007So-FB for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 02:47:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p1jiH-0008Gg-WE for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 02:47:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 04 Dec 2022 07:47: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.167014000331775 (code B ref 59693); Sun, 04 Dec 2022 07:47:01 +0000 Original-Received: (at 59693) by debbugs.gnu.org; 4 Dec 2022 07:46:43 +0000 Original-Received: from localhost ([127.0.0.1]:56013 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1jhz-0008GR-3r for submit@debbugs.gnu.org; Sun, 04 Dec 2022 02:46:43 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:42000) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1jhx-0008GL-3b for 59693@debbugs.gnu.org; Sun, 04 Dec 2022 02:46:41 -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 1p1jhp-0007KX-Uf; Sun, 04 Dec 2022 02:46:33 -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=sz7i0nZ4LGzmxVe+rB1ZQQpWbZbBTGjntui6Cx0gJEU=; b=r7XK8ci+MWPDvKdvkOCp uqPkg4iKRah7BmcjZpPImbHII10sHUMWZPSFC+OfInvWpyaYGleLqfUTVBNwi0cKZYSZ3DfHwf/d/ 4vPx1rSvWQQBt24X2i2Psn624oqlBUcoILJ22kTBgvUfF29djrDcvWhz4jLIqfztJbkW2uM2Rafhu EPau7PYI2rmvDo5jEpIkdgPsno6grA9JLyO+tAxUZrJMgE6GEXCTGpTi2JrGZQYi6xVlTatupY1Of 5ADTETNfKWw8aHf3RbnO8IPE5fpnc/8BliECq0JQFfJ3pyk7QXVDccKDlQbICKans3D+m8DS9Yiak VaEGZsVIt8eB+g==; 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 1p1jhp-0003KC-2N; Sun, 04 Dec 2022 02:46:33 -0500 In-Reply-To: (message from Yuan Fu on Sat, 3 Dec 2022 23:20:59 -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:249904 Archived-At: > From: Yuan Fu > Date: Sat, 3 Dec 2022 23:20:59 -0800 > Cc: miha@kamnitnik.top, > 59693@debbugs.gnu.org > > >>> 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. > > > > Good idea, it’s easier to know when to remove the reference with buffers, aka when buffer is killed. > > I now have a patch that fixes this problem. WDYT? I added a new buffer field since it’s cleaner than turning ts_parser_list into a cons, hopefully that’s not frowned upon. Thanks. If we are adding to the buffer object a field that holds the list of indirect buffers, then: . the name of the field should not include "treesit" in it, and it shouldn't be conditioned on HAVE_TREE_SITTER . I wonder if a flat list is a good idea, i.e. scalable enough? also, treesit_reap_indirect_buffers conses a lot as result . I vaguely remember that adding built-in fields to the buffer object had some caveats, but I don't recall the details (did you bootstrap?) Stefan, any comments on this? Are there better ideas of how to track buffer text changes in indirect buffers?