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#73404: 30.0.50; [forward/kill/etc]-sexp commands do not behave as expected in tree-sitter modes Date: Mon, 06 Jan 2025 15:19:35 -0500 Message-ID: References: <87plox4mtp.fsf@masteringemacs.org> <877cay1lqt.fsf@masteringemacs.org> <86frpma06f.fsf@gnu.org> <86ikueiekp.fsf@mail.linkov.net> <86ed4zg1cc.fsf@mail.linkov.net> <87zflac68t.fsf@mail.linkov.net> <87jzcdlxdp.fsf@mail.linkov.net> <87o71jocgs.fsf@mail.linkov.net> <87wmfwqg7e.fsf@mail.linkov.net> <8734i5fyv1.fsf@mail.linkov.net> <875xmumpzv.fsf@mail.linkov.net> <86ikqubdsd.fsf@gnu.org> <87wmf9912l.fsf@mail.linkov.net> <867c798lco.fsf@gnu.org> <871pxhp24e.fsf@mail.linkov.net> <86cyh16nq3.fsf@gnu.org> <87bjwjyg5f.fsf@mail.linkov.net> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13578"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: mickey@masteringemacs.org, Eli Zaretskii , theo@thornhill.no, casouri@gmail.com, 73404@debbugs.gnu.org To: Juri Linkov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Jan 06 21:20:30 2025 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 1tUtaP-0003FM-5C for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 06 Jan 2025 21:20:29 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tUtaE-00039b-3F; Mon, 06 Jan 2025 15:20:19 -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 1tUtZz-0002uW-FW for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2025 15:20:07 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tUtZz-0005FV-2x for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2025 15:20:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:References:In-Reply-To:From:To:Subject; bh=sdWNJWXufLRED4XnX9sm6EcZ09zg3Mjxw/no7n5P5rs=; b=mcgEuz4BOsszHZhu0wf6Z0/C2mEuVmhPXVoEslpjEy7Cd1GBA5rVShlcWnTCthvXlJSQPWEU1+JaFwA81z54KGmes6c4GwtMRoDRL4D884iJdotsPnTOulVrEOcIF2QnNZTrS0fg1XnafcXa88/AWC599BthOd2tfxlUFETz4qMcv9cZPYtXnzGquRMw6IQKxmRFyvkkFeHEeoNW8yjMzckJykdji6h8zpuRtVHQddkVyP5nHTmzsl1ramuF8IXll8oPSBFL5q2QemaUpseyEYzKw/YB6UHladCMW2fcI+wklcBCQXslPCBCQkIztHk0HRL4s6m9ghIDRGl29X3JFg==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tUtZy-0000i5-GS for bug-gnu-emacs@gnu.org; Mon, 06 Jan 2025 15:20: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, 06 Jan 2025 20:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73404 X-GNU-PR-Package: emacs Original-Received: via spool by 73404-submit@debbugs.gnu.org id=B73404.17361947922702 (code B ref 73404); Mon, 06 Jan 2025 20:20:02 +0000 Original-Received: (at 73404) by debbugs.gnu.org; 6 Jan 2025 20:19:52 +0000 Original-Received: from localhost ([127.0.0.1]:40240 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tUtZn-0000hV-Ks for submit@debbugs.gnu.org; Mon, 06 Jan 2025 15:19:52 -0500 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:28749) by debbugs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1tUtZg-0000h3-FK for 73404@debbugs.gnu.org; Mon, 06 Jan 2025 15:19:49 -0500 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 749E380913; Mon, 6 Jan 2025 15:19:38 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1736194777; bh=rChCcduHPl5aovbJAlApgkL/BlmIBK81VxNpW9v98y0=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=aWvXzlKEzvveY+8h1fzAq2ghz+L8FsKVqWTmaXdCH8+wgKheyklqtYD0NRFlJk+iS kh63inujE1NWvZ8Zhkd0ErG7yoF/EpVKjmzvZ1xYn1PXZ2dpuHYwLZa+KhWXvXpH2y EZINI4Rv759s1QCLv2va0nq9EYKYPShsU6Jc7lp6vI/Rz/JqLRSUV3g4uorPuijcuy rlz36EdKsdd7FYmkPk1ZH3vYTwNUsjetdZYL8/EhnBt2xNYtWsnf6c71woe3BO3M+J rv4FzX2NAAM+NwXmdA45Zk4Pnfwl/3tTO7zZtCB1OMMCqmYwY2VI7rHfs62EW0WVGK UQy32TK5O7aKA== Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 9FF9B806F8; Mon, 6 Jan 2025 15:19:37 -0500 (EST) Original-Received: from pastel (69-165-162-104.dsl.teksavvy.com [69.165.162.104]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 6529812029A; Mon, 6 Jan 2025 15:19:37 -0500 (EST) In-Reply-To: <87bjwjyg5f.fsf@mail.linkov.net> (Juri Linkov's message of "Mon, 06 Jan 2025 20:02:36 +0200") 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:298696 Archived-At: > The problem is that ")" is not the final child of 'cast_expression'. > So C-M-f/C-M-n can't stop after ")". > > All these problems stem from the imperfection of ts grammars. I'm not sure if I'd call it "imperfection". There are tradeoffs. > It would be nice if someone will find a way to modify the grammars > after importing them to Emacs core, to be able to insert more nodes. > This will solve a whole class of problems. I think some way to massage the parse tree would be useful (maybe by massaging the grammar, but not necessarily). The `cast_expression` is one place where we could use it, but it would also help us deal with the fact that grammars can change outside of our control and we may want our major modes to support various versions of a grammar. > Otherwise, if vendoring grammars is not feasible, an alternative > would be to define a new treesit-thing like e.g. "paren" that > will match anonymous nodes like: > > (setq-local treesit-thing-settings > `((c > (paren ,(rx (or "{" "}" "[" "]" "(" ")"))) > > Then low-level treesit functions such as treesit-parent-until > will have to check if there a preceding sibling that matches "paren" > before using their real AST parent node. This means maintaining > a parallel virtual tree. I'd prefer something more targeted, i.e. some way for the major mode to add "extra rules" to explain that some part of `cast_expression` should also be treated as a `list`. Stefan