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: Thu, 08 Dec 2022 08:47:13 +0200 Message-ID: <83zgby2xzi.fsf@gnu.org> References: <87r0xlbjg6.fsf@miha-pc> <5F7AE71F-0327-409E-BCE9-310E1980C17A@gmail.com> <8335a0lept.fsf@gnu.org> <22B4F037-2979-4C65-8917-26D17CFBED0A@gnu.org> <83a64197ny.fsf@gnu.org> <0973FBCA-DFBE-4FF7-9052-2B60D2FC81DC@gmail.com> <83tu287ml3.fsf@gnu.org> <77899171-04F5-4BB2-BE26-4C999DAB0CA0@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="40537"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59693@debbugs.gnu.org, monnier@iro.umontreal.ca, miha@kamnitnik.top To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 08 07:48:29 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 1p3Ahn-000AG4-K3 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 08 Dec 2022 07:48:27 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p3AhT-0000cs-Rs; Thu, 08 Dec 2022 01:48:07 -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 1p3AhO-0000cg-GE for bug-gnu-emacs@gnu.org; Thu, 08 Dec 2022 01:48:02 -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 1p3AhO-0002s4-7A for bug-gnu-emacs@gnu.org; Thu, 08 Dec 2022 01:48:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p3AhN-0004jm-NH for bug-gnu-emacs@gnu.org; Thu, 08 Dec 2022 01:48: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: Thu, 08 Dec 2022 06:48: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.167048205618201 (code B ref 59693); Thu, 08 Dec 2022 06:48:01 +0000 Original-Received: (at 59693) by debbugs.gnu.org; 8 Dec 2022 06:47:36 +0000 Original-Received: from localhost ([127.0.0.1]:54774 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3Agy-0004jV-F5 for submit@debbugs.gnu.org; Thu, 08 Dec 2022 01:47:36 -0500 Original-Received: from eggs.gnu.org ([209.51.188.92]:41738) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p3Agu-0004jP-Kr for 59693@debbugs.gnu.org; Thu, 08 Dec 2022 01:47:35 -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 1p3Agn-0002np-IH; Thu, 08 Dec 2022 01:47:25 -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=8TxXK1p2oXIjnpYKr7eAXD3nKZ5zO7P1X+rvDGQe4uo=; b=XooUEEXwasKS3DM2RbV9 px9YsXeb6YuC2u8UtQZiHWIry8pSk8FI2ln3Z0AcrvZaermREsK/LZCsM8ISnmb39642fhDCeS+j6 PbJGuW4MrDDTSgYIuWn50zGNvTPSsvhYjPIEvZkAfnJWrgmGksfQQK5MDX4ZBvp3LU1MpqhBJ9kpS IE8wCsLlNXAuSNCMV0oD5wPIg7ap6Sll5nUN+NJ+vB0uaG1EdbNWMvih6wjUQamsTIcuZW+bObdJC ZzYjmq2HWNhPrGh5jnoCFqtjk7h3Fn4wHkBn7ruuVx7bBDje9ze6/QGqzVHnMZsAiJnz117ysMgCh xd0kIIq+7sg1tw==; 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 1p3Agm-0002bU-BJ; Thu, 08 Dec 2022 01:47:24 -0500 In-Reply-To: <77899171-04F5-4BB2-BE26-4C999DAB0CA0@gmail.com> (message from Yuan Fu on Wed, 7 Dec 2022 15:13:19 -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:250244 Archived-At: > From: Yuan Fu > Date: Wed, 7 Dec 2022 15:13:19 -0800 > Cc: Stefan Monnier , > 59693@debbugs.gnu.org, > miha@kamnitnik.top > > >> 1. Only allow base buffer to have parsers, no change is needed for insdel.c, treesit_record_change can find the base buffer and update its parsers. We can ask indirect buffers to use their base buffer’s parser. Unless the base buffer is narrowed, I think it will work fine. > > > > I think this is fine, but we need to document it. > > > >> I remember that there were a discussion along the lines of user-narrow vs low-level narrow, what was the outcome of that discussion? > > > > Nothing in particular, and I don't think it's relevant. If some mode needs > > to widen, it can. > > > > Thanks. > > Here is a patch that does #1. Thanks, a few minor comments for documentation below. > +If @var{buffer} (or the current buffer) is an indirect buffer, its > +base buffer is used instead. That is, indirect buffers uses their ^^^^^^^^^^^^^^^^^^^^^ "use", in plural. > @@ -447,7 +455,9 @@ Using Parser > @defun treesit-parser-list &optional buffer > This function returns the parser list of @var{buffer}. If > @var{buffer} is @code{nil} or omitted, it defaults to the current > -buffer. > +buffer. If @var{buffer} (or the current buffer) is an indirect ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ I'd say more concisely If that buffer is an indirect buffer, ... And please add a cross-reference to the node where indirect buffers are described. > +buffer, its base buffer is used instead. That is, indirect buffers > +uses their base buffer's parsers. ^^^^ "use". > + Parsers in indirect buffers: We make indirect buffers to share the > + parser of its base buffer. See bug#59693 for reasoning. */ I'd rather have a short summary of the reasoning here than ask the readers to go to the bug tracker and read a long discussion. Just explain why indirect buffers present a problem for a parser, and then say that we decided to do this as the easiest, simplest solution. > +If BUFFER (or the current buffer) is an indirect buffer, its base > +buffer is used instead. That is, indirect buffers uses their base ^^^^ "use" > +buffer's parsers. If the base buffer is narrowed, an indirect buffer > +might not be able to retrieve information of the portion of the buffer > +text that are invisible in the base buffer. Lisp programs should > +widen as necessary should they want to use a parser in an indirect > +buffer. */) Here I would remove the second sentence: it is appropriate for the manual, but is redundant in the doc string, since the next sentence says it all. > @@ -1329,7 +1345,10 @@ DEFUN ("treesit-parser-list", > Ftreesit_parser_list, Streesit_parser_list, > 0, 1, 0, > doc: /* Return BUFFER's parser list. > -BUFFER defaults to the current buffer. */) > + > +BUFFER defaults to the current buffer. If BUFFER (or the current > +buffer) is an indirect buffer, its base buffer is used instead. That > +is, indirect buffers uses their base buffer's parsers. */) ^^^^ "use" Otherwise, LGTM.