From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Danny Freeman Newsgroups: gmane.emacs.devel Subject: Re: Treesit Regression In ec4d29c4494f32acf0ff7c5632a1d951d957f084 Date: Mon, 11 Sep 2023 08:41:26 -0400 Message-ID: <87o7i898af.fsf@dfreeman.email> References: <87r0n7dt34.fsf@dfreeman.email> <68CFCC60-F71F-41E3-AF2A-E78E00EB3FD2@gmail.com> <8734zm4qin.fsf@dfreeman.email> <107166BF-6EC2-4D13-9BA4-A6C0DE1CA565@gmail.com> <945F818F-AA9B-402B-BCC7-53286EAD2C05@gmail.com> 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="12080"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel To: Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Sep 11 14:59:09 2023 Return-path: Envelope-to: ged-emacs-devel@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 1qfgVN-0002s9-UO for ged-emacs-devel@m.gmane-mx.org; Mon, 11 Sep 2023 14:59:07 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qfgUO-0001zR-7C; Mon, 11 Sep 2023 08:58:05 -0400 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 1qfgUL-0001zH-7g for emacs-devel@gnu.org; Mon, 11 Sep 2023 08:58:01 -0400 Original-Received: from out-212.mta0.migadu.com ([91.218.175.212]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qfgUF-000805-Kq for emacs-devel@gnu.org; Mon, 11 Sep 2023 08:58:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dfreeman.email; s=key1; t=1694437069; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=CMuP4qrHmyoVz4R4aTozWyg65XVld5S8RUIucKC7xbM=; b=GGaw4cOm7ZevlOpJ8UpbvBJwiqXwwPCOylIza6X9RB+Irekjvv1VBMCw+ILw3xnxKiSRfr cIvdYh3/7vYjvkXDYTUtvNvyuVh/T4vXJOy2PgugY1AGFuANQkB3Xy+ZqBD57xPekonVhw SKfSP0rXIrKdvXRFUn/epbpMIcUAbAo= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. In-reply-to: <945F818F-AA9B-402B-BCC7-53286EAD2C05@gmail.com> X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=91.218.175.212; envelope-from=danny@dfreeman.email; helo=out-212.mta0.migadu.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:310466 Archived-At: Yuan Fu writes: >> I take that back. It is indeed caused by that commit. I just had a wrong= Emacs build when testing. In that commit, ts_tree_cursor_goto_first_child_= for_byte seem to be the problem. Well I'm glad to know I am capable of building Emacs with the latest tree sitter. Not as glad that the problem still exists lol > What I found is that, for some reason, ts_tree_cursor_goto_first_child_fo= r_byte doesn=E2=80=99t always work > as expected in clojure [1]. In your example, if I evaluate (treesit-node-= parent (treesit-node-at > (point))) with point at the beginning of =E2=80=9Cdefn=E2=80=9D, =E2=80= =9Cfoo=E2=80=9D, =E2=80=9C[]=E2=80=9D, and =E2=80=9C1=E2=80=9D, only =E2=80= =9Cdefn=E2=80=9D correctly > evaluates to the parent node. I tried this in other modes like c-ts-mode,= but things seems to work > fine in all the few cases I tried. > > So now the question is, is there anything tree-sitter-clojure does differ= ently? Not saying it does, but that seems like a starting point. Maybe there is. The grammar has not changed in a couple months, and those things that did change were related to keyword literals, which are not involved in the example I've been using to reproduce this. Even knowing that. I will try to narrow the problem down even further, and see if I can find another grammar the exhibits this behavior. > [1] Instead of returning the first child node of NODE that extends beyond= POS, ts_tree_cursor_goto_first_child_for_byte (NODE, POS) returns false (m= eaning not found). I remember we found an issue with a similarly named function here https://github.com/tree-sitter/tree-sitter/issues/2012 https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D60127 You ended up writing a workaround in emacs for this called treesit_cursor_first_child_for_byte I don't think there is overlap between that change and this ec4d29 one. However, maybe there is overlap in the tree-sitter implementation? I'm not sure how to tell right now, but maybe this is an upstream tree-sitter problem that is just brought into the light by the commit in question here. --=20 Danny Freeman