From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu 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, 1 Dec 2022 21:05:43 -0800 Message-ID: References: <87r0xlbjg6.fsf@miha-pc> <5F7AE71F-0327-409E-BCE9-310E1980C17A@gmail.com> <8335a0lept.fsf@gnu.org> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5929"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 59693@debbugs.gnu.org, miha@kamnitnik.top To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Dec 02 06:06:20 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 1p0yFg-0001JN-LH for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 02 Dec 2022 06:06:20 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p0yFQ-0001Ko-6C; Fri, 02 Dec 2022 00:06: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 1p0yFO-0001K4-KQ for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 00:06: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 1p0yFO-0005Uh-8P for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 00:06:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p0yFN-0007RL-Pb for bug-gnu-emacs@gnu.org; Fri, 02 Dec 2022 00:06:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 02 Dec 2022 05:06: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.166995755828592 (code B ref 59693); Fri, 02 Dec 2022 05:06:01 +0000 Original-Received: (at 59693) by debbugs.gnu.org; 2 Dec 2022 05:05:58 +0000 Original-Received: from localhost ([127.0.0.1]:44086 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0yFG-0007Qz-BU for submit@debbugs.gnu.org; Fri, 02 Dec 2022 00:05:58 -0500 Original-Received: from mail-pg1-f170.google.com ([209.85.215.170]:37863) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p0yFD-0007Qt-Tk for 59693@debbugs.gnu.org; Fri, 02 Dec 2022 00:05:52 -0500 Original-Received: by mail-pg1-f170.google.com with SMTP id v3so3503222pgh.4 for <59693@debbugs.gnu.org>; Thu, 01 Dec 2022 21:05:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=V+ZxkoyDzG3sCIwnQFPSNn3vW4+lnA3ZThborgx4+P0=; b=gbhV29kKBZBNy+WySHABZ6vihca5SiA/86B3cO2ZdbMwzftvF6aYe9rvhzG7h0zAY3 M1+gaZCUIPt4MOjhZELo8wpfD0pITLewcQOHROiUIjlb5KTWTHZwccgh90cEcW5bAHoF 11ZSvr9w8MkDaekZt71cB/rQ/+Ir94QIbpzFlbbonj7MvAJmxUorhrc3gqXXYf+fhGq5 cyhN30E+FGKGmzxQma+4kLd2MXQopZHgC7fANLQCu40LpghdZs7TyYQIGsfAMS4qHBs6 5hMxTJt23IWg7P2nT+UgJapdZFVDpUKVQw9pPV0PxrCsDFvD/fd/IdZZeR/Q8neDRmHW GXpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V+ZxkoyDzG3sCIwnQFPSNn3vW4+lnA3ZThborgx4+P0=; b=kmlIHyhO2gGCOxF5GrvcGXVfLaarA7g4dHCQ8uKRDqO5UP7W8K82DTVPtMIVfAI656 onO9M/p6jQUIAbSV5xtsPqn7D1dJid6+7FsxERiBsOX/m9L9+AYBLKEoXWo8hsf6AmPo f4XgRlo9O6qr/e7/a12eHIlEMbxjO+I0niQcF/iSm4IDZFoumHPdaRw/fx4rVtY91Ywp KbrJ6/Vb0wD2DFC3tQBM6dwTF8kEQ6MgFvyYA5X7xidTdVikU6Of2SrJq+XQs+fSws71 oaF5BSn162FJgwUl9tKXi+TwBf3tFgOYfWq41t3UE7idiEM9Q5z6kmgyeUwjMKYLq1uc yadQ== X-Gm-Message-State: ANoB5pkW1d8iMPKAqBOQB/crFG0mfi+FaxQsAYPTCqo3s8DT2SJMn+HD ZBME5DjAgFmQOrvfAlhONXIdtc2UthA= X-Google-Smtp-Source: AA0mqf51IPZgS4pZu+RrjugeXfodUeBtk/d2xF7AC61rcMKRtanKb1gaS/P/GfAyEAq3Oh/3sOgr5A== X-Received: by 2002:a63:f545:0:b0:477:e3ce:739c with SMTP id e5-20020a63f545000000b00477e3ce739cmr30213577pgk.363.1669957545710; Thu, 01 Dec 2022 21:05:45 -0800 (PST) Original-Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com. [172.117.161.177]) by smtp.gmail.com with ESMTPSA id x65-20020a623144000000b0056bfebfa6e4sm4083047pfx.190.2022.12.01.21.05.44 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Dec 2022 21:05:45 -0800 (PST) In-Reply-To: <8335a0lept.fsf@gnu.org> X-Mailer: Apple Mail (2.3696.120.41.1.1) 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:249698 Archived-At: > On Nov 30, 2022, at 6:05 AM, Eli Zaretskii wrote: >=20 >> Cc: 59693@debbugs.gnu.org >> From: Yuan Fu >> Date: Wed, 30 Nov 2022 02:17:14 -0800 >>=20 >> Thanks! I forgot about indirect buffers... We=E2=80=99ll need to make = sure to >> use the parsers in the original buffer when user edits the indirect >> buffer, or something like that. I need to look into how does indirect >> buffer works. >=20 > 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=E2=80=99s 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.=20 We don=E2=80=99t 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. 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. Then base buffer can update all indirect buffers=E2=80=99 parsers, and = indirect buffer can find its base buffer and update all the parsers, = including the base buffer=E2=80=99s parsers and other indirect = buffers=E2=80=99 parsers. Of course, treesit-parser-create and treesit-parser-delete needs to do = some extra work, but nothing complicated. Yuan=