GNU bug report logs - #60127
treesit-end-of-defun: possible bug with clojure grammar

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Danny Freeman <Danny@HIDDEN>; Keywords: pending; dated Fri, 16 Dec 2022 18:53:01 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.

Message received at 60127 <at> debbugs.gnu.org:


Received: (at 60127) by debbugs.gnu.org; 17 Jan 2023 15:59:39 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 17 10:59:39 2023
Received: from localhost ([127.0.0.1]:38044 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pHoN9-0006Fx-C8
	for submit <at> debbugs.gnu.org; Tue, 17 Jan 2023 10:59:39 -0500
Received: from out-57.mta0.migadu.com ([91.218.175.57]:50748)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <danny@HIDDEN>) id 1pHoN7-0006Fp-5y
 for 60127 <at> debbugs.gnu.org; Tue, 17 Jan 2023 10:59:38 -0500
References: <A3552170-800F-4F96-8935-929F42941E89@HIDDEN>
 <83zgah2vz8.fsf@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dfreeman.email;
 s=key1; t=1673971173;
 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=y3uHXltXHSLFknm3nsGgAmn7gA3cwoxuqPaGML61ggU=;
 b=iedVc/9RGHfdFBk6iLfCHGFse7Stcfq0FoO3NxL++PGnNKS3Pu+aSikXzazRHFYWMODwL6
 VXSegwX5dcdbj5FEcBQFp+i1xyS/BpEhhie2h1ZXYXY8dJLJPiaKAE/YW60vbHQM4HCEkd
 UVhKRjvqpJGb8R+G0wAAcQmhYqdhYSw=
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Danny Freeman <danny@HIDDEN>
To: Eli Zaretskii <eliz@HIDDEN>
Subject: Re: bug#60127: treesit-end-of-defun: possible bug with clojure grammar
Date: Tue, 17 Jan 2023 10:49:45 -0500
In-reply-to: <83zgah2vz8.fsf@HIDDEN>
Message-ID: <87zgahgnj3.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Migadu-Flow: FLOW_OUT
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60127
Cc: Yuan Fu <casouri@HIDDEN>, 60127 <at> debbugs.gnu.org, dgutov@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Eli Zaretskii <eliz@HIDDEN> writes:

>> From: Yuan Fu <casouri@HIDDEN>
>> Date: Tue, 17 Jan 2023 01:30:22 -0800
>> Cc: 60127 <at> debbugs.gnu.org,
>>  Danny Freeman <danny@HIDDEN>,
>>  Eli Zaretskii <eliz@HIDDEN>
>>=20
>>=20
>> > I=E2=80=99d rather not use treesit_search_dfs, as it does much more wo=
rk than
>> > the current code. You know what, I can write a custom
>> > ts_node_first_child_for_byte and use that in Emacs, I=E2=80=99ve alrea=
dy done
>> > that for ts_node_parent anyway.
>>=20
>> I did that. I tested with the Clojure example and it works fine now.
>>=20
>> Eli, we don=E2=80=99t use ts_node_first_child_for_pos for now until tree=
-sitter
>> fix that function, should I removed the boilerplate for it or should I
>> leave it as-is? I saw you removed ts_node_parent when I did a similar
>> fix.
>
> It should be either removed or #ifdef'ed away, because otherwise GCC
> complains in the MS-Windows build about unused macro.

Thanks for tackling this problem on the Emacs end Yuan. I tested it out
with clojure-ts-mode and it seems to have addressed my problems.
I also took the liberty of linking to your commit in the tree-sitter
github issue in case the maintainers want to take a look at it.

--=20
Danny Freeman




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60127; Package emacs. Full text available.

Message received at 60127 <at> debbugs.gnu.org:


Received: (at 60127) by debbugs.gnu.org; 17 Jan 2023 12:20:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 17 07:20:44 2023
Received: from localhost ([127.0.0.1]:35997 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pHkxH-0007SX-RA
	for submit <at> debbugs.gnu.org; Tue, 17 Jan 2023 07:20:44 -0500
Received: from eggs.gnu.org ([209.51.188.92]:50210)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1pHkxE-0007SE-Lq
 for 60127 <at> debbugs.gnu.org; Tue, 17 Jan 2023 07:20:42 -0500
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pHkx8-00064C-9N; Tue, 17 Jan 2023 07:20:34 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=MIME-version:References:Subject:In-Reply-To:To:From:
 Date; bh=6DxQabcPlNIjkmggvdDcBIV334UFcf+sYBJd+G9QveY=; b=dSaerCvwJxx/bkHeObGW
 wue5ZSz7rTs/CUFlTbzYsXXJU5qhKjOebAWaMO+N2nUcJ4RtXw3BhtGAIY8RMGu2VpG6Xv7IJ1Gm4
 KiYkwI5FIr+cVBeEVYvzAzOaGkC+YwtFgbKBlssYBcN6rSU6yPHbe4bSTDcUDe9/5pp5WO9z3dpeK
 RfJ9zF3czDD8IWu00lHjadqGJ+P78wd8+5LpiHNgUFaFcKNwCH8did7rgI2/Epib9aVF0GW/VodPV
 QwwBH9CTRSxOnLZfydJxujfic0xTr6uPmrfB7lnxe6+IQUhcW9EJ5+2NpwtsKY+ywts5nBixYpT3r
 WT+IaMqfbBHPQA==;
Received: from [87.69.77.57] (helo=home-c4e4a596f7)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <eliz@HIDDEN>)
 id 1pHkx7-0004ka-Eh; Tue, 17 Jan 2023 07:20:34 -0500
Date: Tue, 17 Jan 2023 14:20:43 +0200
Message-Id: <83zgah2vz8.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Yuan Fu <casouri@HIDDEN>
In-Reply-To: <A3552170-800F-4F96-8935-929F42941E89@HIDDEN> (message from
 Yuan Fu on Tue, 17 Jan 2023 01:30:22 -0800)
Subject: Re: bug#60127: treesit-end-of-defun: possible bug with clojure grammar
References: <A3552170-800F-4F96-8935-929F42941E89@HIDDEN>
MIME-version: 1.0
Content-type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 60127
Cc: 60127 <at> debbugs.gnu.org, danny@HIDDEN, dgutov@HIDDEN
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

> From: Yuan Fu <casouri@HIDDEN>
> Date: Tue, 17 Jan 2023 01:30:22 -0800
> Cc: 60127 <at> debbugs.gnu.org,
>  Danny Freeman <danny@HIDDEN>,
>  Eli Zaretskii <eliz@HIDDEN>
> 
> 
> > I’d rather not use treesit_search_dfs, as it does much more work than
> > the current code. You know what, I can write a custom
> > ts_node_first_child_for_byte and use that in Emacs, I’ve already done
> > that for ts_node_parent anyway.
> 
> I did that. I tested with the Clojure example and it works fine now.
> 
> Eli, we don’t use ts_node_first_child_for_pos for now until tree-sitter
> fix that function, should I removed the boilerplate for it or should I
> leave it as-is? I saw you removed ts_node_parent when I did a similar
> fix.

It should be either removed or #ifdef'ed away, because otherwise GCC
complains in the MS-Windows build about unused macro.




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60127; Package emacs. Full text available.

Message received at 60127 <at> debbugs.gnu.org:


Received: (at 60127) by debbugs.gnu.org; 17 Jan 2023 09:30:33 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Jan 17 04:30:33 2023
Received: from localhost ([127.0.0.1]:35749 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pHiIb-0000WC-FF
	for submit <at> debbugs.gnu.org; Tue, 17 Jan 2023 04:30:33 -0500
Received: from mail-pj1-f48.google.com ([209.85.216.48]:53797)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <casouri@HIDDEN>) id 1pHiIZ-0000Vw-84
 for 60127 <at> debbugs.gnu.org; Tue, 17 Jan 2023 04:30:32 -0500
Received: by mail-pj1-f48.google.com with SMTP id d8so595079pjc.3
 for <60127 <at> debbugs.gnu.org>; Tue, 17 Jan 2023 01:30:31 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:from:to:cc:subject:date:message-id
 :reply-to; bh=3ITKihIQSCli07PwFr2mYsPxQfNYYXHGTPiNzDUeKl0=;
 b=kdsZ2e6HVmXhT42LAhW782128KtNDtssIObxWBcLhZ0C90yiwEfW1Aoabuur08c3Qu
 tJqSbTFRLDnvAULuujv0/gvRMZ6l038ak9+whrJI+eIhPlh7FENYdRMXiFvMCi8/AMmP
 MY4TevU6u85ldvFluYHTkMnhbWrFpYw8gWIOYIP4dot5EkuRUSbp9U6iFfAUl3nuMtvN
 J6WfKw7mh/0Ac/3fcWAfVm3Uo4GuGD1prrpYxrUMvbrNOxMK9krufmOG1w0uVSApUlr6
 aKBjnCSJMBAPzjq2M4DDf5qLy7VYtC2AU2iFjSVHHKx3ddu512mG2mbtqBQFxNahyIwk
 wLcQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=3ITKihIQSCli07PwFr2mYsPxQfNYYXHGTPiNzDUeKl0=;
 b=s10NuUpk2yKTRs6Xy8Uh4rLqa9rtq1z5SIr/ynJkukbNc5lf1Q1H56IxdtXLzEhEax
 yvKn2h6RDrWlZefXkQWpNyYwvvMQ2xhAeIPPGKuo0KaxB2WBuSKxIGmj8QA0HpeYJzwC
 F3qr/KFJGClKruOpAmLL/xM0iM3PyhFs5efiTTErexmTAq0CumyB0xakLvvVbEibYJme
 Bvib2H7GvxnuXPd8vpxT6NU/IDdiWDpc1BvTS+iYkvGexxa9YDvIg2eV9CpeGYY/uz3B
 +iWCA/cfs79nRGAH4LpJh2u5SL6WIQv4TOTwkkJ+f9qezdWK6SXp73mYZMKwh5I5IhxK
 aadA==
X-Gm-Message-State: AFqh2kojxBhqbDilwANm4BM4R5zeeQcqtxlOhqKmHgwWdznnTYeFYlb/
 LvhSaDYHkkvWk1lvNwwiUHU=
X-Google-Smtp-Source: AMrXdXsmhc3H+4FS2cVa1X4UqxANumE8fqs3rkiF111IQVo+3fz5eyoLGUVBM+tjYjhc/ww/jBQWZA==
X-Received: by 2002:a17:90a:a795:b0:226:3a18:177e with SMTP id
 f21-20020a17090aa79500b002263a18177emr2668924pjq.16.1673947825183; 
 Tue, 17 Jan 2023 01:30:25 -0800 (PST)
Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com.
 [172.117.161.177]) by smtp.gmail.com with ESMTPSA id
 x4-20020a634844000000b0044046aec036sm16932226pgk.81.2023.01.17.01.30.23
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Tue, 17 Jan 2023 01:30:24 -0800 (PST)
From: Yuan Fu <casouri@HIDDEN>
Content-Type: text/plain;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\))
Subject: Re: bug#60127: treesit-end-of-defun: possible bug with clojure grammar
Message-Id: <A3552170-800F-4F96-8935-929F42941E89@HIDDEN>
Date: Tue, 17 Jan 2023 01:30:22 -0800
To: Dmitry Gutov <dgutov@HIDDEN>
X-Mailer: Apple Mail (2.3696.120.41.1.1)
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60127
Cc: Eli Zaretskii <eliz@HIDDEN>, 60127 <at> debbugs.gnu.org,
 Danny Freeman <danny@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


> I=E2=80=99d rather not use treesit_search_dfs, as it does much more =
work than
> the current code. You know what, I can write a custom
> ts_node_first_child_for_byte and use that in Emacs, I=E2=80=99ve =
already done
> that for ts_node_parent anyway.

I did that. I tested with the Clojure example and it works fine now.

Eli, we don=E2=80=99t use ts_node_first_child_for_pos for now until =
tree-sitter
fix that function, should I removed the boilerplate for it or should I
leave it as-is? I saw you removed ts_node_parent when I did a similar
fix.

Yuan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60127; Package emacs. Full text available.

Message received at 60127 <at> debbugs.gnu.org:


Received: (at 60127) by debbugs.gnu.org; 16 Jan 2023 02:40:06 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 15 21:40:06 2023
Received: from localhost ([127.0.0.1]:60024 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pHFPq-0006gc-Cd
	for submit <at> debbugs.gnu.org; Sun, 15 Jan 2023 21:40:06 -0500
Received: from mail-pl1-f170.google.com ([209.85.214.170]:39849)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <casouri@HIDDEN>) id 1pHFPn-0006g2-Uk
 for 60127 <at> debbugs.gnu.org; Sun, 15 Jan 2023 21:40:05 -0500
Received: by mail-pl1-f170.google.com with SMTP id z13so1119845plg.6
 for <60127 <at> debbugs.gnu.org>; Sun, 15 Jan 2023 18:40:03 -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=IpuB4coZ6teP5+aOWNYMp8w5aRYYsqEm3UfnCfe1zfI=;
 b=BY6e0wQAkIcm2qcW3l9u2TDlYNTTk5mNaKDY7ssJTLS1jXYSIzY91Rhxx2OvobOhKA
 TkDYI2mTgd+cxey+XZD9X3EfMGoZolwueXCkkxnT1EA9VkT0d4z1WcvRfLbNCmZNgm3J
 8Y0nP03G6SKaeuILfl/4zU/nezvqbLkTINT7JKm7Vt8Ds/5bcejGbUVm2NyWmpXADKk2
 9lclvqOcO/TXAAODVd1iFEE+rBdkAd6IAx7kniAZ8HPgu2p92FM0oTekHKHnCjTDx4R+
 Ws8CQIy92lDt1yCVLeOTZqX1ou0fQMO7pSU0kxATZIVuCxADWjIdxfCMuvFEiX6cKSDe
 WAow==
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=IpuB4coZ6teP5+aOWNYMp8w5aRYYsqEm3UfnCfe1zfI=;
 b=nWP8rY0nEG2tBTzD770rAVynQVLggAS6vGNB9akAc9TGwCecwbPd/dpMiJleUhq9Vw
 4ztP+L0FJelhylbZ6P/0Huc/0nUY+Iq6nLYtGm1OpIrtBQ1ZYlaBbaeXVD7AoEEr6PB2
 kIYUpbC2OycNZsmoL0MTs+g8NhDX2g3mHLviR7nd5kQneWjyWXFjWGCihKMM9EOD0Buy
 w0nuG84pnejxgItU+8t0IBoatKV1nfdVwOsUsvQ4XLymVp0NcM0X6hu52W3ndD+9z6GX
 mghWW/XHgktzBydShFozUY55XXvBdSODeD/7qFhtOYhoS11CJ19d+5EW7Q0T/tn04T/m
 sIUw==
X-Gm-Message-State: AFqh2kp+L9Om7tZBscXoQuFlr1cE+Y4pJfgyDy4KgU3RihhFzaSA2Ozx
 uj86mMocAnHVUpXx24PPFvg=
X-Google-Smtp-Source: AMrXdXtKiz+V9HSq+AUKo5ozT7Is8noht8Ifc9QQMkJ5A1dWCAXXzzBSMlFg8gO/RD5ZwWP64hMSkA==
X-Received: by 2002:a05:6a20:669a:b0:b8:5eb4:a817 with SMTP id
 o26-20020a056a20669a00b000b85eb4a817mr4775549pzh.44.1673836798054; 
 Sun, 15 Jan 2023 18:39:58 -0800 (PST)
Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com.
 [172.117.161.177]) by smtp.gmail.com with ESMTPSA id
 bg7-20020a056a02010700b004785c24ffb4sm5816699pgb.26.2023.01.15.18.39.57
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Sun, 15 Jan 2023 18:39:57 -0800 (PST)
Content-Type: text/plain;
	charset=utf-8
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\))
Subject: Re: bug#60127: treesit-end-of-defun: possible bug with clojure grammar
From: Yuan Fu <casouri@HIDDEN>
In-Reply-To: <6a7f5a94-b2cd-c6b8-1267-87da1c6303e1@HIDDEN>
Date: Sun, 15 Jan 2023 18:39:56 -0800
Content-Transfer-Encoding: quoted-printable
Message-Id: <1B32D81E-3647-4FCA-A1C8-AFD8AFC96E78@HIDDEN>
References: <87sfhf5ghj.fsf@HIDDEN>
 <CD0C17BC-4F54-48EB-AF2A-5D7314845AD7@HIDDEN>
 <6a7f5a94-b2cd-c6b8-1267-87da1c6303e1@HIDDEN>
To: Dmitry Gutov <dgutov@HIDDEN>
X-Mailer: Apple Mail (2.3696.120.41.1.1)
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60127
Cc: 60127 <at> debbugs.gnu.org, Danny Freeman <danny@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)



> On Jan 15, 2023, at 5:56 PM, Dmitry Gutov <dgutov@HIDDEN> wrote:
>=20
> On 22/12/2022 10:55, Yuan Fu wrote:
>> Danny Freeman<danny@HIDDEN>  writes:
>>> Yuan,
>>>=20
>>>>> Thank you very much for this detailed report! This seems to be =
some
>>>>> problem with either tree-sitter or tree-sitter-clojure, where
>>>>> treesit-node-first-child-for-pos gives wrong result. We=E2=80=99ve =
had similar
>>>>> problem with bash before[1].
>>>>>=20
>>>>> At this point there aren=E2=80=99t much we can do in Emacs. If I =
find some time
>>>>> I=E2=80=99ll make a reproduce recipe and submit an issue on =
tree-sitter-clojure.
>>>>>=20
>>>>> [1]https://github.com/tree-sitter/tree-sitter-bash/issues/139
>>>>>=20
>>>>> Yuan
>>> I have a c program that I believe reproduces the problem. I'm not =
sure
>>> how we will go about fixing it in tree-sitter-clojure, but at least =
we
>>> have a minimal way to re-create it.
>>>=20
>>> Here is a link to the issue I created:
>>> https://github.com/sogaiu/tree-sitter-clojure/issues/32
>>> that also includes the c-program. I've also put it on my source hut
>>> =
https://paste.sr.ht/~dannyfreeman/8786059276c334036877159a5b0872cd2aa6fbc0=
 =20
>>> If you find the time, I would appreciate it if you could confirm my
>>> findings. I'm a little in over my head with this bug I'm afraid.
>> I think it=E2=80=99s pretty good (the reproduce), the author=E2=80=99s =
modified program
>> is even better. Let=E2=80=99s wait and see what tree-sitter=E2=80=99s =
author have to
>> say.
>=20
> Just to keep everyone of the same page:
>=20
> clojure-tree-sitter's author posted an issue to tree-sitter last week: =
https://github.com/tree-sitter/tree-sitter/issues/2012
>=20
> and, previously, he also suggested we might be able to work around it =
using treesit_search_dfs: =
https://github.com/sogaiu/tree-sitter-clojure/issues/32#issuecomment-13648=
30835

I=E2=80=99d rather not use treesit_search_dfs, as it does much more work =
than the current code. You know what, I can write a custom =
ts_node_first_child_for_byte and use that in Emacs, I=E2=80=99ve already =
done that for ts_node_parent anyway.

Yuan=




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60127; Package emacs. Full text available.

Message received at 60127 <at> debbugs.gnu.org:


Received: (at 60127) by debbugs.gnu.org; 16 Jan 2023 01:56:21 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Jan 15 20:56:21 2023
Received: from localhost ([127.0.0.1]:60004 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1pHEjU-0005fv-RS
	for submit <at> debbugs.gnu.org; Sun, 15 Jan 2023 20:56:21 -0500
Received: from mail-wr1-f44.google.com ([209.85.221.44]:33590)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <raaahh@HIDDEN>) id 1pHEjS-0005fg-Tu
 for 60127 <at> debbugs.gnu.org; Sun, 15 Jan 2023 20:56:19 -0500
Received: by mail-wr1-f44.google.com with SMTP id b5so4927919wrn.0
 for <60127 <at> debbugs.gnu.org>; Sun, 15 Jan 2023 17:56:18 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=content-transfer-encoding:in-reply-to:from:references:cc:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :sender:from:to:cc:subject:date:message-id:reply-to;
 bh=o//FlaQeU1f14nEA+MG0zkt0hZu7ebkH4HkHt/a/maY=;
 b=KyZWGpyptnxuFvWESuqFhaAQARm40gkh4f/w6AjRHY3Ji5RqGbY2TSFZcKqZf/rJ1U
 dxuoJMgHyLsYjDN4rptdPkqfdvXuZfhbcQmZNgThfJFv/l31Zjrsk7UkExMtHiX+ahp6
 T553/VsZmBWDsKXNO/aj1J8UJdLekuifai3HWh88gvA1R7BgOf5Rordli7uzz4TqwcmS
 7gDgbKa2HtBXyp6yamWYIWpC4B4fGU0R37JHBCSQnXDfwhOjlKqa5OUgalfOJygVRQoP
 GCbRiMUEaq/zUvVBxjSj4o5akoevkj9gpQZ0h0PTrfU5fq6Ys4TV3VhRwUCTAexSjgYM
 EJ3g==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=content-transfer-encoding:in-reply-to:from:references:cc:to
 :content-language:subject:user-agent:mime-version:date:message-id
 :sender:x-gm-message-state:from:to:cc:subject:date:message-id
 :reply-to;
 bh=o//FlaQeU1f14nEA+MG0zkt0hZu7ebkH4HkHt/a/maY=;
 b=Wp5nBGwNhMSDqkP1n+NIQZAaxVXaEGnsWM7Lz0K/er8KStAxzq+7e2S1OR3mfjn5nL
 qxlVXrIbp7Tf8c7ZaU1QWnUMDqrT0vvUiN0RI9hK92MmizIkMSyIzIFaGRRLoB/c+M4j
 ObYRQN+W+kbxiDRCDLmo4HJW8cVbcHKcwXhMvfItoAaM6qFvxbhLuhnLaqurSrgXhQPF
 EmIKu1q6KYYnw2htRiCy/iOOcMZgiehcS6N3+qUZqpowog5Z1MGyypBRkTa0RJbnomgn
 mbvhaR6CpPxOrM/ZKW8o9ngbz/a6gePcEFGAWenO/XWl/zzN4Us/zZf2ShD+l8mDSPjK
 ysAw==
X-Gm-Message-State: AFqh2krYpe6+4d4KEWL+T3KnrEnrOJh8Hs0hmfsS2euxOG5qeuMsYW9M
 rqIN5nyJXfbHftZmaRZ1V7w=
X-Google-Smtp-Source: AMrXdXun2OnNGvj5cELWuk1urs37hZqWLbsh7UyxCsA+hUTSFqhKWCgS7Q0pu7rEfKmd3ZXsYT/wSA==
X-Received: by 2002:adf:de0e:0:b0:2bd:fa1d:5291 with SMTP id
 b14-20020adfde0e000000b002bdfa1d5291mr3128286wrm.67.1673834173049; 
 Sun, 15 Jan 2023 17:56:13 -0800 (PST)
Received: from [192.168.0.2] ([46.251.119.176])
 by smtp.googlemail.com with ESMTPSA id
 v14-20020adff68e000000b002365730eae8sm24974426wrp.55.2023.01.15.17.56.12
 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
 Sun, 15 Jan 2023 17:56:12 -0800 (PST)
Message-ID: <6a7f5a94-b2cd-c6b8-1267-87da1c6303e1@HIDDEN>
Date: Mon, 16 Jan 2023 03:56:10 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.4.2
Subject: Re: bug#60127: treesit-end-of-defun: possible bug with clojure grammar
Content-Language: en-US
To: Yuan Fu <casouri@HIDDEN>, Danny Freeman <danny@HIDDEN>
References: <87sfhf5ghj.fsf@HIDDEN>
 <CD0C17BC-4F54-48EB-AF2A-5D7314845AD7@HIDDEN>
From: Dmitry Gutov <dgutov@HIDDEN>
In-Reply-To: <CD0C17BC-4F54-48EB-AF2A-5D7314845AD7@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Spam-Score: -0.9 (/)
X-Debbugs-Envelope-To: 60127
Cc: 60127 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.9 (-)

On 22/12/2022 10:55, Yuan Fu wrote:
> Danny Freeman<danny@HIDDEN>  writes:
> 
>> Yuan,
>>
>>>> Thank you very much for this detailed report! This seems to be some
>>>> problem with either tree-sitter or tree-sitter-clojure, where
>>>> treesit-node-first-child-for-pos gives wrong result. We’ve had similar
>>>> problem with bash before[1].
>>>>
>>>> At this point there aren’t much we can do in Emacs. If I find some time
>>>> I’ll make a reproduce recipe and submit an issue on tree-sitter-clojure.
>>>>
>>>> [1]https://github.com/tree-sitter/tree-sitter-bash/issues/139
>>>>
>>>> Yuan
>> I have a c program that I believe reproduces the problem. I'm not sure
>> how we will go about fixing it in tree-sitter-clojure, but at least we
>> have a minimal way to re-create it.
>>
>> Here is a link to the issue I created:
>> https://github.com/sogaiu/tree-sitter-clojure/issues/32
>> that also includes the c-program. I've also put it on my source hut
>> https://paste.sr.ht/~dannyfreeman/8786059276c334036877159a5b0872cd2aa6fbc0  
>>
>> If you find the time, I would appreciate it if you could confirm my
>> findings. I'm a little in over my head with this bug I'm afraid.
> I think it’s pretty good (the reproduce), the author’s modified program
> is even better. Let’s wait and see what tree-sitter’s author have to
> say.

Just to keep everyone of the same page:

clojure-tree-sitter's author posted an issue to tree-sitter last week: 
https://github.com/tree-sitter/tree-sitter/issues/2012

and, previously, he also suggested we might be able to work around it 
using treesit_search_dfs: 
https://github.com/sogaiu/tree-sitter-clojure/issues/32#issuecomment-1364830835




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60127; Package emacs. Full text available.
Added tag(s) pending. Request was from Yuan Fu <casouri@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at 60127 <at> debbugs.gnu.org:


Received: (at 60127) by debbugs.gnu.org; 22 Dec 2022 08:55:48 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu Dec 22 03:55:48 2022
Received: from localhost ([127.0.0.1]:57080 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p8HMi-0004av-85
	for submit <at> debbugs.gnu.org; Thu, 22 Dec 2022 03:55:48 -0500
Received: from mail-pj1-f42.google.com ([209.85.216.42]:36863)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <casouri@HIDDEN>) id 1p8HMg-0004an-0A
 for 60127 <at> debbugs.gnu.org; Thu, 22 Dec 2022 03:55:46 -0500
Received: by mail-pj1-f42.google.com with SMTP id
 q17-20020a17090aa01100b002194cba32e9so5083663pjp.1
 for <60127 <at> debbugs.gnu.org>; Thu, 22 Dec 2022 00:55:45 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:from:to:cc:subject:date:message-id
 :reply-to; bh=kgcqrblpI5iWOcB4yZI4ZOS3VXQ96D/+i98veoX9vh0=;
 b=ShBQrs3U2uGrj3WLKfdDTNXfrrIQYsa33NXhlfsRz65QmHS3zEzeqbKy8+yQrN8ioh
 VeJnZaU4QqbA7CcOyETgiqpofQGt4+G9cFWXh5qBu1HOTo/W7C/JwQ6OYcCIO0IppLuk
 6HhvNt4gdcb0FJJfRnnykP40aVhCzuOKNL8UQPSszP4tCG+8K8loMIrpfjbO37cK+AEA
 cfl2QZrhvFzhFEHNdb+45L1bLznbXCS0RavX2JNoVu6xlDC/JzagKJAszVFwj9aHl4+3
 tJLrwmPIffbuSnHsjCzk1eWcgvgcOb25NhI1xrQtKVZZZo4jfRBc3Y1XPIli/8YtowZJ
 fflg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=kgcqrblpI5iWOcB4yZI4ZOS3VXQ96D/+i98veoX9vh0=;
 b=dOYQh9KHt6xikSKmON+8U7//QT7i9ITf2G+oNlx9ykmpkTaxyfxXqWqdqEjYFLHy1c
 oph+qvunMHJsLxw/SCHHKj1iv4IBy8AXdsBfguFdpJRqbPjD541V/P5WCE59Ii9dEOW+
 1XY+myByDbXHusZR+AVbfVNkZ4mUY2tut+E3Ks1l7ZLSNGxuoEZCPYyFOMJL+NlKOQ67
 BovTLQpzU99PVEHf8qt4UGTyGzAEY14TaTwTekEYmIuG+QcJSQ4AAk3xtJNXNFYha9u2
 7nef2btkwnVepymLGWCbinbCDF2r85qTn5cVcCUH6xIn+c1VOBAY2hI8SaAxPCLh0KAb
 G7+Q==
X-Gm-Message-State: AFqh2kpXIqGYL9CrLsF5cd6ZmhouBXXTxvZ/XUweVvR31q2CTUQ34b95
 YiJ+JxmBNGA26/3TCHQo2tcG3of47jI=
X-Google-Smtp-Source: AMrXdXtoJvViGyqm3dUNatTgC//0DMCu8395/Ct2YNh1aSZ9TxwLOixqzLIvMossjn2lzKjJ6cPpwA==
X-Received: by 2002:a17:902:748b:b0:191:3c8:b2ab with SMTP id
 h11-20020a170902748b00b0019103c8b2abmr5297541pll.31.1671699340329; 
 Thu, 22 Dec 2022 00:55:40 -0800 (PST)
Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com.
 [172.117.161.177]) by smtp.gmail.com with ESMTPSA id
 a3-20020a170902710300b00186b758c9fasm17167pll.33.2022.12.22.00.55.39
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Thu, 22 Dec 2022 00:55:39 -0800 (PST)
From: Yuan Fu <casouri@HIDDEN>
Content-Type: text/plain;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\))
Subject: Re: bug#60127: treesit-end-of-defun: possible bug with clojure grammar
Message-Id: <CD0C17BC-4F54-48EB-AF2A-5D7314845AD7@HIDDEN>
Date: Thu, 22 Dec 2022 00:55:38 -0800
To: Danny Freeman <danny@HIDDEN>
X-Mailer: Apple Mail (2.3696.120.41.1.1)
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 60127
Cc: 60127 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Danny Freeman <danny@HIDDEN> writes:

> Yuan,
>
>>> Thank you very much for this detailed report! This seems to be some
>>> problem with either tree-sitter or tree-sitter-clojure, where
>>> treesit-node-first-child-for-pos gives wrong result. We=E2=80=99ve =
had similar
>>> problem with bash before[1].
>>>
>>> At this point there aren=E2=80=99t much we can do in Emacs. If I =
find some time
>>> I=E2=80=99ll make a reproduce recipe and submit an issue on =
tree-sitter-clojure.
>>>
>>> [1] https://github.com/tree-sitter/tree-sitter-bash/issues/139
>>>
>>> Yuan
>
> I have a c program that I believe reproduces the problem. I'm not sure
> how we will go about fixing it in tree-sitter-clojure, but at least we
> have a minimal way to re-create it.
>
> Here is a link to the issue I created:
> https://github.com/sogaiu/tree-sitter-clojure/issues/32
> that also includes the c-program. I've also put it on my source hut
> =
https://paste.sr.ht/~dannyfreeman/8786059276c334036877159a5b0872cd2aa6fbc0=
=20
>
> If you find the time, I would appreciate it if you could confirm my
> findings. I'm a little in over my head with this bug I'm afraid.

I think it=E2=80=99s pretty good (the reproduce), the author=E2=80=99s =
modified program
is even better. Let=E2=80=99s wait and see what tree-sitter=E2=80=99s =
author have to
say.

Yuan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60127; Package emacs. Full text available.

Message received at 60127 <at> debbugs.gnu.org:


Received: (at 60127) by debbugs.gnu.org; 17 Dec 2022 16:10:12 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 17 11:10:12 2022
Received: from localhost ([127.0.0.1]:56677 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p6ZlL-0002X8-PU
	for submit <at> debbugs.gnu.org; Sat, 17 Dec 2022 11:10:12 -0500
Received: from out-12.mta0.migadu.com ([91.218.175.12]:18558)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <danny@HIDDEN>) id 1p6ZlJ-0002X2-Di
 for 60127 <at> debbugs.gnu.org; Sat, 17 Dec 2022 11:10:10 -0500
References: <42357D6B-C983-4B1F-8857-8C990E848750@HIDDEN>
 <87k02q5dea.fsf@HIDDEN>
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Danny Freeman <danny@HIDDEN>
To: Yuan Fu <casouri@HIDDEN>
Subject: Re: bug#60127: treesit-end-of-defun: possible bug with clojure grammar
Date: Sat, 17 Dec 2022 10:47:58 -0500
In-reply-to: <87k02q5dea.fsf@HIDDEN>
Message-ID: <87a63m57vl.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60127
Cc: 60127 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Yuan,

>> Thank you very much for this detailed report! This seems to be some
>> problem with either tree-sitter or tree-sitter-clojure, where
>> treesit-node-first-child-for-pos gives wrong result. We=E2=80=99ve had s=
imilar
>> problem with bash before[1].
>>
>> At this point there aren=E2=80=99t much we can do in Emacs. If I find so=
me time
>> I=E2=80=99ll make a reproduce recipe and submit an issue on tree-sitter-=
clojure.
>>
>> [1] https://github.com/tree-sitter/tree-sitter-bash/issues/139
>>
>> Yuan

I have a c program that I believe reproduces the problem. I'm not sure
how we will go about fixing it in tree-sitter-clojure, but at least we
have a minimal way to re-create it.

Here is a link to the issue I created:
https://github.com/sogaiu/tree-sitter-clojure/issues/32
that also includes the c-program. I've also put it on my source hut
https://paste.sr.ht/~dannyfreeman/8786059276c334036877159a5b0872cd2aa6fbc0=
=20

If you find the time, I would appreciate it if you could confirm my
findings. I'm a little in over my head with this bug I'm afraid.

--=20
Danny Freeman




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60127; Package emacs. Full text available.

Message received at 60127 <at> debbugs.gnu.org:


Received: (at 60127) by debbugs.gnu.org; 17 Dec 2022 16:00:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 17 11:00:51 2022
Received: from localhost ([127.0.0.1]:56631 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p6ZcI-0002SR-S5
	for submit <at> debbugs.gnu.org; Sat, 17 Dec 2022 11:00:51 -0500
Received: from out-174.mta0.migadu.com ([91.218.175.174]:63152)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <danny@HIDDEN>) id 1p6ZcH-0002SK-6v
 for 60127 <at> debbugs.gnu.org; Sat, 17 Dec 2022 11:00:49 -0500
References: <42357D6B-C983-4B1F-8857-8C990E848750@HIDDEN>
 <87k02q5dea.fsf@HIDDEN>
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Danny Freeman <danny@HIDDEN>
To: Yuan Fu <casouri@HIDDEN>
Subject: Re: bug#60127: treesit-end-of-defun: possible bug with clojure grammar
Date: Sat, 17 Dec 2022 10:47:58 -0500
In-reply-to: <87k02q5dea.fsf@HIDDEN>
Message-ID: <87cz8i58hv.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 60127
Cc: 60127 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Danny Freeman <danny@HIDDEN> writes:


>> Thank you very much for this detailed report! This seems to be some
>> problem with either tree-sitter or tree-sitter-clojure, where
>> treesit-node-first-child-for-pos gives wrong result. We=E2=80=99ve had s=
imilar
>> problem with bash before[1].
>>
>> At this point there aren=E2=80=99t much we can do in Emacs. If I find so=
me time
>> I=E2=80=99ll make a reproduce recipe and submit an issue on tree-sitter-=
clojure.
>>
>> [1] https://github.com/tree-sitter/tree-sitter-bash/issues/139
>>
>> Yuan

I have a c program that I believe reproduces the problem. I'm not sure
how we will go about fixing it in tree-sitter-clojure, but at least we
have a minimal way to re-create it.

https://paste.sr.ht/~dannyfreeman/8786059276c334036877159a5b0872cd2aa6fbc0

--=20
Danny Freeman




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60127; Package emacs. Full text available.

Message received at 60127 <at> debbugs.gnu.org:


Received: (at 60127) by debbugs.gnu.org; 17 Dec 2022 14:11:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Dec 17 09:11:03 2022
Received: from localhost ([127.0.0.1]:56126 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p6Xu3-0001Lq-CM
	for submit <at> debbugs.gnu.org; Sat, 17 Dec 2022 09:11:03 -0500
Received: from out2.migadu.com ([188.165.223.204]:21266)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <danny@HIDDEN>) id 1p6Xu0-0001LT-8e
 for 60127 <at> debbugs.gnu.org; Sat, 17 Dec 2022 09:11:02 -0500
References: <42357D6B-C983-4B1F-8857-8C990E848750@HIDDEN>
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dfreeman.email;
 s=key1; t=1671286256;
 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=RjP6iqBNwnDfkkxBXpT6a5fA0osqMav1x+9edPerLp4=;
 b=TM1wJg82Mn8Wd5LHJMoq1dM1WEaXBM2aSbZwLBYvPEhQsU4/7PnfS9El0E0J2/SpVudAGQ
 8hdaPa9wXnXnvFsVX8fo965V7HMwPNvHih6hhLt/kA8CgUvQNWOqOhsy+potcQMil4KQfk
 7KriaZ7I81DQtqdQTg3eg2j6fhALUmE=
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
From: Danny Freeman <danny@HIDDEN>
To: Yuan Fu <casouri@HIDDEN>
Subject: Re: bug#60127: treesit-end-of-defun: possible bug with clojure grammar
Date: Sat, 17 Dec 2022 09:07:40 -0500
In-reply-to: <42357D6B-C983-4B1F-8857-8C990E848750@HIDDEN>
Message-ID: <87k02q5dea.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Migadu-Flow: FLOW_OUT
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 60127
Cc: 60127 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Yuan Fu <casouri@HIDDEN> writes:

> Thank you very much for this detailed report! This seems to be some
> problem with either tree-sitter or tree-sitter-clojure, where
> treesit-node-first-child-for-pos gives wrong result. We=E2=80=99ve had si=
milar
> problem with bash before[1].
>
> At this point there aren=E2=80=99t much we can do in Emacs. If I find som=
e time
> I=E2=80=99ll make a reproduce recipe and submit an issue on tree-sitter-c=
lojure.
>
> [1] https://github.com/tree-sitter/tree-sitter-bash/issues/139
>
> Yuan

This bash issue will be really helpful, thanks for sharing.
I've been doing work on tree-sitter-clojure, so I can start digging over
there. You don't need to worry about writing up a recipe unless you
really want to. (I will just test with Emacs since I do not know C very
well).

--=20
Danny Freeman




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60127; Package emacs. Full text available.

Message received at 60127 <at> debbugs.gnu.org:


Received: (at 60127) by debbugs.gnu.org; 16 Dec 2022 23:20:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 16 18:20:56 2022
Received: from localhost ([127.0.0.1]:52116 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p6K0d-00088Y-Hj
	for submit <at> debbugs.gnu.org; Fri, 16 Dec 2022 18:20:55 -0500
Received: from mail-pl1-f182.google.com ([209.85.214.182]:40740)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <casouri@HIDDEN>) id 1p6K0b-00088S-9v
 for 60127 <at> debbugs.gnu.org; Fri, 16 Dec 2022 18:20:53 -0500
Received: by mail-pl1-f182.google.com with SMTP id a9so3751289pld.7
 for <60127 <at> debbugs.gnu.org>; Fri, 16 Dec 2022 15:20:53 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:from:to:cc:subject:date:message-id
 :reply-to; bh=u98LpS0OOuWq7DdNWuW7V5Va56E8TYlbca8kA9ZTLFY=;
 b=iQ89sWEz11xBPLjwccJ9e7kjtwyARIJJ5kLc2d3ajts5Gr1Rf5FWSfEAnvGEB7wc8W
 Kg5nYDzjiiQjWzqu9rdNGsjABfPBrLeCws5GoNqLIUgQM9RW61Fl7uBm4sReLK0zCDOA
 cf8i8oQgPdyNzQ+zvwLJDhXtg3BIBamBluEZvVMsNQZbC1c7tjeJJxucL+xzgRcAE1xv
 hriWhEx5QeR+B/M18v2A4Hosrx7h5YWeuD/STNhPTS3OQFmiNL9E8mk3Wtlqmhb8XHn8
 0ztt9Nc77psg6MPynrSwpLu7GOXkCBNxrCNGNbBrOJzInKaYG0Lv8pco7VZ1fTYFoi5f
 1SWw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=to:cc:date:message-id:subject:mime-version
 :content-transfer-encoding:from:x-gm-message-state:from:to:cc
 :subject:date:message-id:reply-to;
 bh=u98LpS0OOuWq7DdNWuW7V5Va56E8TYlbca8kA9ZTLFY=;
 b=obMOsiUD4qKKEOF+boBhPZZiQEKG1vJz42unz5nA7c2Ic4sig3Bl79sV+/LkRLl2kO
 u/SF6lg0HFoQ7Mu9qsV8Cet76Kvps56vfHFy2azYBsfArFmvXrhAYeML5bYdYXDqwuiZ
 QzSwqBc63Bp4fob2mmZC5MSGQ/p/8c/kmAkMM5MXIrbDHz+Y0UbDAc58gusXvbfbrbmG
 ltAcA3LgvEHaVnMC1kIILM+qx9kHQkZqGxVg3yhQ1c5H7Y+98L9Ufle/keMJQlxt/0tv
 CUyvKZc3auMfzXibVcx8dR84gwfMNws+4p19q6a72vzVNUOzJzvurUy55kDXIFw6jncm
 dRlw==
X-Gm-Message-State: ANoB5pnLyzmrEMcv7RqJlHOMMJUD6mdn93fqZtEkyXHvKJbjBbeNm5hM
 kPhnp7ygMLxXGeYtviaLr5Y5nWlofAeYTw==
X-Google-Smtp-Source: AA0mqf6sDTlag2FzfQhAoKp9uZyXrTm+GQnYQkg0nJpk8PEiI2uvXAV4g11WB41Dq1h0hpe1WOwXkQ==
X-Received: by 2002:a17:902:f10d:b0:18f:a447:2254 with SMTP id
 e13-20020a170902f10d00b0018fa4472254mr20514133plb.64.1671232847262; 
 Fri, 16 Dec 2022 15:20:47 -0800 (PST)
Received: from smtpclient.apple (cpe-172-117-161-177.socal.res.rr.com.
 [172.117.161.177]) by smtp.gmail.com with ESMTPSA id
 z6-20020a1709027e8600b00172973d3cd9sm2151472pla.55.2022.12.16.15.20.46
 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128);
 Fri, 16 Dec 2022 15:20:46 -0800 (PST)
From: Yuan Fu <casouri@HIDDEN>
Content-Type: text/plain;
	charset=utf-8
Content-Transfer-Encoding: quoted-printable
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\))
Subject: Re: bug#60127: treesit-end-of-defun: possible bug with clojure grammar
Message-Id: <42357D6B-C983-4B1F-8857-8C990E848750@HIDDEN>
Date: Fri, 16 Dec 2022 15:20:43 -0800
To: Danny@HIDDEN
X-Mailer: Apple Mail (2.3696.120.41.1.1)
X-Spam-Score: -0.0 (/)
X-Debbugs-Envelope-To: 60127
Cc: 60127 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


Danny Freeman <Danny@HIDDEN> writes:

> Hello,
>
> I have been running into what I believe is a bug with
> treesit-end-of-defun while developing clojure-ts-mode. There are some
> positions in clojure buffers where treesit-end-of-defun will jump to =
the
> end of the buffer.
>
> Steps to reproduce:
>
> Checkout the emacs-29 branch. I have built mine with commit
> b01d0246d71a7a3fd92b2864a3c0c0bc9367ee0b and tree-sitter version =
0.20.7
>
> Clone my clojure-mode fork:
> https://github.com/dannyfreeman/clojure-mode
>
> check out the `end-of-defun-bug` branch (master works too, but I added
> a helpful debug message in this branch)
>
> Clone tree-sitter-module repo:
> https://github.com/casouri/tree-sitter-module
>
> Apply the patch `tree-sitter-module-clojure-support.patch` located in
> clojure-mode repo to the casouri/tree-sitter-module repo.
>
> Build the treesitter parser for clojure with
>
> $ ./build clojure
>
> Start emacs
>
> $ emacs -q
>
> Evaluate the following, replacing the paths with what is relevant to
> your system
>
> ```
> (progn
>   (setq treesit-extra-load-path =
'("~/path/to/tree-sitter-module/dist"))
>   (add-to-list 'load-path "~/path/to/clojure-mode/")
>   (find-file "~/path/to/clojure-mode/clojure-ts-mode.el")
>   (eval-buffer)
>   (find-file "~/path/to/clojure-mode/test_end_of_defun.clj"))
> ```
>
>
> Once you have opened test_end_of_defun.clj you can see the problem by
> pressing
>
> M-<
> C-M-e
> C-M-e
>
> You should see the cursor move from
>
> ```
> |(def w 1)
>
> (def x 2)
>
> (def y 3)
>
> (def skip-to-here? 4)
> ```
>
> to
>
> ```
> (def w 1)
> |
> (def x 2)
>
> (def y 3)
>
> (def skip-to-here? 4)
> ```
>
>
> then it unexpectedly jumps to the end of the buffer
>
> ```
> (def w 1)
>
> (def x 2)
>
> (def y 3)
>
> (def skip-to-here? 4)
> |
> ```
>
>
> The message buffer shows that when the point is between the forms
>
> ```
> (def w 1)
> |
> (def x 2)
> ```
>
>
> that `treesit-end-of-defun` thinks the current node is
> `(def skip-to-here? 4)`, which does not seem right.
>
> When the cursor is at other points in this buffer, this problem =
doesn't
> seem to occur. For instance, between the (def x 2) and (def y 3) =
forms,
> this doesn't happen.
>
> I can also see this happening in the `test.clj` file of the =
clojure-mode
> repo in a different spot but there is a lot more going on in that =
file.
> (hit C-M-e in it until the problem occurs if you are curious).
>
> I have the following vars relevant vars set in clojure-ts-mode.
> Different combinations of them yield the same results.
>
> ```
> (setq-local treesit-defun-prefer-top-level t
>             treesit-defun-tactic 'top-level
>             treesit-defun-type-regexp (cons (rx (or "list_lit" =
"vec_lit" "map_lit"))
>                                             (lambda (node)
>                                               (message "Node: %s" =
(treesit-node-text node t))
>                                               t)))
> ```
>
>
> The clojure code in question produces an error free parse tree. I can
> see it with `treesit-explore-mode` and by running the file through
> `tree-sitter parse`, which gives the following parse tree:
>
> ```
> (source [0, 0] - [7, 0]
>   (list_lit [0, 0] - [0, 9]
>     value: (sym_lit [0, 1] - [0, 4]
>       name: (sym_name [0, 1] - [0, 4]))
>     value: (sym_lit [0, 5] - [0, 6]
>       name: (sym_name [0, 5] - [0, 6]))
>     value: (num_lit [0, 7] - [0, 8]))
>   (list_lit [2, 0] - [2, 9]
>     value: (sym_lit [2, 1] - [2, 4]
>       name: (sym_name [2, 1] - [2, 4]))
>     value: (sym_lit [2, 5] - [2, 6]
>       name: (sym_name [2, 5] - [2, 6]))
>     value: (num_lit [2, 7] - [2, 8]))
>   (list_lit [4, 0] - [4, 9]
>     value: (sym_lit [4, 1] - [4, 4]
>       name: (sym_name [4, 1] - [4, 4]))
>     value: (sym_lit [4, 5] - [4, 6]
>       name: (sym_name [4, 5] - [4, 6]))
>     value: (num_lit [4, 7] - [4, 8]))
>   (list_lit [6, 0] - [6, 21]
>     value: (sym_lit [6, 1] - [6, 4]
>       name: (sym_name [6, 1] - [6, 4]))
>     value: (sym_lit [6, 5] - [6, 18]
>       name: (sym_name [6, 5] - [6, 18]))
>     value: (num_lit [6, 19] - [6, 20])))
> ```
>
> Any help or advice here is appreciated.
>
> Thank you,

Thank you very much for this detailed report! This seems to be some
problem with either tree-sitter or tree-sitter-clojure, where
treesit-node-first-child-for-pos gives wrong result. We=E2=80=99ve had =
similar
problem with bash before[1].

At this point there aren=E2=80=99t much we can do in Emacs. If I find =
some time
I=E2=80=99ll make a reproduce recipe and submit an issue on =
tree-sitter-clojure.

[1] https://github.com/tree-sitter/tree-sitter-bash/issues/139

Yuan




Information forwarded to bug-gnu-emacs@HIDDEN:
bug#60127; Package emacs. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 16 Dec 2022 18:52:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Dec 16 13:52:47 2022
Received: from localhost ([127.0.0.1]:50972 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1p6Fp9-0005Sx-Ax
	for submit <at> debbugs.gnu.org; Fri, 16 Dec 2022 13:52:47 -0500
Received: from lists.gnu.org ([209.51.188.17]:33552)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <Danny@HIDDEN>) id 1p6Fp7-0005Sr-HX
 for submit <at> debbugs.gnu.org; Fri, 16 Dec 2022 13:52:46 -0500
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 <Danny@HIDDEN>)
 id 1p6Fp5-0008VB-Tg
 for bug-gnu-emacs@HIDDEN; Fri, 16 Dec 2022 13:52:45 -0500
Received: from out2.migadu.com ([188.165.223.204])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <Danny@HIDDEN>)
 id 1p6Fp2-00038S-G3
 for bug-gnu-emacs@HIDDEN; Fri, 16 Dec 2022 13:52:43 -0500
X-Report-Abuse: Please report any abuse attempt to abuse@HIDDEN and
 include these headers.
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dfreeman.email;
 s=key1; t=1671216718;
 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;
 bh=q00+QnbtrpycSvThs451G9uGUUG9+aRS1x0DDK1N+BQ=;
 b=I/X8pI6CEKX3Ud9nVTCGhic/FScLZ9xC5061bKM4xvJ412OQBr4DfhPGbFthlNjbT/8IQE
 Hi4dcFehWaEoFJf403/0F70jSKq40xEmQ76yabXBGxNEtUsopI8v0YWfnJAjFIKwHxrJYT
 31veWAgm3ygASptGKMtW76uAJKi/SQY=
From: Danny Freeman <Danny@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: treesit-end-of-defun: possible bug with clojure grammar
Date: Fri, 16 Dec 2022 13:12:09 -0500
Message-ID: <87sfhf5ghj.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Migadu-Flow: FLOW_OUT
Received-SPF: pass client-ip=188.165.223.204;
 envelope-from=Danny@HIDDEN; helo=out2.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_PASS=-0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.4 (-)
X-Debbugs-Envelope-To: submit
Cc: Yuan Fu <casouri@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.4 (--)


Hello,

I have been running into what I believe is a bug with
treesit-end-of-defun while developing clojure-ts-mode. There are some
positions in clojure buffers where treesit-end-of-defun will jump to the
end of the buffer.

Steps to reproduce:

Checkout the emacs-29 branch. I have built mine with commit
b01d0246d71a7a3fd92b2864a3c0c0bc9367ee0b and tree-sitter version 0.20.7

Clone my clojure-mode fork:
https://github.com/dannyfreeman/clojure-mode

check out the `end-of-defun-bug` branch (master works too, but I added
a helpful debug message in this branch)

Clone tree-sitter-module repo:
https://github.com/casouri/tree-sitter-module

Apply the patch `tree-sitter-module-clojure-support.patch` located in
clojure-mode repo to the casouri/tree-sitter-module repo.

Build the treesitter parser for clojure with

$ ./build clojure

Start emacs

$ emacs -q

Evaluate the following, replacing the paths with what is relevant to
your system

```
(progn
  (setq treesit-extra-load-path '("~/path/to/tree-sitter-module/dist"))
  (add-to-list 'load-path "~/path/to/clojure-mode/")
  (find-file "~/path/to/clojure-mode/clojure-ts-mode.el")
  (eval-buffer)
  (find-file "~/path/to/clojure-mode/test_end_of_defun.clj"))
```

Once you have opened test_end_of_defun.clj you can see the problem by
pressing

M-<
C-M-e
C-M-e

You should see the cursor move from

```
|(def w 1)

(def x 2)

(def y 3)

(def skip-to-here? 4)
```

to
```
(def w 1)
|
(def x 2)

(def y 3)

(def skip-to-here? 4)
```

then it unexpectedly jumps to the end of the buffer
```
(def w 1)

(def x 2)

(def y 3)

(def skip-to-here? 4)
|
```

The message buffer shows that when the point is between the forms

```
(def w 1)
|
(def x 2)
```

that `treesit-end-of-defun` thinks the current node is
`(def skip-to-here? 4)`, which does not seem right.

When the cursor is at other points in this buffer, this problem doesn't
seem to occur. For instance, between the (def x 2) and (def y 3) forms,
this doesn't happen.

I can also see this happening in the `test.clj` file of the clojure-mode
repo in a different spot but there is a lot more going on in that file.
(hit C-M-e in it until the problem occurs if you are curious).

I have the following vars relevant vars set in clojure-ts-mode.
Different combinations of them yield the same results.

```
(setq-local treesit-defun-prefer-top-level t
            treesit-defun-tactic 'top-level
            treesit-defun-type-regexp (cons (rx (or "list_lit" "vec_lit" "map_lit"))
                                            (lambda (node)
                                              (message "Node: %s" (treesit-node-text node t))
                                              t)))
```

The clojure code in question produces an error free parse tree. I can
see it with `treesit-explore-mode` and by running the file through
`tree-sitter parse`, which gives the following parse tree:

```
(source [0, 0] - [7, 0]
  (list_lit [0, 0] - [0, 9]
    value: (sym_lit [0, 1] - [0, 4]
      name: (sym_name [0, 1] - [0, 4]))
    value: (sym_lit [0, 5] - [0, 6]
      name: (sym_name [0, 5] - [0, 6]))
    value: (num_lit [0, 7] - [0, 8]))
  (list_lit [2, 0] - [2, 9]
    value: (sym_lit [2, 1] - [2, 4]
      name: (sym_name [2, 1] - [2, 4]))
    value: (sym_lit [2, 5] - [2, 6]
      name: (sym_name [2, 5] - [2, 6]))
    value: (num_lit [2, 7] - [2, 8]))
  (list_lit [4, 0] - [4, 9]
    value: (sym_lit [4, 1] - [4, 4]
      name: (sym_name [4, 1] - [4, 4]))
    value: (sym_lit [4, 5] - [4, 6]
      name: (sym_name [4, 5] - [4, 6]))
    value: (num_lit [4, 7] - [4, 8]))
  (list_lit [6, 0] - [6, 21]
    value: (sym_lit [6, 1] - [6, 4]
      name: (sym_name [6, 1] - [6, 4]))
    value: (sym_lit [6, 5] - [6, 18]
      name: (sym_name [6, 5] - [6, 18]))
    value: (num_lit [6, 19] - [6, 20])))
```

Any help or advice here is appreciated.

Thank you,
-- 
Danny Freeman




Acknowledgement sent to Danny Freeman <Danny@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#60127; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 17 Jan 2023 16:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.