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: Sat, 3 Dec 2022 23:20:59 -0800 Message-ID: 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 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_BC4D0109-2183-4F34-B0A6-745C75C74423" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37646"; 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 Sun Dec 04 08:22:06 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 1p1jKA-0009Yf-93 for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 04 Dec 2022 08:22:06 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p1jK7-0006m7-R3; Sun, 04 Dec 2022 02:22:03 -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 1p1jK6-0006lj-7E for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 02:22: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 1p1jK5-0005jE-QV for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 02:22:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p1jK5-00082U-Lf for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 02:22: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: Sun, 04 Dec 2022 07:22: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.167013847430878 (code B ref 59693); Sun, 04 Dec 2022 07:22:01 +0000 Original-Received: (at 59693) by debbugs.gnu.org; 4 Dec 2022 07:21:14 +0000 Original-Received: from localhost ([127.0.0.1]:55884 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1jJJ-00081y-Hh for submit@debbugs.gnu.org; Sun, 04 Dec 2022 02:21:13 -0500 Original-Received: from mail-pl1-f179.google.com ([209.85.214.179]:37610) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1jJH-00081s-GW for 59693@debbugs.gnu.org; Sun, 04 Dec 2022 02:21:12 -0500 Original-Received: by mail-pl1-f179.google.com with SMTP id m4so1269485pls.4 for <59693@debbugs.gnu.org>; Sat, 03 Dec 2022 23:21:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=yZdGWkeMsFAWmcXe4ZS+G4s8weUS4r2oa9Pq7YaWRoc=; b=g8ovlHpTX1Z05Id0v37zYJeAbdkfN7PzMMOPLiWOylWYIvEDPn846BOWfOacKje+gi +h7HojyT1zZaYuszjdRTUzSe2LtQAAlWH2Iyv9K3gKlh7a4UD9YQWGdbSqvzsPXh+jFM epkDr+J3pk0iY8GS/LmQTwMPvubH7NsShQ6cnUurOrmEH02OMH8i7LkWIRyRsD1W2n2c 7Hvf0Lvh2KlQTgPFgrJC/YRH4oS2opVN7ChvWoRhOStgDlIWkAaUSRZECzP1kzJGSOVW 8wckTe8VUUH/TUlLe+dNdKnxALblJe7dR4LMuKkr0DqRVO5u3qYLMf/ynFfGPpHkY6fT +VBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yZdGWkeMsFAWmcXe4ZS+G4s8weUS4r2oa9Pq7YaWRoc=; b=VIaW2wmHwkewWMhLdIXyCCaclcadOL719hdbTGacYp3LfL7jJ1lhWhADR9d7bFYqow TSfAfx5yoACEhFHyyhzvUAlEvLXRH8NvZdwTlXEnhaxJgt2sGNb4A2/X3qrZ+TVLBf5m KJvrpBCmQED/hapFmZouh2Lzc+HPHi5Voyn9FYvmfxFgQDmtmJnvkOE9vScHL8X0CKfR 80G4jl55/PBnGkAW+km9Ozfh6mmJBGmW+mqfftks2eByTdy+/GFiqvP5KaG+LY4+i7mL dZog5Df427LqGXmi9/6qrIF421P/zJEVxyd06CjtesDA6hdNTLMy/+BncxYVVZV42fZR 8eyQ== X-Gm-Message-State: ANoB5pnkeJMDME4EQfVWfwx3nLjEy5Dpx0LV88GJcCrl8gBw78wMtjJh 7/dZZz6KzpkZdVw/iDJg/LxwqRatVNY= X-Google-Smtp-Source: AA0mqf6kUbgNoCfT++rLoHdk0YQPdlztRBxOWgftpagWilOvy/PWaTnxAEieBdslCDDP0GIdOowUbA== X-Received: by 2002:a17:902:8e85:b0:189:8ec5:93fb with SMTP id bg5-20020a1709028e8500b001898ec593fbmr31155170plb.154.1670138465369; Sat, 03 Dec 2022 23:21:05 -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 d6-20020a170902654600b00188ef3ea2b6sm8225972pln.262.2022.12.03.23.21.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 03 Dec 2022 23:21:04 -0800 (PST) In-Reply-To: <5AEFFFF0-9788-4006-87A6-89AF741A33C4@gmail.com> 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:249901 Archived-At: --Apple-Mail=_BC4D0109-2183-4F34-B0A6-745C75C74423 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Dec 2, 2022, at 5:01 PM, Yuan Fu wrote: >=20 >=20 >=20 >> On Dec 2, 2022, at 12:33 AM, Eli Zaretskii wrote: >>=20 >>> From: Yuan Fu >>> Date: Thu, 1 Dec 2022 21:05:43 -0800 >>> Cc: miha@kamnitnik.top, >>> 59693@debbugs.gnu.org >>>=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. >>>=20 >>> 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 >>=20 >> That's not the problem presented by the OP, though. >=20 > Yeah, but they are the same problem in spirit, ie, parser not updated = when base/indirect buffer receive changes. >=20 >>=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. >>=20 >> Yes, the parsers should not be shared. >>=20 >>> 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. >>=20 >> 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. >=20 > Good idea, it=E2=80=99s 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=E2=80=99s cleaner than turning ts_parser_list into a = cons, hopefully that=E2=80=99s not frowned upon.=20 Yuan --Apple-Mail=_BC4D0109-2183-4F34-B0A6-745C75C74423 Content-Disposition: attachment; filename=indirect.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="indirect.patch" Content-Transfer-Encoding: quoted-printable =46rom=20cf8b52f5053cc42fac0ddcefc1b2771c5838cb0d=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Yuan=20Fu=20=0ADate:=20Sat,=20= 3=20Dec=202022=2021:18:31=20-0800=0ASubject:=20[PATCH=201/3]=20Refactor=20= treesit_record_change=0A=0AThis=20is=20part=20of=20the=20multi-commit=20= change=20to=20support=20indirect=0Abuffers=20(bug#59693).=0A=0ABesides=20= moving=20the=20code=20to=20a=20new=20function,=20I=20also=20removed=20= two=20lines:=0A=0A-=20=20=20=20=20=20CHECK_CONS=20(parser_list);=0A-=20=20= =20=20=20=20treesit_check_parser=20(lisp_parser);=0A=0Abecause=20they=20= could=20signal,=20and=20don't=20really=20make=20sense=20in=20a=20= internal=0Afunction.=20=20If=20we=20really=20want=20the=20checks,=20we=20= could=20add=20easserts.=0A=0A*=20src/treesit.c=20= (treesit_record_change_1):=20New=20function.=0A(treesit_record_change):=20= Move=20bulk=20of=20code=20to=20the=20new=20function.=0A---=0A=20= src/treesit.c=20|=20139=20= ++++++++++++++++++++++++++------------------------=0A=201=20file=20= changed,=2072=20insertions(+),=2067=20deletions(-)=0A=0Adiff=20--git=20= a/src/treesit.c=20b/src/treesit.c=0Aindex=204b150059fac..2ed9c2eafbe=20= 100644=0A---=20a/src/treesit.c=0A+++=20b/src/treesit.c=0A@@=20-690,6=20= +690,75=20@@=20treesit_tree_edit_1=20(TSTree=20*tree,=20ptrdiff_t=20= start_byte,=0A=20=20=20ts_tree_edit=20(tree,=20&edit);=0A=20}=0A=20=0A= +/*=20Update=20each=20parser=20in=20PARSER_LIST.=20=20*/=0A+static=20= inline=20void=0A+treesit_record_change_1=20(Lisp_Object=20parser_list,=20= ptrdiff_t=20start_byte,=0A+=09=09=09=20ptrdiff_t=20old_end_byte,=20= ptrdiff_t=20new_end_byte)=0A+{=0A+=20=20FOR_EACH_TAIL_SAFE=20= (parser_list)=0A+=20=20{=0A+=20=20=20=20Lisp_Object=20lisp_parser=20=3D=20= XCAR=20(parser_list);=0A+=20=20=20=20TSTree=20*tree=20=3D=20XTS_PARSER=20= (lisp_parser)->tree;=0A+=20=20=20=20/*=20See=20comment=20= (ref:visible-beg-null)=20if=20you=20wonder=20why=20we=20don't=0A+=20=20=20= =20=20=20=20update=20visible_beg/end=20when=20tree=20is=20NULL.=20=20*/=0A= +=20=20=20=20if=20(tree=20!=3D=20NULL)=0A+=20=20=20=20=20=20{=0A+=09= eassert=20(start_byte=20<=3D=20old_end_byte);=0A+=09eassert=20= (start_byte=20<=3D=20new_end_byte);=0A+=09/*=20Think=20the=20recorded=20= change=20as=20a=20delete=20followed=20by=20an=0A+=09=20=20=20insert,=20= and=20think=20of=20them=20as=20moving=20unchanged=20text=20back=0A+=09=20= =20=20and=20forth.=20=20After=20all,=20the=20whole=20point=20of=20= updating=20the=0A+=09=20=20=20tree=20is=20to=20update=20the=20position=20= of=20unchanged=20text.=20=20*/=0A+=09ptrdiff_t=20visible_beg=20=3D=20= XTS_PARSER=20(lisp_parser)->visible_beg;=0A+=09ptrdiff_t=20visible_end=20= =3D=20XTS_PARSER=20(lisp_parser)->visible_end;=0A+=09eassert=20= (visible_beg=20>=3D=200);=0A+=09eassert=20(visible_beg=20<=3D=20= visible_end);=0A+=0A+=09/*=20AFFECTED_START/OLD_END/NEW_END=20are=20= (0-based)=20offsets=20from=0A+=09=20=20=20VISIBLE_BEG.=20=20= min(visi_end,=20max(visi_beg,=20value))=20clips=0A+=09=20=20=20value=20= into=20[visi_beg,=20visi_end],=20and=20subtracting=20visi_beg=0A+=09=20=20= =20gives=20the=20offset=20from=20visi_beg.=20=20*/=0A+=09ptrdiff_t=20= start_offset=20=3D=20(min=20(visible_end,=0A+=09=09=09=09=20=20=20=20=20=20= =20max=20(visible_beg,=20start_byte))=0A+=09=09=09=09=20=20-=20= visible_beg);=0A+=09ptrdiff_t=20old_end_offset=20=3D=20(min=20= (visible_end,=0A+=09=09=09=09=09=20max=20(visible_beg,=20old_end_byte))=0A= +=09=09=09=09=20=20=20=20-=20visible_beg);=0A+=09ptrdiff_t=20= new_end_offset=20=3D=20(min=20(visible_end,=0A+=09=09=09=09=09=20max=20= (visible_beg,=20new_end_byte))=0A+=09=09=09=09=20=20=20=20-=20= visible_beg);=0A+=09eassert=20(start_offset=20<=3D=20old_end_offset);=0A= +=09eassert=20(start_offset=20<=3D=20new_end_offset);=0A+=0A+=09= treesit_tree_edit_1=20(tree,=20start_offset,=20old_end_offset,=0A+=09=09=09= =20=20=20=20=20new_end_offset);=0A+=09XTS_PARSER=20= (lisp_parser)->need_reparse=20=3D=20true;=0A+=09XTS_PARSER=20= (lisp_parser)->timestamp++;=0A+=0A+=09/*=20VISIBLE_BEG/END=20records=20= tree-sitter's=20range=20of=20view=20in=0A+=09=20=20=20the=20buffer.=20=20= We=20need=20to=20adjust=20them=20when=20tree-sitter's=0A+=09=20=20=20= view=20changes.=20=20*/=0A+=09ptrdiff_t=20visi_beg_delta;=0A+=09if=20= (old_end_byte=20>=20new_end_byte)=0A+=09=20=20/*=20Move=20backward.=20=20= */=0A+=09=20=20visi_beg_delta=20=3D=20(min=20(visible_beg,=20= new_end_byte)=0A+=09=09=09=20=20=20=20-=20min=20(visible_beg,=20= old_end_byte));=0A+=09else=0A+=09=20=20/*=20Move=20forward.=20=20*/=0A+=09= =20=20visi_beg_delta=20=3D=20(old_end_byte=20<=20visible_beg=0A+=09=09=09= =20=20=20=20?=20new_end_byte=20-=20old_end_byte=20:=200);=0A+=09= XTS_PARSER=20(lisp_parser)->visible_beg=20=3D=20visible_beg=20+=20= visi_beg_delta;=0A+=09XTS_PARSER=20(lisp_parser)->visible_end=20=3D=20= (visible_end=0A+=09=09=09=09=09=09=20+=20visi_beg_delta=0A+=09=09=09=09=09= =09=20+=20(new_end_offset=0A+=09=09=09=09=09=09=20=20=20=20-=20= old_end_offset));=0A+=09eassert=20(XTS_PARSER=20= (lisp_parser)->visible_beg=20>=3D=200);=0A+=09eassert=20(XTS_PARSER=20= (lisp_parser)->visible_beg=0A+=09=09=20<=3D=20XTS_PARSER=20= (lisp_parser)->visible_end);=0A+=20=20=20=20=20=20}=0A+=20=20}=0A+}=0A+=0A= =20/*=20Update=20each=20parser's=20tree=20after=20the=20user=20made=20an=20= edit.=20=20This=0A=20=20=20=20function=20does=20not=20parse=20the=20= buffer=20and=20only=20updates=20the=20tree,=20so=20it=0A=20=20=20=20= should=20be=20very=20fast.=20=20*/=0A@@=20-697,74=20+766,10=20@@=20= treesit_tree_edit_1=20(TSTree=20*tree,=20ptrdiff_t=20start_byte,=0A=20= treesit_record_change=20(ptrdiff_t=20start_byte,=20ptrdiff_t=20= old_end_byte,=0A=20=09=09=20=20=20=20=20=20=20ptrdiff_t=20new_end_byte)=0A= =20{=0A-=20=20Lisp_Object=20parser_list;=0A+=20=20Lisp_Object=20= parser_list=20=3D=20BVAR=20(current_buffer,=20ts_parser_list);=0A+=20=20= treesit_record_change_1=20(parser_list,=20start_byte,=0A+=09=09=09=20=20=20= old_end_byte,=20new_end_byte);=0A=20=0A-=20=20parser_list=20=3D=20BVAR=20= (current_buffer,=20ts_parser_list);=0A-=0A-=20=20FOR_EACH_TAIL_SAFE=20= (parser_list)=0A-=20=20=20=20{=0A-=20=20=20=20=20=20CHECK_CONS=20= (parser_list);=0A-=20=20=20=20=20=20Lisp_Object=20lisp_parser=20=3D=20= XCAR=20(parser_list);=0A-=20=20=20=20=20=20treesit_check_parser=20= (lisp_parser);=0A-=20=20=20=20=20=20TSTree=20*tree=20=3D=20XTS_PARSER=20= (lisp_parser)->tree;=0A-=20=20=20=20=20=20/*=20See=20comment=20= (ref:visible-beg-null)=20if=20you=20wonder=20why=20we=20don't=0A-=20=20=20= =20=20=20update=20visible_beg/end=20when=20tree=20is=20NULL.=20=20*/=0A-=20= =20=20=20=20=20if=20(tree=20!=3D=20NULL)=0A-=09{=0A-=09=20=20eassert=20= (start_byte=20<=3D=20old_end_byte);=0A-=09=20=20eassert=20(start_byte=20= <=3D=20new_end_byte);=0A-=09=20=20/*=20Think=20the=20recorded=20change=20= as=20a=20delete=20followed=20by=20an=0A-=09=20=20=20=20=20insert,=20and=20= think=20of=20them=20as=20moving=20unchanged=20text=20back=0A-=09=20=20=20= =20=20and=20forth.=20=20After=20all,=20the=20whole=20point=20of=20= updating=20the=0A-=09=20=20=20=20=20tree=20is=20to=20update=20the=20= position=20of=20unchanged=20text.=20=20*/=0A-=09=20=20ptrdiff_t=20= visible_beg=20=3D=20XTS_PARSER=20(lisp_parser)->visible_beg;=0A-=09=20=20= ptrdiff_t=20visible_end=20=3D=20XTS_PARSER=20(lisp_parser)->visible_end;=0A= -=09=20=20eassert=20(visible_beg=20>=3D=200);=0A-=09=20=20eassert=20= (visible_beg=20<=3D=20visible_end);=0A-=0A-=09=20=20/*=20= AFFECTED_START/OLD_END/NEW_END=20are=20(0-based)=20offsets=20from=0A-=09=20= =20=20=20=20VISIBLE_BEG.=20=20min(visi_end,=20max(visi_beg,=20value))=20= clips=0A-=09=20=20=20=20=20value=20into=20[visi_beg,=20visi_end],=20and=20= subtracting=20visi_beg=0A-=09=20=20=20=20=20gives=20the=20offset=20from=20= visi_beg.=20=20*/=0A-=09=20=20ptrdiff_t=20start_offset=20=3D=20(min=20= (visible_end,=0A-=09=09=09=09=09=20max=20(visible_beg,=20start_byte))=0A= -=09=09=09=09=20=20=20=20-=20visible_beg);=0A-=09=20=20ptrdiff_t=20= old_end_offset=20=3D=20(min=20(visible_end,=0A-=09=09=09=09=09=20=20=20= max=20(visible_beg,=20old_end_byte))=0A-=09=09=09=09=20=20=20=20=20=20-=20= visible_beg);=0A-=09=20=20ptrdiff_t=20new_end_offset=20=3D=20(min=20= (visible_end,=0A-=09=09=09=09=09=20=20=20max=20(visible_beg,=20= new_end_byte))=0A-=09=09=09=09=20=20=20=20=20=20-=20visible_beg);=0A-=09=20= =20eassert=20(start_offset=20<=3D=20old_end_offset);=0A-=09=20=20eassert=20= (start_offset=20<=3D=20new_end_offset);=0A-=0A-=09=20=20= treesit_tree_edit_1=20(tree,=20start_offset,=20old_end_offset,=0A-=09=09=09= =20=20=20=20=20=20=20new_end_offset);=0A-=09=20=20XTS_PARSER=20= (lisp_parser)->need_reparse=20=3D=20true;=0A-=09=20=20XTS_PARSER=20= (lisp_parser)->timestamp++;=0A-=0A-=09=20=20/*=20VISIBLE_BEG/END=20= records=20tree-sitter's=20range=20of=20view=20in=0A-=09=20=20=20=20=20= the=20buffer.=20=20We=20need=20to=20adjust=20them=20when=20tree-sitter's=0A= -=09=20=20=20=20=20view=20changes.=20=20*/=0A-=09=20=20ptrdiff_t=20= visi_beg_delta;=0A-=09=20=20if=20(old_end_byte=20>=20new_end_byte)=0A-=09= =20=20=20=20/*=20Move=20backward.=20=20*/=0A-=09=20=20=20=20= visi_beg_delta=20=3D=20(min=20(visible_beg,=20new_end_byte)=0A-=09=09=09=20= =20=20=20=20=20-=20min=20(visible_beg,=20old_end_byte));=0A-=09=20=20= else=0A-=09=20=20=20=20/*=20Move=20forward.=20=20*/=0A-=09=20=20=20=20= visi_beg_delta=20=3D=20(old_end_byte=20<=20visible_beg=0A-=09=09=09=20=20= =20=20=20=20?=20new_end_byte=20-=20old_end_byte=20:=200);=0A-=09=20=20= XTS_PARSER=20(lisp_parser)->visible_beg=20=3D=20visible_beg=20+=20= visi_beg_delta;=0A-=09=20=20XTS_PARSER=20(lisp_parser)->visible_end=20=3D=20= (visible_end=0A-=09=09=09=09=09=09=20=20=20+=20visi_beg_delta=0A-=09=09=09= =09=09=09=20=20=20+=20(new_end_offset=0A-=09=09=09=09=09=09=20=20=20=20=20= =20-=20old_end_offset));=0A-=09=20=20eassert=20(XTS_PARSER=20= (lisp_parser)->visible_beg=20>=3D=200);=0A-=09=20=20eassert=20= (XTS_PARSER=20(lisp_parser)->visible_beg=0A-=09=09=20=20=20<=3D=20= XTS_PARSER=20(lisp_parser)->visible_end);=0A-=09}=0A-=20=20=20=20}=0A=20= }=0A=20=0A=20/*=20Comment=20(ref:visible-beg-null)=20The=20purpose=20of=20= visible_beg/end=20is=20to=0A--=20=0A2.33.1=0A=0A=0A=46rom=20= 98623c2a5fa6776d63d341c9975f066d6849fff0=20Mon=20Sep=2017=2000:00:00=20= 2001=0AFrom:=20Yuan=20Fu=20=0ADate:=20Sat,=203=20Dec=20= 2022=2021:28:08=20-0800=0ASubject:=20[PATCH=202/3]=20Rename=20= ts_parser_list=20and=20add=20treesit_indirect_list=0A=0AThis=20is=20part=20= of=20the=20multi-commit=20change=20to=20support=20indirect=20buffers=20= in=0Atree-sitter=20(bug#59693).=0A=0Ats_parser_list=20dodged=20the=20= prefix=20rename=20from=20ts_=20to=20treesit_,=20so=20I=0Atook=20the=20= opportunity=20to=20bring=20it=20to=20justice.=0A=0A*=20src/buffer.c=20= (bset_ts_parser_list):=20Rename.=0A(bset_treesit_indirect_list):=20New=20= function.=0A(reset_buffer,=20init_buffer_once):=20Initialize=20= treesit_indirect_list.=0ARename=20ts_parser_list.=0A=0A*=20src/buffer.h=20= (struct=20buffer):=20Add=20treesit_indirect_list.=20=20Rename=0A= ts_parser_list.=0A=0A*=20src/treesit.c=20(treesit_record_change_1)=0A= (Ftreesit_parser_create)=0A(Ftreesit_parser_delete)=0A= (Ftreesit_parser_list):=20Rename=20ts_parser_list.=0A---=0A=20= src/buffer.c=20=20|=2018=20+++++++++++++-----=0A=20src/buffer.h=20=20|=20= =207=20++++++-=0A=20src/treesit.c=20|=2013=20+++++++------=0A=203=20= files=20changed,=2026=20insertions(+),=2012=20deletions(-)=0A=0Adiff=20= --git=20a/src/buffer.c=20b/src/buffer.c=0Aindex=20= 71be7ed9e13..d7dd2c3a2d8=20100644=0A---=20a/src/buffer.c=0A+++=20= b/src/buffer.c=0A@@=20-233,9=20+233,14=20@@=20bset_extra_line_spacing=20= (struct=20buffer=20*b,=20Lisp_Object=20val)=0A=20}=0A=20#ifdef=20= HAVE_TREE_SITTER=0A=20static=20void=0A-bset_ts_parser_list=20(struct=20= buffer=20*b,=20Lisp_Object=20val)=0A+bset_treesit_parser_list=20(struct=20= buffer=20*b,=20Lisp_Object=20val)=0A=20{=0A-=20=20b->ts_parser_list_=20=3D= =20val;=0A+=20=20b->treesit_parser_list_=20=3D=20val;=0A+}=0A+static=20= void=0A+bset_treesit_indirect_list=20(struct=20buffer=20*b,=20= Lisp_Object=20val)=0A+{=0A+=20=20b->treesit_indirect_list_=20=3D=20val;=0A= =20}=0A=20#endif=0A=20static=20void=0A@@=20-1066,7=20+1071,8=20@@=20= reset_buffer=20(register=20struct=20buffer=20*b)=0A=20=20=20= bset_cursor_type=20(b,=20BVAR=20(&buffer_defaults,=20cursor_type));=0A=20= =20=20bset_extra_line_spacing=20(b,=20BVAR=20(&buffer_defaults,=20= extra_line_spacing));=0A=20#ifdef=20HAVE_TREE_SITTER=0A-=20=20= bset_ts_parser_list=20(b,=20Qnil);=0A+=20=20bset_treesit_parser_list=20= (b,=20Qnil);=0A+=20=20bset_treesit_indirect_list=20(b,=20Qnil);=0A=20= #endif=0A=20=0A=20=20=20b->display_error_modiff=20=3D=200;=0A@@=20= -4692,7=20+4698,8=20@@=20init_buffer_once=20(void)=0A=20=20=20= XSETFASTINT=20(BVAR=20(&buffer_local_flags,=20cursor_type),=20idx);=20= ++idx;=0A=20=20=20XSETFASTINT=20(BVAR=20(&buffer_local_flags,=20= extra_line_spacing),=20idx);=20++idx;=0A=20#ifdef=20HAVE_TREE_SITTER=0A-=20= =20XSETFASTINT=20(BVAR=20(&buffer_local_flags,=20ts_parser_list),=20= idx);=20++idx;=0A+=20=20XSETFASTINT=20(BVAR=20(&buffer_local_flags,=20= treesit_parser_list),=20idx);=20++idx;=0A+=20=20XSETFASTINT=20(BVAR=20= (&buffer_local_flags,=20treesit_indirect_list),=20idx);=20++idx;=0A=20= #endif=0A=20=20=20XSETFASTINT=20(BVAR=20(&buffer_local_flags,=20= cursor_in_non_selected_windows),=20idx);=20++idx;=0A=20=0A@@=20-4763,7=20= +4770,8=20@@=20init_buffer_once=20(void)=0A=20=20=20bset_cursor_type=20= (&buffer_defaults,=20Qt);=0A=20=20=20bset_extra_line_spacing=20= (&buffer_defaults,=20Qnil);=0A=20#ifdef=20HAVE_TREE_SITTER=0A-=20=20= bset_ts_parser_list=20(&buffer_defaults,=20Qnil);=0A+=20=20= bset_treesit_parser_list=20(&buffer_defaults,=20Qnil);=0A+=20=20= bset_treesit_indirect_list=20(&buffer_defaults,=20Qnil);=0A=20#endif=0A=20= =20=20bset_cursor_in_non_selected_windows=20(&buffer_defaults,=20Qt);=0A=20= =0Adiff=20--git=20a/src/buffer.h=20b/src/buffer.h=0Aindex=20= dded0cd98c1..984c5ee4437=20100644=0A---=20a/src/buffer.h=0A+++=20= b/src/buffer.h=0A@@=20-575,7=20+575,12=20@@=20#define=20BVAR(buf,=20= field)=20((buf)->field=20##=20_)=0A=20=0A=20#ifdef=20HAVE_TREE_SITTER=0A=20= =20=20/*=20A=20list=20of=20tree-sitter=20parsers=20for=20this=20buffer.=20= =20*/=0A-=20=20Lisp_Object=20ts_parser_list_;=0A+=20=20Lisp_Object=20= treesit_parser_list_;=0A+=20=20/*=20A=20list=20of=20indirect=20buffers=20= of=20this=20buffer=20whose=20tree-sitter=0A+=20=20=20=20=20parsers=20= wants=20to=20be=20updated=20with=20buffer=20content=20changes.=20=20This=0A= +=20=20=20=20=20list=20does=20not=20necessarily=20include=20all=20= indirect=20buffers=20of=20this=0A+=20=20=20=20=20buffer,=20and=20buffers=20= in=20this=20list=20are=20not=20necessarily=20alive.=20=20*/=0A+=20=20= Lisp_Object=20treesit_indirect_list_;=0A=20#endif=0A=20=20=20/*=20Cursor=20= type=20to=20display=20in=20non-selected=20windows.=0A=20=20=20=20=20=20t=20= means=20to=20use=20hollow=20box=20cursor.=0Adiff=20--git=20= a/src/treesit.c=20b/src/treesit.c=0Aindex=202ed9c2eafbe..9a076be67c5=20= 100644=0A---=20a/src/treesit.c=0A+++=20b/src/treesit.c=0A@@=20-766,7=20= +766,7=20@@=20treesit_record_change_1=20(Lisp_Object=20parser_list,=20= ptrdiff_t=20start_byte,=0A=20treesit_record_change=20(ptrdiff_t=20= start_byte,=20ptrdiff_t=20old_end_byte,=0A=20=09=09=20=20=20=20=20=20=20= ptrdiff_t=20new_end_byte)=0A=20{=0A-=20=20Lisp_Object=20parser_list=20=3D=20= BVAR=20(current_buffer,=20ts_parser_list);=0A+=20=20Lisp_Object=20= parser_list=20=3D=20BVAR=20(current_buffer,=20treesit_parser_list);=0A=20= =20=20treesit_record_change_1=20(parser_list,=20start_byte,=0A=20=09=09=09= =20=20=20old_end_byte,=20new_end_byte);=0A=20=0A@@=20-1279,7=20+1279,7=20= @@=20DEFUN=20("treesit-parser-create",=0A=20=20=20= treesit_check_buffer_size=20(buf);=0A=20=0A=20=20=20/*=20See=20if=20we=20= can=20reuse=20a=20parser.=20=20*/=0A-=20=20for=20(Lisp_Object=20tail=20=3D= =20BVAR=20(buf,=20ts_parser_list);=0A+=20=20for=20(Lisp_Object=20tail=20= =3D=20BVAR=20(buf,=20treesit_parser_list);=0A=20=20=20=20=20=20=20=20= NILP=20(no_reuse)=20&&=20!NILP=20(tail);=0A=20=20=20=20=20=20=20=20tail=20= =3D=20XCDR=20(tail))=0A=20=20=20=20=20{=0A@@=20-1306,7=20+1306,8=20@@=20= DEFUN=20("treesit-parser-create",=0A=20=09=09=09=09=09=09=20language);=0A= =20=0A=20=20=20/*=20Update=20parser-list.=20=20*/=0A-=20=20BVAR=20(buf,=20= ts_parser_list)=20=3D=20Fcons=20(lisp_parser,=20BVAR=20(buf,=20= ts_parser_list));=0A+=20=20Lisp_Object=20buffer_list=20=3D=20BVAR=20= (buf,=20treesit_parser_list);=0A+=20=20BVAR=20(buf,=20= treesit_parser_list)=20=3D=20Fcons=20(lisp_parser,=20buffer_list);=0A=20=0A= =20=20=20return=20lisp_parser;=0A=20}=0A@@=20-1323,8=20+1324,8=20@@=20= DEFUN=20("treesit-parser-delete",=0A=20=20=20Lisp_Object=20buffer=20=3D=20= XTS_PARSER=20(parser)->buffer;=0A=20=20=20struct=20buffer=20*buf=20=3D=20= XBUFFER=20(buffer);=0A=20=0A-=20=20BVAR=20(buf,=20ts_parser_list)=0A-=20=20= =20=20=3D=20Fdelete=20(parser,=20BVAR=20(buf,=20ts_parser_list));=0A+=20=20= BVAR=20(buf,=20treesit_parser_list)=0A+=20=20=20=20=3D=20Fdelete=20= (parser,=20BVAR=20(buf,=20treesit_parser_list));=0A=20=0A=20=20=20= XTS_PARSER=20(parser)->deleted=20=3D=20true;=0A=20=20=20return=20Qnil;=0A= @@=20-1350,7=20+1351,7=20@@=20DEFUN=20("treesit-parser-list",=0A=20=20=20= Lisp_Object=20return_list=20=3D=20Qnil;=0A=20=20=20Lisp_Object=20tail;=0A= =20=0A-=20=20tail=20=3D=20BVAR=20(buf,=20ts_parser_list);=0A+=20=20tail=20= =3D=20BVAR=20(buf,=20treesit_parser_list);=0A=20=0A=20=20=20= FOR_EACH_TAIL=20(tail)=0A=20=20=20=20=20return_list=20=3D=20Fcons=20= (XCAR=20(tail),=20return_list);=0A--=20=0A2.33.1=0A=0A=0A=46rom=20= 6f338f347f737531af8b29776f3745e653710f12=20Mon=20Sep=2017=2000:00:00=20= 2001=0AFrom:=20Yuan=20Fu=20=0ADate:=20Sat,=203=20Dec=20= 2022=2022:55:22=20-0800=0ASubject:=20[PATCH=203/3]=20Update=20= tree-sitter=20parser=20on=20both=20base=20and=20indirect=0A=20buffers=0A=0A= This=20is=20part=20of=20the=20multi-commit=20change=20to=20support=20= indirect=20buffers=20in=0Atree-sitter=20(bug#59693).=0A=0AIn=20this=20= commit=20we=20finally=20share=20the=20buffer=20change=20across=20all=20= base=20and=0Aindirect=20buffers.=20=20I=20also=20fixed=20a=20bug=20in=20= Ftreesit_parser_create=20where=0Awe=20unconditionally=20use=20the=20= current=20buffer=20when=20creating=20the=20parser,=0Aregardless=20of=20= the=20value=20of=20the=20BUFFER=20parameter.=0A=0A*=20src/treesit.c=20= (treesit_reap_indirect_buffers):=20New=20function.=0A= (treesit_record_change):=20Update=20all=20parsers=20in=20both=20the=20= base=20buffer=0Aand=20its=20indirect=20buffers.=0A= (Ftreesit_parser_create):=20Add=20this=20buffer=20to=20its=20base=20= buffer's=0Atreesit_indirect_list.=0A(Ftreesit__indirect_buffer_list):=20= New=20function.=0A=0A*=20test/src/treesit-tests.el=20= (treesit-indirect-buffers):=20New=20test.=0A---=0A=20src/treesit.c=20=20=20= =20=20=20=20=20=20=20=20=20=20|=2090=20= +++++++++++++++++++++++++++++++++++++--=0A=20test/src/treesit-tests.el=20= |=2063=20+++++++++++++++++++++++++++=0A=202=20files=20changed,=20149=20= insertions(+),=204=20deletions(-)=0A=0Adiff=20--git=20a/src/treesit.c=20= b/src/treesit.c=0Aindex=209a076be67c5..c6ee0c3322f=20100644=0A---=20= a/src/treesit.c=0A+++=20b/src/treesit.c=0A@@=20-690,6=20+690,27=20@@=20= treesit_tree_edit_1=20(TSTree=20*tree,=20ptrdiff_t=20start_byte,=0A=20=20= =20ts_tree_edit=20(tree,=20&edit);=0A=20}=0A=20=0A+/*=20Reap=20deleted=20= buffers=20in=20the=20treesit_parser_list=20of=20BASE_BUFFER.=20=20*/=0A= +static=20inline=20void=0A+treesit_reap_indirect_buffers=20(struct=20= buffer=20*base_buffer)=0A+{=0A+=20=20eassert=20(base_buffer->base_buffer=20= =3D=3D=200);=0A+=20=20Lisp_Object=20buffer_list=20=3D=20BVAR=20= (base_buffer,=20treesit_indirect_list);=0A+=20=20Lisp_Object=20= new_buffer_list=20=3D=20Qnil;=0A+=0A+=20=20/*=20Go=20over=20the=20= current=20buffer=20list=20and=20build=20a=20new=20list=20with=20only=0A+=20= =20=20=20=20live=20buffers,=20and=20replace=20the=20old=20list=20with=20= the=20new=20list.=20=20*/=0A+=20=20FOR_EACH_TAIL_SAFE=20(buffer_list)=0A= +=20=20{=0A+=20=20=20=20Lisp_Object=20the_buffer=20=3D=20XCAR=20= (buffer_list);=0A+=20=20=20=20eassert=20(BUFFERP=20(the_buffer));=0A+=20=20= =20=20if=20(BUFFER_LIVE_P=20(XBUFFER=20(the_buffer)))=0A+=20=20=20=20=20=20= new_buffer_list=20=3D=20Fcons=20(the_buffer,=20new_buffer_list);=0A+=20=20= }=0A+=20=20new_buffer_list=20=3D=20Fnreverse=20(new_buffer_list);=0A+=20=20= BVAR=20(base_buffer,=20treesit_indirect_list)=20=3D=20new_buffer_list;=0A= +}=0A+=0A=20/*=20Update=20each=20parser=20in=20PARSER_LIST.=20=20*/=0A=20= static=20inline=20void=0A=20treesit_record_change_1=20(Lisp_Object=20= parser_list,=20ptrdiff_t=20start_byte,=0A@@=20-766,10=20+787,37=20@@=20= treesit_record_change_1=20(Lisp_Object=20parser_list,=20ptrdiff_t=20= start_byte,=0A=20treesit_record_change=20(ptrdiff_t=20start_byte,=20= ptrdiff_t=20old_end_byte,=0A=20=09=09=20=20=20=20=20=20=20ptrdiff_t=20= new_end_byte)=0A=20{=0A-=20=20Lisp_Object=20parser_list=20=3D=20BVAR=20= (current_buffer,=20treesit_parser_list);=0A+=20=20/*=20We=20always=20act=20= on=20the=20base=20buffer.=20=20If=20this=20buffer=20is=20an=20indirect=0A= +=20=20=20=20=20buffer,=20switch=20to=20its=20base=20buffer.=20=20*/=0A+=20= =20struct=20buffer=20*base_buffer=20=3D=20current_buffer;=0A+=20=20if=20= (current_buffer->base_buffer)=0A+=20=20=20=20base_buffer=20=3D=20= current_buffer->base_buffer;=0A+=0A+=20=20/*=20First=20update=20base=20= buffer's=20parsers.=20=20*/=0A+=20=20Lisp_Object=20parser_list=20=3D=20= BVAR=20(base_buffer,=20treesit_parser_list);=0A=20=20=20= treesit_record_change_1=20(parser_list,=20start_byte,=0A=20=09=09=09=20=20= =20old_end_byte,=20new_end_byte);=0A=20=0A+=20=20/*=20Then=20update=20= parsers=20of=20indirect=20buffers.=20=20*/=0A+=20=20Lisp_Object=20= buffer_list=20=3D=20BVAR=20(base_buffer,=20treesit_indirect_list);=0A+=20= =20bool=20need_reap=20=3D=20false;=0A+=20=20FOR_EACH_TAIL_SAFE=20= (buffer_list)=0A+=20=20{=0A+=20=20=20=20struct=20buffer=20*buffer=20=3D=20= XBUFFER=20(XCAR=20(buffer_list));=0A+=20=20=20=20if=20(BUFFER_LIVE_P=20= (buffer))=0A+=20=20=20=20=20=20{=0A+=09Lisp_Object=20parser_list=20=3D=20= BVAR=20(buffer,=20treesit_parser_list);=0A+=09treesit_record_change_1=20= (parser_list,=20start_byte,=0A+=09=09=09=09=20old_end_byte,=20= new_end_byte);=0A+=20=20=20=20=20=20}=0A+=20=20=20=20else=0A+=20=20=20=20= =20=20need_reap=20=3D=20true;=0A+=20=20}=0A+=0A+=20=20/*=20If=20we=20= encountered=20deleted=20indirect=20buffer=20above,=20remove=20it=20from=0A= +=20=20=20=20=20the=20indirect=20list.=20=20*/=0A+=20=20if=20(need_reap)=0A= +=20=20=20=20treesit_reap_indirect_buffers=20(base_buffer);=0A=20}=0A=20=0A= =20/*=20Comment=20(ref:visible-beg-null)=20The=20purpose=20of=20= visible_beg/end=20is=20to=0A@@=20-1270,7=20+1318,10=20@@=20DEFUN=20= ("treesit-parser-create",=0A=20=20=20CHECK_SYMBOL=20(language);=0A=20=20=20= struct=20buffer=20*buf;=0A=20=20=20if=20(NILP=20(buffer))=0A-=20=20=20=20= buf=20=3D=20current_buffer;=0A+=20=20=20=20{=0A+=20=20=20=20=20=20buf=20= =3D=20current_buffer;=0A+=20=20=20=20=20=20XSETBUFFER=20(buffer,=20= current_buffer);=0A+=20=20=20=20}=0A=20=20=20else=0A=20=20=20=20=20{=0A=20= =20=20=20=20=20=20CHECK_BUFFER=20(buffer);=0A@@=20-1301,14=20+1352,26=20= @@=20DEFUN=20("treesit-parser-create",=0A=20=20=20ts_parser_set_language=20= (parser,=20lang);=0A=20=0A=20=20=20/*=20Create=20parser.=20=20*/=0A-=20=20= Lisp_Object=20lisp_parser=20=3D=20make_treesit_parser=20(Fcurrent_buffer=20= (),=0A-=09=09=09=09=09=09=20parser,=20NULL,=0A+=20=20Lisp_Object=20= lisp_parser=20=3D=20make_treesit_parser=20(buffer,=20parser,=20NULL,=0A=20= =09=09=09=09=09=09=20language);=0A=20=0A=20=20=20/*=20Update=20= parser-list.=20=20*/=0A=20=20=20Lisp_Object=20buffer_list=20=3D=20BVAR=20= (buf,=20treesit_parser_list);=0A=20=20=20BVAR=20(buf,=20= treesit_parser_list)=20=3D=20Fcons=20(lisp_parser,=20buffer_list);=0A=20=0A= +=20=20/*=20If=20this=20buffer=20is=20an=20indirect=20buffer,=20add=20= this=20buffer=20to=20its=20base=0A+=20=20=20=20=20buffer's=20= treesit_indirect_list.=20=20*/=0A+=20=20if=20(buf->base_buffer)=0A+=20=20= =20=20{=0A+=20=20=20=20=20=20struct=20buffer=20*base_buffer=20=3D=20= buf->base_buffer;=0A+=20=20=20=20=20=20Lisp_Object=20indirect_list=20=3D=20= BVAR=20(base_buffer,=20treesit_indirect_list);=0A+=20=20=20=20=20=20if=20= (NILP=20(Fmemq=20(buffer,=20indirect_list)))=0A+=09{=0A+=09=20=20= indirect_list=20=3D=20Fcons=20(buffer,=20indirect_list);=0A+=09=20=20= BVAR=20(base_buffer,=20treesit_indirect_list)=20=3D=20indirect_list;=0A+=09= }=0A+=20=20=20=20}=0A+=0A=20=20=20return=20lisp_parser;=0A=20}=0A=20=0A= @@=20-1382,6=20+1445,24=20@@=20DEFUN=20("treesit-parser-language",=0A=20=20= =20return=20XTS_PARSER=20(parser)->language_symbol;=0A=20}=0A=20=0A= +DEFUN=20("treesit--indirect-buffer-list",=0A+=20=20=20=20=20=20=20= Ftreesit__indirect_buffer_list,=20Streesit__indirect_buffer_list,=0A+=20=20= =20=20=20=20=200,=201,=200,=0A+=20=20=20=20=20=20=20doc:=20/*=20This=20= INTERNAL=20function=20is=20used=20for=20testing=20only.=0A+It=20does=20= NOT=20return=20all=20the=20indirect=20buffers=20of=20BUFFER.=20=20*/)=0A= +=20=20(Lisp_Object=20buffer)=0A+{=0A+=20=20CHECK_BUFFER=20(buffer);=0A+=20= =20struct=20buffer=20*buf=20=3D=20XBUFFER=20(buffer);=0A+=20=20= Lisp_Object=20return_list=20=3D=20Qnil;=0A+=20=20Lisp_Object=20tail=20=3D=20= BVAR=20(buf,=20treesit_indirect_list);=0A+=0A+=20=20FOR_EACH_TAIL=20= (tail)=0A+=20=20=20=20return_list=20=3D=20Fcons=20(XCAR=20(tail),=20= return_list);=0A+=0A+=20=20return=20Freverse=20(return_list);=0A+}=0A+=0A= =20/***=20Parser=20API=20*/=0A=20=0A=20DEFUN=20= ("treesit-parser-root-node",=0A@@=20-3105,6=20+3186,7=20@@=20= syms_of_treesit=20(void)=0A=20=20=20defsubr=20(&Streesit_parser_list);=0A= =20=20=20defsubr=20(&Streesit_parser_buffer);=0A=20=20=20defsubr=20= (&Streesit_parser_language);=0A+=20=20defsubr=20= (&Streesit__indirect_buffer_list);=0A=20=0A=20=20=20defsubr=20= (&Streesit_parser_root_node);=0A=20=20=20/*=20defsubr=20= (&Streesit_parse_string);=20*/=0Adiff=20--git=20= a/test/src/treesit-tests.el=20b/test/src/treesit-tests.el=0Aindex=20= 80fde408cd3..bc8502531dc=20100644=0A---=20a/test/src/treesit-tests.el=0A= +++=20b/test/src/treesit-tests.el=0A@@=20-31,6=20+31,7=20@@=0A=20= (declare-function=20treesit-parser-create=20"treesit.c")=0A=20= (declare-function=20treesit-parser-delete=20"treesit.c")=0A=20= (declare-function=20treesit-parser-list=20"treesit.c")=0A= +(declare-function=20treesit--indirect-buffer-list=20"treesit.c")=0A=20= (declare-function=20treesit-parser-buffer=20"treesit.c")=0A=20= (declare-function=20treesit-parser-language=20"treesit.c")=0A=20=0A@@=20= -156,6=20+157,68=20@@=20treesit-node-api=0A=20=20=20=20=20=20=20(should=20= (treesit-node-eq=20root-node=20root-node))=0A=20=20=20=20=20=20=20= (should=20(not=20(treesit-node-eq=20root-node=20doc-node))))))=0A=20=0A= +(ert-deftest=20treesit-indirect-buffers=20()=0A+=20=20"Test=20basic=20= parsing=20routines."=0A+=20=20(skip-unless=20= (treesit-language-available-p=20'json))=0A+=20=20(let*=20((base-buffer=20= (get-buffer-create=20"*treesit=20test*"))=0A+=20=20=20=20=20=20=20=20=20= (indirect-1=20(make-indirect-buffer=20base-buffer=20"*treesit=20test=20= 1*"))=0A+=20=20=20=20=20=20=20=20=20(indirect-2=20(make-indirect-buffer=20= base-buffer=20"*treesit=20test=202*")))=0A+=20=20=20=20(unwind-protect=0A= +=20=20=20=20=20=20=20=20(progn=0A+=20=20=20=20=20=20=20=20=20=20= (treesit-parser-create=20'json=20base-buffer)=0A+=20=20=20=20=20=20=20=20= =20=20(treesit-parser-create=20'json=20indirect-1)=0A+=20=20=20=20=20=20=20= =20=20=20(treesit-parser-create=20'json=20indirect-2)=0A+=20=20=20=20=20=20= =20=20=20=20;;=201.=20Creating=20parsers=20in=20indirect=20buffers=20= should=20add=20them=0A+=20=20=20=20=20=20=20=20=20=20;;=20to=20the=20= base=20buffer's=20indirect=20list.=0A+=20=20=20=20=20=20=20=20=20=20= (should=20(equal=20(treesit--indirect-buffer-list=20base-buffer)=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (list=20indirect-2=20indirect-1)))=0A+=20=20=20=20=20=20=20=20=20=20;;=20= 2.=20Creating=20additional=20parsers=20in=20the=20indirect=20buffer=0A+=20= =20=20=20=20=20=20=20=20=20;;=20should=20not=20add=20duplicate=20= indirect=20buffers=20to=20the=20base=0A+=20=20=20=20=20=20=20=20=20=20;;=20= buffer's=20indirect=20list.=0A+=20=20=20=20=20=20=20=20=20=20= (treesit-parser-create=20'json=20indirect-2=20t)=0A+=20=20=20=20=20=20=20= =20=20=20(should=20(equal=20(treesit--indirect-buffer-list=20= base-buffer)=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20(list=20indirect-2=20indirect-1)))=0A+=20=20=20=20=20=20= =20=20=20=20;;=203.=20Edit=20the=20base=20buffer...=0A+=20=20=20=20=20=20= =20=20=20=20(with-current-buffer=20base-buffer=0A+=20=20=20=20=20=20=20=20= =20=20=20=20(insert=20"[1,2,3]"))=0A+=20=20=20=20=20=20=20=20=20=20;;=20= ...and=20parsers=20in=20the=20indirect=20buffer=20should=20be=20updated=20= too.=0A+=20=20=20=20=20=20=20=20=20=20(with-current-buffer=20indirect-1=0A= +=20=20=20=20=20=20=20=20=20=20=20=20(should=20(eq=20(treesit-node-end=20= (treesit-buffer-root-node))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=208))=0A+=20=20=20=20=20=20=20=20=20=20=20=20= ;;=204.=20Edit=20the=20indirect=20buffer...=0A+=20=20=20=20=20=20=20=20=20= =20=20=20(goto-char=202)=0A+=20=20=20=20=20=20=20=20=20=20=20=20(insert=20= "0,"))=0A+=20=20=20=20=20=20=20=20=20=20;;=20...and=20parsers=20in=20the=20= base=20and=20other=20indirect=20buffers=20should=20be=0A+=20=20=20=20=20=20= =20=20=20=20;;=20updated=20too.=0A+=20=20=20=20=20=20=20=20=20=20= (with-current-buffer=20base-buffer=0A+=20=20=20=20=20=20=20=20=20=20=20=20= (should=20(eq=20(treesit-node-end=20(treesit-buffer-root-node))=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=2010)))=0A= +=20=20=20=20=20=20=20=20=20=20(with-current-buffer=20indirect-2=0A+=20=20= =20=20=20=20=20=20=20=20=20=20(should=20(eq=20(treesit-node-end=20= (treesit-buffer-root-node))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=2010)))=0A+=20=20=20=20=20=20=20=20=20=20;;=20= 5.=20Kill=20an=20indirect=20buffer,=20editing=20the=20base=20buffer=20= and=20the=0A+=20=20=20=20=20=20=20=20=20=20;;=20other=20indirect=20= buffer=20should=20be=20fine.=0A+=20=20=20=20=20=20=20=20=20=20= (kill-buffer=20indirect-1)=0A+=20=20=20=20=20=20=20=20=20=20= (with-current-buffer=20base-buffer=0A+=20=20=20=20=20=20=20=20=20=20=20=20= (delete-region=20(point-min)=20(point-max)))=0A+=20=20=20=20=20=20=20=20=20= =20(with-current-buffer=20indirect-2=0A+=20=20=20=20=20=20=20=20=20=20=20= =20(insert=20"[1,2,3]"))=0A+=20=20=20=20=20=20=20=20=20=20= (with-current-buffer=20base-buffer=0A+=20=20=20=20=20=20=20=20=20=20=20=20= (should=20(eq=20(treesit-node-end=20(treesit-buffer-root-node))=0A+=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=208)))=0A= +=20=20=20=20=20=20=20=20=20=20(with-current-buffer=20indirect-2=0A+=20=20= =20=20=20=20=20=20=20=20=20=20(should=20(eq=20(treesit-node-end=20= (treesit-buffer-root-node))=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=208)))=0A+=20=20=20=20=20=20=20=20=20=20;;=20= 6.=20The=20killed=20indirect=20buffer=20should=20be=20removed=20from=20= the=0A+=20=20=20=20=20=20=20=20=20=20;;=20base=20buffer's=20indirect=20= list.=0A+=20=20=20=20=20=20=20=20=20=20(should=20(equal=20= (treesit--indirect-buffer-list=20base-buffer)=0A+=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(list=20indirect-2)))=0A= +=20=20=20=20=20=20=20=20=20=20(kill-buffer=20indirect-2)=0A+=20=20=20=20= =20=20=20=20=20=20(kill-buffer=20base-buffer))=0A+=20=20=20=20=20=20= (kill-buffer=20base-buffer)=0A+=20=20=20=20=20=20(kill-buffer=20= base-buffer)=0A+=20=20=20=20=20=20(kill-buffer=20base-buffer))))=0A+=0A=20= (ert-deftest=20treesit-query-api=20()=0A=20=20=20"Tests=20for=20query=20= API."=0A=20=20=20(skip-unless=20(treesit-language-available-p=20'json))=0A= --=20=0A2.33.1=0A=0A= --Apple-Mail=_BC4D0109-2183-4F34-B0A6-745C75C74423--