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.devel Subject: Re: Treesit Regression In ec4d29c4494f32acf0ff7c5632a1d951d957f084 Date: Mon, 11 Sep 2023 15:19:43 -0700 Message-ID: <6182FD48-B83E-4C5D-85A5-946DB5408DC7@gmail.com> 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> <87o7i898af.fsf@dfreeman.email> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3731.700.6\)) 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="18124"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel To: Danny Freeman Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Sep 12 00:20:54 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 1qfpH4-0004Ta-DL for ged-emacs-devel@m.gmane-mx.org; Tue, 12 Sep 2023 00:20:54 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qfpGG-0004yB-5f; Mon, 11 Sep 2023 18:20:04 -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 1qfpGD-0004xZ-OP for emacs-devel@gnu.org; Mon, 11 Sep 2023 18:20:01 -0400 Original-Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qfpGA-0001R3-Vq for emacs-devel@gnu.org; Mon, 11 Sep 2023 18:20:01 -0400 Original-Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-68fdd5c1bbbso543231b3a.1 for ; Mon, 11 Sep 2023 15:19:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694470795; x=1695075595; darn=gnu.org; 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=vPOkq6ej4HxbA7LSHTJxAnZqnps5MMe+9X/J5i0BkLM=; b=qPB2KPd5cBx/6ndf6xSLaOr4P78+Zz7vch+wtl6JgCvFtJoTW0/kFa5aMLhVjPWEB0 l3knLOu3HwCzelx5IQs1l4N4QQYxxuBEVyTSBQjWalPTssHtK/FOpzM3kCHUkFT9DmA0 gXfK/SqloQ3NHPXOY6vg1M0qjjZZOpj3rto+9KX5vISQNFOy3XHXHvNZC+2zm6JNTcM7 cteUlCIDUl1Q4yMhHs8+mLwFs3QVh+HYckVqGRk7oswEWX5rPPwC3J67RJFIOkj2r+DL FziZva26pBYj6VVsgeeFrmE2M+ADot4pQDcpjcIB0gw/ySaOWPG8EAyLSTdJhp5+g8fy 4ObQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694470795; x=1695075595; 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=vPOkq6ej4HxbA7LSHTJxAnZqnps5MMe+9X/J5i0BkLM=; b=JTBbB+tCf5H/MK9fGGXYvY15yRpLohDIo6fkkbv6r7/b4EvX2MJQXAGykB9sSTJESJ ZhhwuctaxoJ5se9/3Fhm53KbIQF3+ZfvtTuofQ47FCYPylYBGOlF+6uePAnxGqpikeAc vXfedkacdbpI5i18Xh+SrwIFxLkc6WXE93M6P5Lf3dBc6dawLJ6pq4oOeko6/DsUgNGn PvMysATxzV9QwATwI6IWldYksUoJW6taL0i3B/h5oqLvxG9fSvbh5iA13tonLyWCu04+ xzDV4YGCI5E7qaQnOgyPPCE7ooIFQTieQjNkwtJt6mEZyzlqHtPVaYox8gxQCl2p2C5L 9pRg== X-Gm-Message-State: AOJu0YwKn/u2GeE3P2iZjkmK2Al/Kldrh62xYswL8Zczm74qRbVARgoh H5D7Q8EQf4eIK5O9NFwuXf11JwMr9c4= X-Google-Smtp-Source: AGHT+IGMJnjQJ06EZoNsAkOMKuFVlMysyo4zpG8MdPbbrhNDT4qLFdL9ufgVzLyQSQ/aiL0bMslGZg== X-Received: by 2002:a05:6a00:178d:b0:68a:6d34:474b with SMTP id s13-20020a056a00178d00b0068a6d34474bmr1081560pfg.15.1694470795204; Mon, 11 Sep 2023 15:19:55 -0700 (PDT) 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 x22-20020a62fb16000000b006887037cde6sm6059898pfm.60.2023.09.11.15.19.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 11 Sep 2023 15:19:54 -0700 (PDT) In-Reply-To: <87o7i898af.fsf@dfreeman.email> X-Mailer: Apple Mail (2.3731.700.6) Received-SPF: pass client-ip=2607:f8b0:4864:20::42f; envelope-from=casouri@gmail.com; helo=mail-pf1-x42f.google.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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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:310486 Archived-At: > On Sep 11, 2023, at 5:41 AM, Danny Freeman = wrote: >=20 >=20 > Yuan Fu writes: >=20 >>> 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. >=20 > 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 >=20 >=20 >> What I found is that, for some reason, = ts_tree_cursor_goto_first_child_for_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. >>=20 >> So now the question is, is there anything tree-sitter-clojure does = differently? Not saying it does, but that seems like a starting point. >=20 > 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. >=20 > 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. >=20 >> [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 (meaning not found). >=20 > I remember we found an issue with a similarly named function here >=20 > https://github.com/tree-sitter/tree-sitter/issues/2012 > https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D60127 >=20 > You ended up writing a workaround in emacs for this called > treesit_cursor_first_child_for_byte >=20 > 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. Duh, I can=E2=80=99t believe I completely forgot about this. Yes, this = is exactly it, thank you for binging it up. Before tree-sitter can fix = treesit_cursor_first_child_for_byte, I=E2=80=99ll just replicate the = workaround and we should be golden. I=E2=80=99ve pushed a fix to = emacs-29. Once master pulls from emacs-29, the problem should go away. BTW, I should=E2=80=99ve opened a bug report and move the discussion = there. But since we are mostly done here, and there=E2=80=99s another = bug report to refer to, there=E2=80=99s no need to do that now. Yuan=