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#68993: treesitter support for forward-sexp-default-function Date: Mon, 12 Feb 2024 20:41:46 +0200 Organization: LINKOV.NET Message-ID: <86o7clv82d.fsf@mail.linkov.net> References: <86y1bv6jsm.fsf@mail.linkov.net> <89817820-6928-43AD-B4BB-0AB48B1808FB@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="29203"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu) Cc: 68993@debbugs.gnu.org To: Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 12 19:45:00 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 1rZbIa-0007Ti-0o for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 12 Feb 2024 19:45:00 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZbIM-0007bC-Tb; Mon, 12 Feb 2024 13:44:46 -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 1rZbIL-0007aw-D3 for bug-gnu-emacs@gnu.org; Mon, 12 Feb 2024 13:44:45 -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 1rZbIL-0005Lz-4R for bug-gnu-emacs@gnu.org; Mon, 12 Feb 2024 13:44:45 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rZbIc-00014C-0e for bug-gnu-emacs@gnu.org; Mon, 12 Feb 2024 13:45: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: Mon, 12 Feb 2024 18:45:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68993 X-GNU-PR-Package: emacs Original-Received: via spool by 68993-submit@debbugs.gnu.org id=B68993.17077634803987 (code B ref 68993); Mon, 12 Feb 2024 18:45:01 +0000 Original-Received: (at 68993) by debbugs.gnu.org; 12 Feb 2024 18:44:40 +0000 Original-Received: from localhost ([127.0.0.1]:48961 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rZbIG-00012F-8q for submit@debbugs.gnu.org; Mon, 12 Feb 2024 13:44:40 -0500 Original-Received: from relay9-d.mail.gandi.net ([2001:4b98:dc4:8::229]:32831) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rZbID-00011T-2H for 68993@debbugs.gnu.org; Mon, 12 Feb 2024 13:44:39 -0500 Original-Received: by mail.gandi.net (Postfix) with ESMTPSA id 96F6DFF805; Mon, 12 Feb 2024 18:44:12 +0000 (UTC) In-Reply-To: <89817820-6928-43AD-B4BB-0AB48B1808FB@gmail.com> (Yuan Fu's message of "Sun, 11 Feb 2024 17:42:34 -0800") 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:279917 Archived-At: >> The problem is that e.g. Ruby parser to such text: >> >> hash[:key] >> >> produces such syntax tree: >> >> (element_reference object: (identifier) [ (simple_symbol) ]) >> >> so when point is on [ then 'C-M-f' can't move to ]. >> >> This is fixed now by the third patch: >> @@ -1170,7 +1170,20 @@ ruby-ts-mode >> + (comment ,(lambda (node) >> + (or (member (treesit-node-type node) >> + '("comment" "string_content")) >> + (and (member (treesit-node-text node) >> + '("[" "]")) >> + (equal (treesit-node-type >> + (treesit-node-parent node)) >> + "element_reference")) >> + (and (member (treesit-node-text node) >> + '("#{" "}")) >> + (equal (treesit-node-type >> + (treesit-node-parent node)) >> + "interpolation")))))))) > > IIUC, this doesn’t look like a good idea: you don’t want to mark > something that’s not comment as comment. In the future, other packages > will start using these thing definitions, and I’m sure you don’t want > them consider regular code as comments. > > For the specific problem you described, maybe the change made in #68899 can help? bug#68899 can't help because it only fixes 'C-M-f' to move point to the end of the current symbol. Whereas for the problem above we need a predicate that will instruct 'treesit-forward-sexp' to fall back to 'forward-sexp-default-function'. Clearly neither the name 'text' nor 'comment' would be suitable for such usage. Maybe it's possible to find a different name?