From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov 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: Thu, 12 Dec 2024 09:58:03 +0200 Organization: LINKOV.NET Message-ID: <87y10l8h6k.fsf@mail.linkov.net> References: <87plox4mtp.fsf@masteringemacs.org> <87frpm20t7.fsf@masteringemacs.org> <8634lmbs8t.fsf@gnu.org> <87bk0a1u0o.fsf@masteringemacs.org> <86tte2a5o3.fsf@gnu.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> <5192B278-66C0-48AE-B881-E57CCBB6B501@gmail.com> <87frmtbc9z.fsf@mail.linkov.net> <86bjxh1h86.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="22662"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu) Cc: theo@thornhill.no, casouri@gmail.com, mickey@masteringemacs.org, monnier@iro.umontreal.ca, 73404@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Dec 12 09:04:23 2024 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 1tLeBL-0005lj-Hb for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 12 Dec 2024 09:04:23 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tLeBB-0001E7-I3; Thu, 12 Dec 2024 03:04:14 -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 1tLeB1-0001Dj-A1 for bug-gnu-emacs@gnu.org; Thu, 12 Dec 2024 03:04:04 -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 1tLeB0-0003yI-Qr for bug-gnu-emacs@gnu.org; Thu, 12 Dec 2024 03:04: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=H34TSyTMd9g4L7QNdRp/7rTjbME08wc8ZHvpjStaMx0=; b=OE+Afcv2H2d+w0UD72jJhk8NtmB/7P7VVPyJ+L6giX11+0jg2VBk3ObaEcw7/TfvrHKOE7VPrVkUjx+OdvPmsn89KVuxAXvgaz3SwG2G0igZcbkNrwSnUf8das8my/8iDXkfrUzwECbaqZ5HpbQAemA0OjbvH31Sbmwmsk1ez3GVjbM2zwpwONLueYh5wUkcoTON/5e7DojNCb3aIDI2+/o2cfGP8BJcOwu2hFUVB/PSoCXk9Ih9Obp5Ax2lZyYpyo5e2stJ87KZLzz3zP0p3x1bAvVL2BKXaxjjWQ+Y5GO3gVDawQDPqW6pPO15jCf0PBAlA4L0mpttATeqFiSlEQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tLeB0-0005wX-Ds for bug-gnu-emacs@gnu.org; Thu, 12 Dec 2024 03:04:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 12 Dec 2024 08:04: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.173399064022830 (code B ref 73404); Thu, 12 Dec 2024 08:04:02 +0000 Original-Received: (at 73404) by debbugs.gnu.org; 12 Dec 2024 08:04:00 +0000 Original-Received: from localhost ([127.0.0.1]:37484 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLeAx-0005wA-HW for submit@debbugs.gnu.org; Thu, 12 Dec 2024 03:03:59 -0500 Original-Received: from relay5-d.mail.gandi.net ([217.70.183.197]:55787) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tLeAu-0005vh-AD for 73404@debbugs.gnu.org; Thu, 12 Dec 2024 03:03:57 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id C18291C0008; Thu, 12 Dec 2024 08:03:28 +0000 (UTC) In-Reply-To: <86bjxh1h86.fsf@gnu.org> (Eli Zaretskii's message of "Thu, 12 Dec 2024 09:40:57 +0200") X-GND-Sasl: juri@linkov.net 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:296892 Archived-At: >> forward-sexp moves over a balanced parenthetical group like >> forward-list does. Plus forward-sexp also moves over an atom >> such as a symbol, a number. >> >> The problem is that treesit adds too much structural information >> to such simple things as a symbol and a number. For example, in js >> a simple keyword "export" gets the "(export_statement export" subtree, >> Another keyword "const" gets "(lexical_declaration kind: const", etc. >> >> Therefore for such symbols forward-sexp needs to bypass the structure >> and use simpler syntactic information to move over them like on a flat list. > > If you mean we should ignore the information provided by tree-sitter > and instead use our own syntactic information, then that sounds wrong > to me, FWIW. Why cannot we understand enough of the tree-sitter > structural information to move like we want? Presumably, the > structural information provided by tree-sitter is a portion of a parse > tree, which to me means we should be able to move between the parse > tree's nodes as long as we understand the tree and can interpret it in > our terms. > > Aren't there some grammar-agnostic traits of tree-sitter nodes that > would allow us to interpret the nodes in language-independent terms? > If that is not available, then each major mode will have to provide > treesit.el with a way to interpret the tree-sitter nodes of the > corresponding grammar in a way that will allow sexp movement, thus > providing an abstraction layer that treesit.el could use for the > movement commands. Maybe it would be possible to use something like 'flatten-tree' on the treesit's syntax tree? But this will require the addition of a lot of rules to specify what nodes should be flattened.