From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" 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 22:49:14 -0500 Message-ID: References: <87r0xlbjg6.fsf@miha-pc> <5F7AE71F-0327-409E-BCE9-310E1980C17A@gmail.com> <8335a0lept.fsf@gnu.org> Reply-To: Stefan Monnier Mime-Version: 1.0 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="39538"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , 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 Mon Dec 05 04:50:22 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 1p22Un-000A4X-71 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Dec 2022 04:50:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p22UX-0003Wp-06; Sun, 04 Dec 2022 22:50:05 -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 1p22UV-0003Wa-Go for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 22:50: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 1p22UU-00021i-Lf for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 22:50:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p22UU-0006zd-71 for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 22:50:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 05 Dec 2022 03:50:02 +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.167021216826866 (code B ref 59693); Mon, 05 Dec 2022 03:50:02 +0000 Original-Received: (at 59693) by debbugs.gnu.org; 5 Dec 2022 03:49:28 +0000 Original-Received: from localhost ([127.0.0.1]:33265 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p22Tv-0006zG-Rz for submit@debbugs.gnu.org; Sun, 04 Dec 2022 22:49:28 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:56181) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p22Tr-0006z9-A6 for 59693@debbugs.gnu.org; Sun, 04 Dec 2022 22:49:25 -0500 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 7BB06442359; Sun, 4 Dec 2022 22:49:17 -0500 (EST) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id DD02B441F6E; Sun, 4 Dec 2022 22:49:15 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1670212155; bh=ecUvPxeKsJ8fmYQTIqgcLJxb7X6lfvbexxcRyZyYMLk=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=i8zixEy0PF3z7rJzVtUyddQItk0s57zOtCM9jdCuwx2gNo4dXQzRGrIoCz1fkcC+0 8nqbmR0U2TWxQnArGuHelYgya3mxqbQPh2DoK56G1RaJktipaRZ9R5nKUH1SgM9lNP cZQft48ptLuo6oZmVceALO6y+/8nZXBrRRqXu/r6fJKSYIgZky63pLiyYx+ZE5myMg XVek90HxK1cM7aHCOMa4epGHIzKfHvjdp2YKB2sAKngJUg5ulo1FW24mqCPIRU2cLB L1sS7bSMdZuCfRkKovGwXcMBypdKO/rUqCd0tkCe063odouaQPLIxlOgPnIppuv0Ju H2yKghUC+tJkg== Original-Received: from alfajor (unknown [45.72.193.52]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id A8C8B121C2D; Sun, 4 Dec 2022 22:49:15 -0500 (EST) In-Reply-To: (Yuan Fu's message of "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:249986 Archived-At: > Actually there=E2=80=99s a little bit of problem. When we edit the base b= uffer, 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 Background note: I consider indirect buffers an attractive nuisance and for this reason I think we should spend as little time as possible improving them. Instead we should encourage people to develop alternative approaches. I know we have a large number of bugs lurking in that area. E.g.: Emacs -Q M-x clone-indirect-buffer RET M-x fundamental-mode RET we see that `*scratch*` has lost its font-lock highlighting even though we changed major mode in the "other" buffer. Now go to `*scratch*` type some text: you see that font-lock properly updates the new code's highlighting. Then go to `*scratch*<2>` and type some more text: you should see that font-lock does *not* properly update the new code's highlighting in the base buffer. AFAICT this is the exact same bug as what you're seeing, just with font-lock instead of tree-sitter. [ Of course, for font-lock it's worse because font-lock uses text-properties (which are shared between the base and the its indirect buffers) so it simply can't do its job properly in indirect buffers. ] This bug has been with us since indirect buffers were invented, so it has very low priority, AFAIC. > Then base buffer can update all indirect buffers=E2=80=99 parsers, and in= direct > 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. Don't bother, please. Instead, I recommend you disallow the use of tree sitter in indirect buffers. And we should probably try and change `insdel.c` so it always runs the `after/before-change-functions` in the base buffer (this should fix the worst part of the problems). Stefan