GNU bug report logs - #67036
30.0.50; treesit-forward-sexp not working properly in ruby-ts-mode

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: Juri Linkov <juri@HIDDEN>; Done: Juri Linkov <juri@HIDDEN>; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
bug marked as fixed in version 30.0.50, send any further explanations to 67036 <at> debbugs.gnu.org and Juri Linkov <juri@HIDDEN> Request was from Juri Linkov <juri@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

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


Received: (at 67036) by debbugs.gnu.org; 2 May 2024 06:31:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Thu May 02 02:31:56 2024
Received: from localhost ([127.0.0.1]:41823 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1s2Pz2-0004OG-M2
	for submit <at> debbugs.gnu.org; Thu, 02 May 2024 02:31:56 -0400
Received: from relay4-d.mail.gandi.net ([217.70.183.196]:57883)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>)
 id 1s2Pz0-0004O1-Hk; Thu, 02 May 2024 02:31:55 -0400
Received: by mail.gandi.net (Postfix) with ESMTPSA id 99AB6E0003;
 Thu,  2 May 2024 06:31:25 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: Dmitry Gutov <dmitry@HIDDEN>
Subject: Re: bug#67036: 30.0.50; treesit-forward-sexp not working properly
 in ruby-ts-mode
In-Reply-To: <864jc3ap3s.fsf@HIDDEN> (Juri Linkov's message of "Sun, 
 14 Apr 2024 19:25:11 +0300")
Organization: LINKOV.NET
References: <86bkc2nktq.fsf@HIDDEN> <83a5r2dw25.fsf@HIDDEN>
 <45795de5-2064-3ab9-3cbb-c1b2018faf7c@HIDDEN>
 <864jh776bm.fsf@HIDDEN>
 <5a8d4404-47ec-9190-d80f-edc1fca26cf3@HIDDEN>
 <86msuxulvt.fsf@HIDDEN>
 <d790e608-abe4-72d5-b115-ef7550615d3f@HIDDEN>
 <867cllrln9.fsf@HIDDEN> <864jc3ap3s.fsf@HIDDEN>
Date: Thu, 02 May 2024 09:29:41 +0300
Message-ID: <868r0s7mlm.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain
X-GND-Sasl: juri@HIDDEN
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 67036
Cc: 67036 <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.7 (-)

close 67036 30.0.50
thanks

>>>>>>>>> +# C-M-f on '[' doesn't jump to after ']'
>>>>>>>>> +hash['key']
>>>>>>>>> +
>>>>>>>
>>>>>>> As discussed previously, there is no specific node which spans from [ to
>>>>>>> ]. Some custom code could probably be written (there *are* leaf nodes for [
>>>>>>> and ]), but the current capabilities of treesit-thing-settings don't offer
>>>>>>> a good way to plug that in.
>>>>>> Like for point inside strings, this might require more general changes
>>>>>> that take into account syntax tables.
>>>>>
>>>>> Possibly, but I expect a solution that doesn't use the syntax table would
>>>>> be tried first.
>>>> Since there is no available information from treesit, handling
>>>> treesit-forward-sexp inside strings/comments could forward to the syntax table
>>>> like `prog-fill-reindent-defun' forwards to `fill-paragraph'.
>>
>> Shouldn't treesit-forward-sexp provide a way for ts-modes to override
>> the default handling?  By default for all ts-modes such a hook could
>> check if point is inside strings/comments then to use syntax navigation.
>
> This is now implemented in bug#68993.  So here is the patch that 
> handles such cases as C-M-f jumping from '[' to ']' in
>
>   hash[:key]
>   hash['key']
>
> and from '{' to '}' in
>
>   "abc #{ghi} def"
>
> diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el

I guess this patch was ok.  So I pushed it to master, and closed.
Anything could be adjusted later if needed.




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

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


Received: (at 67036) by debbugs.gnu.org; 14 Apr 2024 16:28:03 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Apr 14 12:28:03 2024
Received: from localhost ([127.0.0.1]:36048 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rw2i1-0000d8-EC
	for submit <at> debbugs.gnu.org; Sun, 14 Apr 2024 12:28:03 -0400
Received: from relay4-d.mail.gandi.net ([217.70.183.196]:34525)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1rw2hz-0000bu-Oo
 for 67036 <at> debbugs.gnu.org; Sun, 14 Apr 2024 12:28:00 -0400
Received: by mail.gandi.net (Postfix) with ESMTPSA id 1F1D5E0004;
 Sun, 14 Apr 2024 16:27:40 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: Dmitry Gutov <dmitry@HIDDEN>
Subject: Re: bug#67036: 30.0.50; treesit-forward-sexp not working properly
 in ruby-ts-mode
In-Reply-To: <867cllrln9.fsf@HIDDEN> (Juri Linkov's message of "Mon, 
 11 Dec 2023 19:09:54 +0200")
Organization: LINKOV.NET
References: <86bkc2nktq.fsf@HIDDEN> <83a5r2dw25.fsf@HIDDEN>
 <45795de5-2064-3ab9-3cbb-c1b2018faf7c@HIDDEN>
 <864jh776bm.fsf@HIDDEN>
 <5a8d4404-47ec-9190-d80f-edc1fca26cf3@HIDDEN>
 <86msuxulvt.fsf@HIDDEN>
 <d790e608-abe4-72d5-b115-ef7550615d3f@HIDDEN>
 <867cllrln9.fsf@HIDDEN>
Date: Sun, 14 Apr 2024 19:25:11 +0300
Message-ID: <864jc3ap3s.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-GND-Sasl: juri@HIDDEN
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 67036
Cc: Eli Zaretskii <eliz@HIDDEN>, 67036 <at> debbugs.gnu.org,
 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: -1.7 (-)

--=-=-=
Content-Type: text/plain

>>>>>>>> +# C-M-f on '[' doesn't jump to after ']'
>>>>>>>> +hash['key']
>>>>>>>> +
>>>>>>
>>>>>> As discussed previously, there is no specific node which spans from [ to
>>>>>> ]. Some custom code could probably be written (there *are* leaf nodes for [
>>>>>> and ]), but the current capabilities of treesit-thing-settings don't offer
>>>>>> a good way to plug that in.
>>>>> Like for point inside strings, this might require more general changes
>>>>> that take into account syntax tables.
>>>>
>>>> Possibly, but I expect a solution that doesn't use the syntax table would
>>>> be tried first.
>>> Since there is no available information from treesit, handling
>>> treesit-forward-sexp inside strings/comments could forward to the syntax table
>>> like `prog-fill-reindent-defun' forwards to `fill-paragraph'.
>
> Shouldn't treesit-forward-sexp provide a way for ts-modes to override
> the default handling?  By default for all ts-modes such a hook could
> check if point is inside strings/comments then to use syntax navigation.

This is now implemented in bug#68993.  So here is the patch that 
handles such cases as C-M-f jumping from '[' to ']' in

  hash[:key]
  hash['key']

and from '{' to '}' in

  "abc #{ghi} def"


--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline; filename=ruby-ts-mode-text.patch

diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el
index 7133cb0b5b0..098cca2cb56 100644
--- a/lisp/progmodes/ruby-ts-mode.el
+++ b/lisp/progmodes/ruby-ts-mode.el
@@ -1171,7 +1171,20 @@ ruby-ts-mode
                                 "global_variable"
                                 )
                                eol)
-                              #'ruby-ts--sexp-p)))))
+                              #'ruby-ts--sexp-p))
+                 (text ,(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"))))))))
 
   ;; AFAIK, Ruby can not nest methods
   (setq-local treesit-defun-prefer-top-level nil)

--=-=-=--




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

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


Received: (at 67036) by debbugs.gnu.org; 11 Dec 2023 17:21:58 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Dec 11 12:21:58 2023
Received: from localhost ([127.0.0.1]:54499 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rCjyg-0001vH-7d
	for submit <at> debbugs.gnu.org; Mon, 11 Dec 2023 12:21:58 -0500
Received: from relay3-d.mail.gandi.net ([217.70.183.195]:56555)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1rCjyZ-0001uk-NP
 for 67036 <at> debbugs.gnu.org; Mon, 11 Dec 2023 12:21:56 -0500
Received: by mail.gandi.net (Postfix) with ESMTPSA id 0A5CF60006;
 Mon, 11 Dec 2023 17:21:29 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: Dmitry Gutov <dmitry@HIDDEN>
Subject: Re: bug#67036: 30.0.50; treesit-forward-sexp not working properly
 in ruby-ts-mode
In-Reply-To: <d790e608-abe4-72d5-b115-ef7550615d3f@HIDDEN> (Dmitry Gutov's
 message of "Mon, 11 Dec 2023 02:47:10 +0200")
Organization: LINKOV.NET
References: <86bkc2nktq.fsf@HIDDEN> <83a5r2dw25.fsf@HIDDEN>
 <45795de5-2064-3ab9-3cbb-c1b2018faf7c@HIDDEN>
 <864jh776bm.fsf@HIDDEN>
 <5a8d4404-47ec-9190-d80f-edc1fca26cf3@HIDDEN>
 <86msuxulvt.fsf@HIDDEN>
 <d790e608-abe4-72d5-b115-ef7550615d3f@HIDDEN>
Date: Mon, 11 Dec 2023 19:09:54 +0200
Message-ID: <867cllrln9.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain
X-GND-Sasl: juri@HIDDEN
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 67036
Cc: Eli Zaretskii <eliz@HIDDEN>, 67036 <at> debbugs.gnu.org,
 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: -1.7 (-)

>>>>>>>     +  # from "elsif" and "then" C-M-f should jump to next "elsif"/"else"
>>>>>>>       if a == 2 then
>>>>>>>         puts "hello"
>>>>>>>       elsif a == 3
>>>>>
>>>>> Try out the change referenced above, but it doesn't do exactly
>>>>> this. Because the tree-sitter parse tree doesn't match the intuition you
>>>>> described above.
>>>> Thanks for adding "then" and "else" that works not bad.
>>>> Then "elsif" could be added as well.
>>>
>>> You can try it and report back. My impression is that it made navigation
>>> worse: the "elsif" nodes are not siblings of one another, they are
>>> nested. So it doesn't exactly match your expectations.
>> Now I tried and indeed it does wrong thing: jumps to the end of the
>> last "else" instead of the end of own block because they are nested.
>> But maybe possible to skip "condition" and jump to the end of its
>> "consequence" before "alternative"?
>
> With custom code? Like with other questions, I'm not sure where to plug it
> in.
>
> I guess it's possible to set up a ruby-ts-mode specific wrapper for
> treesit-forward-sexp, but that may not be the most optimal way to do
> that. Anyway, I haven't studied this direction yet.

Shouldn't treesit-forward-sexp provide a way for ts-modes to override
the default handling?  By default for all ts-modes such a hook could
check if point is inside strings/comments then to use syntax navigation.
And ruby-ts-mode could use such a hook to implement exceptions like
handling 'else'.

>>>>> Also, interactive forward-sexp never reports "No next sexp" when inside
>>>>> parens or begin...end. It will do forward-up-list instead.
>>>> On the one hand, it's inconsistent with the default non-treesit behavior of
>>>> forward-sexp.  On the other hand, the default behavior is too annoying
>>>> when it screams all the time with "Containing expression ends prematurely!"
>>>> instead of doing something useful.
>>>
>>> Looks like I have been spoiled by Paredit's paredit-forward which catches
>>> such errors and does the appropriate thing. Might be nice to bring this
>>> behavior to Emacs as forward-sexp-command, for example.
>> Agreed, at least as opt-in.
>
> Sounds worth a separate bug-report/feature-request.

Such option would be nice, but still need to investigate here
why "No next sexp" not reported inside begin/class/module.

>>>>>>> +# when point is after @, C-M-f should jump to the end of symbol
>>>>>>>     zzz @abc,
>>>>>>>         4
>>>>>
>>>>> This is something that would need to be changed somewhere inside
>>>>> treesit-forward-sexp (or treesit--navigate-thing). The default forward-sexp
>>>>> behaves differently when in the middle of a symbol.
>>>> Agreed, more general changes are needed when point is inside symbols,
>>>> strings, comments, etc.
>>>
>>> This is regarding behavior "inside" a thing as understood by
>>> treesit. Unrelated to Emacs's syntactic entities.
>> "Inside a thing" could be handled the same way as "inside
>> strings/comments".
>
> IIUC, treesit knows about the bounds of said thing, it just chooses not to
> move in such situation. That just seems like a bug, not a fundamental
> limitaiton.

This could be fixed like described above.

>>>>>>> +# C-M-f on '[' doesn't jump to after ']'
>>>>>>> +hash['key']
>>>>>>> +
>>>>>
>>>>> As discussed previously, there is no specific node which spans from [ to
>>>>> ]. Some custom code could probably be written (there *are* leaf nodes for [
>>>>> and ]), but the current capabilities of treesit-thing-settings don't offer
>>>>> a good way to plug that in.
>>>> Like for point inside strings, this might require more general changes
>>>> that take into account syntax tables.
>>>
>>> Possibly, but I expect a solution that doesn't use the syntax table would
>>> be tried first.
>> Since there is no available information from treesit, handling
>> treesit-forward-sexp inside strings/comments could forward to the syntax table
>> like `prog-fill-reindent-defun' forwards to `fill-paragraph'.
>
> Maybe.

Idem.




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

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


Received: (at 67036) by debbugs.gnu.org; 11 Dec 2023 00:47:40 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 10 19:47:40 2023
Received: from localhost ([127.0.0.1]:52135 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1rCUSS-0003Gl-3n
	for submit <at> debbugs.gnu.org; Sun, 10 Dec 2023 19:47:40 -0500
Received: from wout1-smtp.messagingengine.com ([64.147.123.24]:48289)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dmitry@HIDDEN>) id 1rCUSM-0003GN-BV
 for 67036 <at> debbugs.gnu.org; Sun, 10 Dec 2023 19:47:38 -0500
Received: from compute4.internal (compute4.nyi.internal [10.202.2.44])
 by mailout.west.internal (Postfix) with ESMTP id AF0353200A89;
 Sun, 10 Dec 2023 19:47:13 -0500 (EST)
Received: from mailfrontend1 ([10.202.2.162])
 by compute4.internal (MEProxy); Sun, 10 Dec 2023 19:47:14 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc
 :cc:content-transfer-encoding:content-type:content-type:date
 :date:from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:sender:subject:subject:to:to; s=fm3; t=
 1702255633; x=1702342033; bh=KFbFKfGH3rH1RtzS+W+QPywtm/hOCJGsFh6
 kMOjcPl0=; b=nmWJdKO2sebqojrPXPCYwR2BsYKuRNDqTB7CWv72P2SLrFzaWMA
 NYXU+Wszv0VVwPDrYYz6Rxlsig2jhN+ySJcjTqQHPeunRVAyvLZxGA62Dr+EjLaS
 1wDRy9diEfz2BMYpC+pCQmSPMdHzOvFZkNo5NJDMof4k4lfK602q3RyJOM6hKmX7
 Tv/Gz6o/pYwwSfdhD8Kg4ezbNa3s/VgNkFm4wwVnULGLTjXcSLTVqJUM2ioRbWBO
 myr0yz5SnOzeVsFJZoSPz9F6IpU65KINqpq48ja4XXuydqvB0vkuZStWDgvYsPAg
 X7gMWx+V7tTKucwGMmDnLO7Eav8hJSzi1+w==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:cc:content-transfer-encoding
 :content-type:content-type:date:date:feedback-id:feedback-id
 :from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:sender:subject:subject:to:to:x-me-proxy
 :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=
 1702255633; x=1702342033; bh=KFbFKfGH3rH1RtzS+W+QPywtm/hOCJGsFh6
 kMOjcPl0=; b=fj78micF4LxLELUhuGZS23YBouOjsES/0JOnq8ZXTAvcFE/rm7O
 U/Ta3ZvNKfk7B5sYfLg3WhIHna+Tb2YYB0J0FeMCEwwTsSHOxTQIpU+N4b/E+dfs
 PVNvSPvSEKn++OQcA6ALREok9KvJpdIw+XtzuQc6aoT7iK+SmY+x6H9/oLs+cSwA
 S7XMbAlq09lMECnTB+Q9QmdM2wt4FBMeLDvEie9LGBFfrs6GkKAX8NnJJJjgMXU5
 92ISovEwgaPH3xK2ZxZkNC5vhqAQfdrU6tjIdatdUNppJm8XS1szd3Oa9p89XH3i
 YFpCo3TSxo11uMGW6QeK3OYj0au+KHyEkZQ==
X-ME-Sender: <xms:EFx2ZTxc3qwn99UM4eyQiWc5urPUsybK3nNgdmv1Mwzyf0NDzw1EYg>
 <xme:EFx2ZbRJ0bge6JxBhyz02PAB3uR3YEhF_AJ9yIOwB6t1cnIoFPhHwmYX3SZrIzNjq
 2XmZlX81fTq4bLjDds>
X-ME-Received: <xmr:EFx2ZdVxpLql76qztMBPa1JLoSNPrqTbPswEjRkRjrD8qs_TTrJAzPcRnD-NGaUh-2usHg>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudeluddgvdejucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
 uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne
 cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpeffmhhi
 thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth
 htvghrnhepkeegueektdfhudfgjeefhfehgeelfedufffgjedvhfdtgfehueevteekudeh
 gfeunecuffhomhgrihhnpegvnhgurdhithenucevlhhushhtvghrufhiiigvpedtnecurf
 grrhgrmhepmhgrihhlfhhrohhmpegumhhithhrhiesghhuthhovhdruggvvh
X-ME-Proxy: <xmx:EVx2ZdhBiSFCV-vKLwosWcB49jtqKUoB47W0xUDEUUX9TnVzhT89Vg>
 <xmx:EVx2ZVDd_NfJfBkKIi6OmMbUHfHUnS4j-ghZ7bKWDRoYnbjIwEhrTQ>
 <xmx:EVx2ZWK3Jgz0aFbqJLh7q6FLxX0LHCGpsuTYAGWKAhjvNkTDm-z7YA>
 <xmx:EVx2ZYNEaE7Obn5Sf1asD9mWByx-ol28CgY58iZ3X2nZqBAXPhGB8Q>
Feedback-ID: i0e71465a:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun,
 10 Dec 2023 19:47:11 -0500 (EST)
Message-ID: <d790e608-abe4-72d5-b115-ef7550615d3f@HIDDEN>
Date: Mon, 11 Dec 2023 02:47:10 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.13.0
Subject: Re: bug#67036: 30.0.50; treesit-forward-sexp not working properly in
 ruby-ts-mode
Content-Language: en-US
To: Juri Linkov <juri@HIDDEN>
References: <86bkc2nktq.fsf@HIDDEN> <83a5r2dw25.fsf@HIDDEN>
 <45795de5-2064-3ab9-3cbb-c1b2018faf7c@HIDDEN>
 <864jh776bm.fsf@HIDDEN>
 <5a8d4404-47ec-9190-d80f-edc1fca26cf3@HIDDEN>
 <86msuxulvt.fsf@HIDDEN>
From: Dmitry Gutov <dmitry@HIDDEN>
In-Reply-To: <86msuxulvt.fsf@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.9 (--)
X-Debbugs-Envelope-To: 67036
Cc: Eli Zaretskii <eliz@HIDDEN>, 67036 <at> debbugs.gnu.org,
 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: -3.9 (---)

On 29/11/2023 09:04, Juri Linkov wrote:
>>>>>>     +  # from "elsif" and "then" C-M-f should jump to next "elsif"/"else"
>>>>>>       if a == 2 then
>>>>>>         puts "hello"
>>>>>>       elsif a == 3
>>>>
>>>> Try out the change referenced above, but it doesn't do exactly
>>>> this. Because the tree-sitter parse tree doesn't match the intuition you
>>>> described above.
>>> Thanks for adding "then" and "else" that works not bad.
>>> Then "elsif" could be added as well.
>>
>> You can try it and report back. My impression is that it made navigation
>> worse: the "elsif" nodes are not siblings of one another, they are
>> nested. So it doesn't exactly match your expectations.
> 
> Now I tried and indeed it does wrong thing: jumps to the end of the
> last "else" instead of the end of own block because they are nested.
> But maybe possible to skip "condition" and jump to the end of its
> "consequence" before "alternative"?

With custom code? Like with other questions, I'm not sure where to plug 
it in.

I guess it's possible to set up a ruby-ts-mode specific wrapper for 
treesit-forward-sexp, but that may not be the most optimal way to do 
that. Anyway, I haven't studied this direction yet.

>>>> Also, interactive forward-sexp never reports "No next sexp" when inside
>>>> parens or begin...end. It will do forward-up-list instead.
>>> On the one hand, it's inconsistent with the default non-treesit behavior
>>> of
>>> forward-sexp.  On the other hand, the default behavior is too annoying
>>> when it screams all the time with "Containing expression ends prematurely!"
>>> instead of doing something useful.
>>
>> Looks like I have been spoiled by Paredit's paredit-forward which catches
>> such errors and does the appropriate thing. Might be nice to bring this
>> behavior to Emacs as forward-sexp-command, for example.
> 
> Agreed, at least as opt-in.

Sounds worth a separate bug-report/feature-request.

>>>>>> +# when point is after @, C-M-f should jump to the end of symbol
>>>>>>     zzz @abc,
>>>>>>         4
>>>>
>>>> This is something that would need to be changed somewhere inside
>>>> treesit-forward-sexp (or treesit--navigate-thing). The default forward-sexp
>>>> behaves differently when in the middle of a symbol.
>>> Agreed, more general changes are needed when point is inside symbols,
>>> strings, comments, etc.
>>
>> This is regarding behavior "inside" a thing as understood by
>> treesit. Unrelated to Emacs's syntactic entities.
> 
> "Inside a thing" could be handled the same way as "inside strings/comments".

IIUC, treesit knows about the bounds of said thing, it just chooses not 
to move in such situation. That just seems like a bug, not a fundamental 
limitaiton.

>>>>>> +# C-M-f on '[' doesn't jump to after ']'
>>>>>> +hash['key']
>>>>>> +
>>>>
>>>> As discussed previously, there is no specific node which spans from [ to
>>>> ]. Some custom code could probably be written (there *are* leaf nodes for [
>>>> and ]), but the current capabilities of treesit-thing-settings don't offer
>>>> a good way to plug that in.
>>> Like for point inside strings, this might require more general changes
>>> that take into account syntax tables.
>>
>> Possibly, but I expect a solution that doesn't use the syntax table would
>> be tried first.
> 
> Since there is no available information from treesit, handling
> treesit-forward-sexp inside strings/comments could forward to the syntax table
> like `prog-fill-reindent-defun' forwards to `fill-paragraph'.

Maybe.




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

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


Received: (at 67036) by debbugs.gnu.org; 29 Nov 2023 07:20:57 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Nov 29 02:20:57 2023
Received: from localhost ([127.0.0.1]:48666 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r8EsT-0005GO-AU
	for submit <at> debbugs.gnu.org; Wed, 29 Nov 2023 02:20:57 -0500
Received: from relay4-d.mail.gandi.net ([2001:4b98:dc4:8::224]:35713)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1r8EsR-0005G8-1r
 for 67036 <at> debbugs.gnu.org; Wed, 29 Nov 2023 02:20:56 -0500
Received: by mail.gandi.net (Postfix) with ESMTPSA id E806CE0004;
 Wed, 29 Nov 2023 07:20:39 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: Dmitry Gutov <dmitry@HIDDEN>
Subject: Re: bug#67036: 30.0.50; treesit-forward-sexp not working properly
 in ruby-ts-mode
In-Reply-To: <5a8d4404-47ec-9190-d80f-edc1fca26cf3@HIDDEN> (Dmitry Gutov's
 message of "Wed, 29 Nov 2023 00:15:50 +0200")
Organization: LINKOV.NET
References: <86bkc2nktq.fsf@HIDDEN> <83a5r2dw25.fsf@HIDDEN>
 <45795de5-2064-3ab9-3cbb-c1b2018faf7c@HIDDEN>
 <864jh776bm.fsf@HIDDEN>
 <5a8d4404-47ec-9190-d80f-edc1fca26cf3@HIDDEN>
Date: Wed, 29 Nov 2023 09:04:14 +0200
Message-ID: <86msuxulvt.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain
X-GND-Sasl: juri@HIDDEN
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 67036
Cc: Eli Zaretskii <eliz@HIDDEN>, 67036 <at> debbugs.gnu.org,
 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: -1.7 (-)

>>>>>    +  # from "elsif" and "then" C-M-f should jump to next "elsif"/"else"
>>>>>      if a == 2 then
>>>>>        puts "hello"
>>>>>      elsif a == 3
>>>
>>> Try out the change referenced above, but it doesn't do exactly
>>> this. Because the tree-sitter parse tree doesn't match the intuition you
>>> described above.
>> Thanks for adding "then" and "else" that works not bad.
>> Then "elsif" could be added as well.
>
> You can try it and report back. My impression is that it made navigation
> worse: the "elsif" nodes are not siblings of one another, they are
> nested. So it doesn't exactly match your expectations.

Now I tried and indeed it does wrong thing: jumps to the end of the
last "else" instead of the end of own block because they are nested.
But maybe possible to skip "condition" and jump to the end of its
"consequence" before "alternative"?

>>> Also, interactive forward-sexp never reports "No next sexp" when inside
>>> parens or begin...end. It will do forward-up-list instead.
>> On the one hand, it's inconsistent with the default non-treesit behavior
>> of
>> forward-sexp.  On the other hand, the default behavior is too annoying
>> when it screams all the time with "Containing expression ends prematurely!"
>> instead of doing something useful.
>
> Looks like I have been spoiled by Paredit's paredit-forward which catches
> such errors and does the appropriate thing. Might be nice to bring this
> behavior to Emacs as forward-sexp-command, for example.

Agreed, at least as opt-in.

>>>>> +# when point is after @, C-M-f should jump to the end of symbol
>>>>>    zzz @abc,
>>>>>        4
>>>
>>> This is something that would need to be changed somewhere inside
>>> treesit-forward-sexp (or treesit--navigate-thing). The default forward-sexp
>>> behaves differently when in the middle of a symbol.
>> Agreed, more general changes are needed when point is inside symbols,
>> strings, comments, etc.
>
> This is regarding behavior "inside" a thing as understood by
> treesit. Unrelated to Emacs's syntactic entities.

"Inside a thing" could be handled the same way as "inside strings/comments".

>>>>> +# C-M-f on '[' doesn't jump to after ']'
>>>>> +hash['key']
>>>>> +
>>>
>>> As discussed previously, there is no specific node which spans from [ to
>>> ]. Some custom code could probably be written (there *are* leaf nodes for [
>>> and ]), but the current capabilities of treesit-thing-settings don't offer
>>> a good way to plug that in.
>> Like for point inside strings, this might require more general changes
>> that take into account syntax tables.
>
> Possibly, but I expect a solution that doesn't use the syntax table would
> be tried first.

Since there is no available information from treesit, handling
treesit-forward-sexp inside strings/comments could forward to the syntax table
like `prog-fill-reindent-defun' forwards to `fill-paragraph'.




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

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


Received: (at 67036) by debbugs.gnu.org; 28 Nov 2023 22:16:11 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Tue Nov 28 17:16:11 2023
Received: from localhost ([127.0.0.1]:48400 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r86NG-0007P1-OW
	for submit <at> debbugs.gnu.org; Tue, 28 Nov 2023 17:16:11 -0500
Received: from out2-smtp.messagingengine.com ([66.111.4.26]:34605)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dmitry@HIDDEN>) id 1r86NC-0007OJ-W7
 for 67036 <at> debbugs.gnu.org; Tue, 28 Nov 2023 17:16:08 -0500
Received: from compute1.internal (compute1.nyi.internal [10.202.2.41])
 by mailout.nyi.internal (Postfix) with ESMTP id B14325C01E0;
 Tue, 28 Nov 2023 17:15:54 -0500 (EST)
Received: from mailfrontend1 ([10.202.2.162])
 by compute1.internal (MEProxy); Tue, 28 Nov 2023 17:15:54 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc
 :cc:content-transfer-encoding:content-type:content-type:date
 :date:from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:sender:subject:subject:to:to; s=fm3; t=
 1701209754; x=1701296154; bh=VTbm7J5MMjTpBgYyL7ZNc0ZbbqXQspMPfVb
 IeMouy2U=; b=GItbc7TrIs1hdrHgUg4P3HZWfHqYiK6T2YFaixfF0J7+prg9Bsn
 jSYX/Mi8Ub644wiRkLpnnCn26b3uJy0lcQYQjv30wYg1VA9Po7hosudeHDMe9JRN
 HZjD4Hl670DBN6/e6P71zSfEWckwuuxQDkR7jaHxCk9iD6kaqXbRJt/T1JppEN85
 QdP66qJIo9NI/968aF1MYOZL9jOqeWOidqD5X/A1iYLpsawRSHqBPOmZLoVlnn9h
 MdPHCaUQcPGtqkCd3ku33x1LIBmMtJ49VMAjP8gnRosKq4vuk+Zh33ZX+XztjElz
 NIlOYt9T4vNDFXhPVSZa+5vFOxVLL5CNJ5Q==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:cc:content-transfer-encoding
 :content-type:content-type:date:date:feedback-id:feedback-id
 :from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:sender:subject:subject:to:to:x-me-proxy
 :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=
 1701209754; x=1701296154; bh=VTbm7J5MMjTpBgYyL7ZNc0ZbbqXQspMPfVb
 IeMouy2U=; b=T02GwANcpuaJSEzD6sR9K5jK0gBGWUURA5TDR116gZLWNMuh488
 +/YIb1PvQQkN/IK60etH3yz3bSZvRTC3+g0lh0Lw2JaSE3VzA+kY9qhYzZ9TFD2a
 xug+ez8adn/cddYpw+PBVE9cduSFt74/XjGZfrDiPnIIDXiE6LuKZdhHrVoI6Tfp
 LuL43NvjSfin1g1lsLlW/5kGV0hNaMQoqJvdLUCWP8snIBnY15PwhZ9ti84CcnI0
 1BTvtpxoVLqL8vtixbbZKGux1appF10+1mfIwTsvGEs7DM6fk3Sn1Mpbjl4jCwS4
 bZADUjJ6zGrCYT0QKpyRQfJJwEPS72HofAg==
X-ME-Sender: <xms:mmZmZSy3WCFpMuXuIhb7ZNKWufm9kg-lSmHiCrOEgDAh-uoL7XMa-Q>
 <xme:mmZmZeSh3TPO8oA3Yf8z2F4BjGti3Ympr3p-MQDMdcGJ5gL8kQTCOEx5csq6Ycn8P
 hcwoZkMHdlQuMyOBuw>
X-ME-Received: <xmr:mmZmZUUeYSLZ71ED8Js3UaPKKY4ukHkwYAwB0XJhzv3Xg74VTFbM_h2YBqFx7d1OXufe7g>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudeifedgudehjecutefuodetggdotefrod
 ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh
 necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd
 enucfjughrpefkffggfgfuvfevfhfhjggtgfesthejredttdefjeenucfhrhhomhepffhm
 ihhtrhihucfiuhhtohhvuceoughmihhtrhihsehguhhtohhvrdguvghvqeenucggtffrrg
 htthgvrhhnpeekgeeukedthfdugfejfefhheegleefudffgfejvdfhtdfgheeuveetkedu
 hefgueenucffohhmrghinhepvghnugdrihhtnecuvehluhhsthgvrhfuihiivgeptdenuc
 frrghrrghmpehmrghilhhfrhhomhepughmihhtrhihsehguhhtohhvrdguvghv
X-ME-Proxy: <xmx:mmZmZYhNC-elWnXIHjbDB5cLkLlBhg0sf0lrByI6J1H4kgp3FacQIg>
 <xmx:mmZmZUD3Gy2aEx5ctJb4kOnTaih_95c9OAEnhfw9PphUbnOpSGEfXg>
 <xmx:mmZmZZJi8kTsJFnQtmUFbhwkqTBJRfyb9lpeALvj2s09WKhE_zTI2A>
 <xmx:mmZmZXOsNmjldQWG0JuW-3AppNTuy2cgJaFOrbcNl_NlMXYndCmhqg>
Feedback-ID: i0e71465a:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue,
 28 Nov 2023 17:15:52 -0500 (EST)
Message-ID: <5a8d4404-47ec-9190-d80f-edc1fca26cf3@HIDDEN>
Date: Wed, 29 Nov 2023 00:15:50 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.13.0
Subject: Re: bug#67036: 30.0.50; treesit-forward-sexp not working properly in
 ruby-ts-mode
Content-Language: en-US
To: Juri Linkov <juri@HIDDEN>
References: <86bkc2nktq.fsf@HIDDEN> <83a5r2dw25.fsf@HIDDEN>
 <45795de5-2064-3ab9-3cbb-c1b2018faf7c@HIDDEN>
 <864jh776bm.fsf@HIDDEN>
From: Dmitry Gutov <dmitry@HIDDEN>
In-Reply-To: <864jh776bm.fsf@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.9 (--)
X-Debbugs-Envelope-To: 67036
Cc: Eli Zaretskii <eliz@HIDDEN>, 67036 <at> debbugs.gnu.org,
 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: -3.9 (---)

On 27/11/2023 19:06, Juri Linkov wrote:
>>>>    +  # from "elsif" and "then" C-M-f should jump to next "elsif"/"else"
>>>>      if a == 2 then
>>>>        puts "hello"
>>>>      elsif a == 3
>>
>> Try out the change referenced above, but it doesn't do exactly
>> this. Because the tree-sitter parse tree doesn't match the intuition you
>> described above.
> 
> Thanks for adding "then" and "else" that works not bad.
> Then "elsif" could be added as well.

You can try it and report back. My impression is that it made navigation 
worse: the "elsif" nodes are not siblings of one another, they are 
nested. So it doesn't exactly match your expectations.

>>>> +# when point is after @, C-M-f should jump to the end of symbol
>>>>    zzz @abc,
>>>>        4
>>
>> This is something that would need to be changed somewhere inside
>> treesit-forward-sexp (or treesit--navigate-thing). The default forward-sexp
>> behaves differently when in the middle of a symbol.
> 
> Agreed, more general changes are needed when point is inside symbols,
> strings, comments, etc.

This is regarding behavior "inside" a thing as understood by treesit. 
Unrelated to Emacs's syntactic entities.

>> Also, interactive forward-sexp never reports "No next sexp" when inside
>> parens or begin...end. It will do forward-up-list instead.
> 
> On the one hand, it's inconsistent with the default non-treesit behavior of
> forward-sexp.  On the other hand, the default behavior is too annoying
> when it screams all the time with "Containing expression ends prematurely!"
> instead of doing something useful.

Looks like I have been spoiled by Paredit's paredit-forward which 
catches such errors and does the appropriate thing. Might be nice to 
bring this behavior to Emacs as forward-sexp-command, for example.

>>>>      def begin
>>>>      end
>>>>    end
>>>> @@ -522,6 +530,9 @@ def qux
>>>>      puts "Japanese translation: #{orig_text} => #{trans_text}"
>>>>    end
>>>>    +# C-M-f on '[' doesn't jump to after ']'
>>>> +hash['key']
>>>> +
>>
>> As discussed previously, there is no specific node which spans from [ to
>> ]. Some custom code could probably be written (there *are* leaf nodes for [
>> and ]), but the current capabilities of treesit-thing-settings don't offer
>> a good way to plug that in.
> 
> Like for point inside strings, this might require more general changes
> that take into account syntax tables.

Possibly, but I expect a solution that doesn't use the syntax table 
would be tried first.




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

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


Received: (at 67036) by debbugs.gnu.org; 27 Nov 2023 17:08:25 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Mon Nov 27 12:08:25 2023
Received: from localhost ([127.0.0.1]:44662 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r7f5o-0005hM-HQ
	for submit <at> debbugs.gnu.org; Mon, 27 Nov 2023 12:08:25 -0500
Received: from relay8-d.mail.gandi.net ([217.70.183.201]:36163)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1r7f5e-0005gp-R9
 for 67036 <at> debbugs.gnu.org; Mon, 27 Nov 2023 12:08:15 -0500
Received: by mail.gandi.net (Postfix) with ESMTPSA id A15031BF203;
 Mon, 27 Nov 2023 17:07:56 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: Dmitry Gutov <dmitry@HIDDEN>
Subject: Re: bug#67036: 30.0.50; treesit-forward-sexp not working properly
 in ruby-ts-mode
In-Reply-To: <45795de5-2064-3ab9-3cbb-c1b2018faf7c@HIDDEN> (Dmitry Gutov's
 message of "Sun, 26 Nov 2023 18:12:41 +0200")
Organization: LINKOV.NET
References: <86bkc2nktq.fsf@HIDDEN> <83a5r2dw25.fsf@HIDDEN>
 <45795de5-2064-3ab9-3cbb-c1b2018faf7c@HIDDEN>
Date: Mon, 27 Nov 2023 19:06:05 +0200
Message-ID: <864jh776bm.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain
X-GND-Sasl: juri@HIDDEN
X-Spam-Score: -0.7 (/)
X-Debbugs-Envelope-To: 67036
Cc: Eli Zaretskii <eliz@HIDDEN>, 67036 <at> debbugs.gnu.org,
 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: -1.7 (-)

>>>   +  # from "elsif" and "then" C-M-f should jump to next "elsif"/"else"
>>>     if a == 2 then
>>>       puts "hello"
>>>     elsif a == 3
>
> Try out the change referenced above, but it doesn't do exactly
> this. Because the tree-sitter parse tree doesn't match the intuition you
> described above.

Thanks for adding "then" and "else" that works not bad.
Then "elsif" could be added as well.

>>> +# when point is after @, C-M-f should jump to the end of symbol
>>>   zzz @abc,
>>>       4
>
> This is something that would need to be changed somewhere inside
> treesit-forward-sexp (or treesit--navigate-thing). The default forward-sexp
> behaves differently when in the middle of a symbol.

Agreed, more general changes are needed when point is inside symbols,
strings, comments, etc.

> Also, interactive forward-sexp never reports "No next sexp" when inside
> parens or begin...end. It will do forward-up-list instead.

On the one hand, it's inconsistent with the default non-treesit behavior of
forward-sexp.  On the other hand, the default behavior is too annoying
when it screams all the time with "Containing expression ends prematurely!"
instead of doing something useful.

>>>     def foo
>>> -    self.end
>>> +    self.end # when point between 'e' and 'n', C-M-b should jump to "self"
>
> Same as above, although the point will jump to before "end" (after the
> period). And the next C-M-b will jump to before "self".

This looks right.

>>> +  class << self
>>> +    def bar
>>> +    end
>>> +  end
>>> +  # C-M-b at the end of "end" should jump to "class"
>>> +
>
> Now fixed.

Thanks, confirmed.

>>>     def begin
>>>     end
>>>   end
>>> @@ -522,6 +530,9 @@ def qux
>>>     puts "Japanese translation: #{orig_text} => #{trans_text}"
>>>   end
>>>   +# C-M-f on '[' doesn't jump to after ']'
>>> +hash['key']
>>> +
>
> As discussed previously, there is no specific node which spans from [ to
> ]. Some custom code could probably be written (there *are* leaf nodes for [
> and ]), but the current capabilities of treesit-thing-settings don't offer
> a good way to plug that in.

Like for point inside strings, this might require more general changes
that take into account syntax tables.




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

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


Received: (at 67036) by debbugs.gnu.org; 26 Nov 2023 16:12:59 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Nov 26 11:12:59 2023
Received: from localhost ([127.0.0.1]:42597 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r7Hkh-0003bd-6a
	for submit <at> debbugs.gnu.org; Sun, 26 Nov 2023 11:12:59 -0500
Received: from out1-smtp.messagingengine.com ([66.111.4.25]:46995)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <dmitry@HIDDEN>) id 1r7Hke-0003bM-Ue
 for 67036 <at> debbugs.gnu.org; Sun, 26 Nov 2023 11:12:58 -0500
Received: from compute1.internal (compute1.nyi.internal [10.202.2.41])
 by mailout.nyi.internal (Postfix) with ESMTP id E549D5C013B;
 Sun, 26 Nov 2023 11:12:45 -0500 (EST)
Received: from mailfrontend1 ([10.202.2.162])
 by compute1.internal (MEProxy); Sun, 26 Nov 2023 11:12:45 -0500
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gutov.dev; h=cc
 :cc:content-transfer-encoding:content-type:content-type:date
 :date:from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:sender:subject:subject:to:to; s=fm3; t=
 1701015165; x=1701101565; bh=6/7IoZ9Zaj/QnleCObsr26i03Ad092MT4EL
 sRxjFOk8=; b=uj47ZY5hTxYsLeF7DI41rPYx00GKF7c++iJD9quWx82VZhdGGNO
 UwWtKcDWZx1tqwSwCtHnKO/kC3co++XsK+I5RV5tE009/OLTHuACGDhodPdTvVIb
 mxdsSjv1IXFUyCzb2Ttt58nH1hleaulZB1TR+hWoqc8i3uw1s2LyVt50BbqmBCzo
 QInO32Px1lqpyyw6/Lk2FfDor6yQPG+u8uYwD7Efp+wTYDLJXhIm7lZOq722lPiI
 h51BgbZaV5PNTCqbJgJJ7nbI/VwObppuTsmipoKqdZoHDXpAXAhNcpWg7Wr5lqMt
 giffa15EZfDSbl6eORRon5egoPaKZy6k4LA==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
 messagingengine.com; h=cc:cc:content-transfer-encoding
 :content-type:content-type:date:date:feedback-id:feedback-id
 :from:from:in-reply-to:in-reply-to:message-id:mime-version
 :references:reply-to:sender:subject:subject:to:to:x-me-proxy
 :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=
 1701015165; x=1701101565; bh=6/7IoZ9Zaj/QnleCObsr26i03Ad092MT4EL
 sRxjFOk8=; b=B9lHOnhdJKLy/gh9zuy1wZvQSdXPbJgYhWmd7n/xALw2imsJvAT
 w/gvCAZhLbrgpDQmilLb9tFfk3gbHXSq7TDVoH3tampzmyuMfCV4RCX6uwn/aV9n
 6HQRTgrrCfLPIoJ2N+mAE4Z36dEpo6ACXFRajWIB19Qht3rLHcuU0KbmYgF7B/cT
 QH9Erfq5YTlidqCyDTltAPAMPyoZcGXcVDYXknbsPoRBJgX3F1XV8fB8uzlC3dVp
 3h/ywdROmIsg2QutwSDGM3431UQhorjZ2uNTiYFIRs4uCKpNoP3DjhtEMhuWxfKw
 w7kZpv3AfP8WR6hmQCMuI05J+9W8Bli84Ug==
X-ME-Sender: <xms:fW5jZVYQxfHT-y7sNsPdtk2Rc5ViXhN8wtyyBnZ6p8XSXIsChymmrQ>
 <xme:fW5jZcZU0-jiw4_l_46KjYDtFUzDv_hjAn0eBv4_mYjO-sn6tRxHniRU9Sy0lHzbs
 X6RFysvoIyuNhpLxxI>
X-ME-Received: <xmr:fW5jZX9UDdIQ_60ft0BZv52FYV3U2QAXsLYSQbXjgqJZCDEFwv_qfgvraDD-ELX3hxz9ZQ>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrudehledgkeekucetufdoteggodetrfdotf
 fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen
 uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne
 cujfgurhepkfffgggfuffvvehfhfgjtgfgsehtjeertddtfeejnecuhfhrohhmpeffmhhi
 thhrhicuifhuthhovhcuoegumhhithhrhiesghhuthhovhdruggvvheqnecuggftrfgrth
 htvghrnhepkeegueektdfhudfgjeefhfehgeelfedufffgjedvhfdtgfehueevteekudeh
 gfeunecuffhomhgrihhnpegvnhgurdhithenucevlhhushhtvghrufhiiigvpedtnecurf
 grrhgrmhepmhgrihhlfhhrohhmpegumhhithhrhiesghhuthhovhdruggvvh
X-ME-Proxy: <xmx:fW5jZTqAjrX1MPFW8zUg4gVp6hMzBCmCDPdEjUvYOKXs2Fm9CL-17g>
 <xmx:fW5jZQp5nBL8JWPkizFO7vQ2_6aXr5YI-7ZswjNGIJznU2acsXyZMQ>
 <xmx:fW5jZZQhfUM7vug2DOFgAMbpueiFoAyWg6y7i2uMTEe7-FEUW_ou9w>
 <xmx:fW5jZX3dlQYlyhdFqJhJ6XwyPwhxO28LONfFaQoTXmlDYKWTJDQn7g>
Feedback-ID: i0e71465a:Fastmail
Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun,
 26 Nov 2023 11:12:44 -0500 (EST)
Message-ID: <45795de5-2064-3ab9-3cbb-c1b2018faf7c@HIDDEN>
Date: Sun, 26 Nov 2023 18:12:41 +0200
MIME-Version: 1.0
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101
 Thunderbird/102.13.0
Subject: Re: bug#67036: 30.0.50; treesit-forward-sexp not working properly in
 ruby-ts-mode
Content-Language: en-US
To: Eli Zaretskii <eliz@HIDDEN>, Juri Linkov <juri@HIDDEN>,
 Yuan Fu <casouri@HIDDEN>
References: <86bkc2nktq.fsf@HIDDEN> <83a5r2dw25.fsf@HIDDEN>
From: Dmitry Gutov <dmitry@HIDDEN>
In-Reply-To: <83a5r2dw25.fsf@HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Spam-Score: -2.9 (--)
X-Debbugs-Envelope-To: 67036
Cc: 67036 <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: -3.9 (---)

I've pushed an update which improves some of these (commit 2ec4526b972).

On 25/11/2023 11:25, Eli Zaretskii wrote:
> Ping!  Yuan and Dmitry, can we please make some progress here?
> 
>> Cc: dmitry@HIDDEN
>> From: Juri Linkov <juri@HIDDEN>
>> Date: Fri, 10 Nov 2023 09:42:17 +0200
>>
>> Please try these 5 cases described in the comments of this diff:
>>
>> diff --git a/test/lisp/progmodes/ruby-mode-resources/ruby.rb b/test/lisp/progmodes/ruby-mode-resources/ruby.rb
>> index 81d0dfd75c9..abe6a0789b9 100644
>> --- a/test/lisp/progmodes/ruby-mode-resources/ruby.rb
>> +++ b/test/lisp/progmodes/ruby-mode-resources/ruby.rb
>> @@ -123,6 +123,7 @@ def test2 (arg)
>>       puts "there"
>>     end
>>   
>> +  # from "elsif" and "then" C-M-f should jump to next "elsif"/"else" like with { }
>>     if a == 2 then
>>       puts "hello"
>>     elsif a == 3
>> @@ -179,6 +180,7 @@ def test2 (arg)
>>       bar,
>>       :a

Try out the change referenced above, but it doesn't do exactly this. 
Because the tree-sitter parse tree doesn't match the intuition you 
described above.

>> +# when point is after @, C-M-f should jump to the end of symbol
>>   zzz @abc,
>>       4

This is something that would need to be changed somewhere inside 
treesit-forward-sexp (or treesit--navigate-thing). The default 
forward-sexp behaves differently when in the middle of a symbol.

Also, interactive forward-sexp never reports "No next sexp" when inside 
parens or begin...end. It will do forward-up-list instead.

>> @@ -211,10 +213,16 @@ def test2 (arg)
>>   
>>   class C
>>     def foo
>> -    self.end
>> +    self.end # when point between 'e' and 'n', C-M-b should jump to "self"
>>       D.new.class
>>     end

Same as above, although the point will jump to before "end" (after the 
period). And the next C-M-b will jump to before "self".

>> +  class << self
>> +    def bar
>> +    end
>> +  end
>> +  # C-M-b at the end of "end" should jump to "class"
>> +

Now fixed.

>>     def begin
>>     end
>>   end
>> @@ -522,6 +530,9 @@ def qux
>>     puts "Japanese translation: #{orig_text} => #{trans_text}"
>>   end
>>   
>> +# C-M-f on '[' doesn't jump to after ']'
>> +hash['key']
>> +

As discussed previously, there is no specific node which spans from [ to 
]. Some custom code could probably be written (there *are* leaf nodes 
for [ and ]), but the current capabilities of treesit-thing-settings 
don't offer a good way to plug that in.




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

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


Received: (at 67036) by debbugs.gnu.org; 25 Nov 2023 09:25:49 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Nov 25 04:25:49 2023
Received: from localhost ([127.0.0.1]:37803 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r6ov7-0000z7-6t
	for submit <at> debbugs.gnu.org; Sat, 25 Nov 2023 04:25:49 -0500
Received: from eggs.gnu.org ([2001:470:142:3::10]:42602)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <eliz@HIDDEN>) id 1r6ov5-0000yu-8s
 for 67036 <at> debbugs.gnu.org; Sat, 25 Nov 2023 04:25:47 -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 1r6ouu-0007K9-E8; Sat, 25 Nov 2023 04:25:36 -0500
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org;
 s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date:
 mime-version; bh=1ghtlGUtdILmoWWSHc9Fyxar9+OgZdXtT9+/ROlmBP4=; b=miwmiKNZvYXz
 CAnab07x+cykAY36EV+0ICczfA4H1wH6QfOySyeXycOlV2Pt9b975X9Gy1f0hC8H1p6HUDSDxty/X
 iHTmKd5PFbHfwKHxxwenfubWo6YtELc7ijKvfvzOLmNjX++toL2ZU8OX06MqSWO0qq9bPJnzIc+Y5
 o7GFXvKuMrKO9upQsrr7g9iGMIzwjiO0p1v7dYcCMv3yJHGkLrH0LiQYK8qKRAluNrfNa1TS7Q6nk
 EtsMa2hgWGhDU+xwONaCZ7ma+EpIPj6LGHmkjJfc5EBX0vR1JN0OIuVAregPsOnIKAN4YqSg1f7W4
 REntS6WZzZZ5Ec+UV/SPLg==;
Date: Sat, 25 Nov 2023 11:25:06 +0200
Message-Id: <83a5r2dw25.fsf@HIDDEN>
From: Eli Zaretskii <eliz@HIDDEN>
To: Juri Linkov <juri@HIDDEN>, Yuan Fu <casouri@HIDDEN>,
 dmitry@HIDDEN
In-Reply-To: <86bkc2nktq.fsf@HIDDEN> (message from Juri Linkov on
 Fri, 10 Nov 2023 09:42:17 +0200)
Subject: Re: bug#67036: 30.0.50;
 treesit-forward-sexp not working properly in ruby-ts-mode
References: <86bkc2nktq.fsf@HIDDEN>
X-Spam-Score: -2.3 (--)
X-Debbugs-Envelope-To: 67036
Cc: 67036 <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: -3.3 (---)

Ping!  Yuan and Dmitry, can we please make some progress here?

> Cc: dmitry@HIDDEN
> From: Juri Linkov <juri@HIDDEN>
> Date: Fri, 10 Nov 2023 09:42:17 +0200
> 
> Please try these 5 cases described in the comments of this diff:
> 
> diff --git a/test/lisp/progmodes/ruby-mode-resources/ruby.rb b/test/lisp/progmodes/ruby-mode-resources/ruby.rb
> index 81d0dfd75c9..abe6a0789b9 100644
> --- a/test/lisp/progmodes/ruby-mode-resources/ruby.rb
> +++ b/test/lisp/progmodes/ruby-mode-resources/ruby.rb
> @@ -123,6 +123,7 @@ def test2 (arg)
>      puts "there"
>    end
>  
> +  # from "elsif" and "then" C-M-f should jump to next "elsif"/"else" like with { }
>    if a == 2 then
>      puts "hello"
>    elsif a == 3
> @@ -179,6 +180,7 @@ def test2 (arg)
>      bar,
>      :a
>  
> +# when point is after @, C-M-f should jump to the end of symbol
>  zzz @abc,
>      4
>  
> @@ -211,10 +213,16 @@ def test2 (arg)
>  
>  class C
>    def foo
> -    self.end
> +    self.end # when point between 'e' and 'n', C-M-b should jump to "self"
>      D.new.class
>    end
>  
> +  class << self
> +    def bar
> +    end
> +  end
> +  # C-M-b at the end of "end" should jump to "class"
> +
>    def begin
>    end
>  end
> @@ -522,6 +530,9 @@ def qux
>    puts "Japanese translation: #{orig_text} => #{trans_text}"
>  end
>  
> +# C-M-f on '[' doesn't jump to after ']'
> +hash['key']
> +
>  # Tokenizing "**" and "|" separately.
>  def resolve(**args)
>    members = proc do |**args|
> 
> Is it possible to improve ruby-ts-mode to handle these cases?




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

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


Received: (at submit) by debbugs.gnu.org; 10 Nov 2023 07:52:05 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Fri Nov 10 02:52:05 2023
Received: from localhost ([127.0.0.1]:49461 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1r1MJA-0000KF-Vu
	for submit <at> debbugs.gnu.org; Fri, 10 Nov 2023 02:52:05 -0500
Received: from lists.gnu.org ([2001:470:142::17]:40432)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <juri@HIDDEN>) id 1r1MJ5-0000JB-C9
 for submit <at> debbugs.gnu.org; Fri, 10 Nov 2023 02:52:00 -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 <juri@HIDDEN>) id 1r1MIL-0008RX-VY
 for bug-gnu-emacs@HIDDEN; Fri, 10 Nov 2023 02:51:14 -0500
Received: from relay2-d.mail.gandi.net ([2001:4b98:dc4:8::222])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <juri@HIDDEN>) id 1r1MIJ-00027H-Br
 for bug-gnu-emacs@HIDDEN; Fri, 10 Nov 2023 02:51:13 -0500
Received: by mail.gandi.net (Postfix) with ESMTPSA id C797A40008
 for <bug-gnu-emacs@HIDDEN>; Fri, 10 Nov 2023 07:51:05 +0000 (UTC)
From: Juri Linkov <juri@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: 30.0.50; treesit-forward-sexp not working properly in ruby-ts-mode
Organization: LINKOV.NET
Date: Fri, 10 Nov 2023 09:42:17 +0200
Message-ID: <86bkc2nktq.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/30.0.50 (x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=-=-="
X-GND-Sasl: juri@HIDDEN
Received-SPF: pass client-ip=2001:4b98:dc4:8::222;
 envelope-from=juri@HIDDEN; helo=relay2-d.mail.gandi.net
X-Spam_score_int: -25
X-Spam_score: -2.6
X-Spam_bar: --
X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7,
 SPF_HELO_PASS=-0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: 0.7 (/)
X-Debbugs-Envelope-To: submit
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: -0.3 (/)

--=-=-=
Content-Type: text/plain

X-Debbugs-Cc: dmitry@HIDDEN

Please try these 5 cases described in the comments of this diff:


--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline; filename=ruby-ts-mode.patch

diff --git a/test/lisp/progmodes/ruby-mode-resources/ruby.rb b/test/lisp/progmodes/ruby-mode-resources/ruby.rb
index 81d0dfd75c9..abe6a0789b9 100644
--- a/test/lisp/progmodes/ruby-mode-resources/ruby.rb
+++ b/test/lisp/progmodes/ruby-mode-resources/ruby.rb
@@ -123,6 +123,7 @@ def test2 (arg)
     puts "there"
   end
 
+  # from "elsif" and "then" C-M-f should jump to next "elsif"/"else" like with { }
   if a == 2 then
     puts "hello"
   elsif a == 3
@@ -179,6 +180,7 @@ def test2 (arg)
     bar,
     :a
 
+# when point is after @, C-M-f should jump to the end of symbol
 zzz @abc,
     4
 
@@ -211,10 +213,16 @@ def test2 (arg)
 
 class C
   def foo
-    self.end
+    self.end # when point between 'e' and 'n', C-M-b should jump to "self"
     D.new.class
   end
 
+  class << self
+    def bar
+    end
+  end
+  # C-M-b at the end of "end" should jump to "class"
+
   def begin
   end
 end
@@ -522,6 +530,9 @@ def qux
   puts "Japanese translation: #{orig_text} => #{trans_text}"
 end
 
+# C-M-f on '[' doesn't jump to after ']'
+hash['key']
+
 # Tokenizing "**" and "|" separately.
 def resolve(**args)
   members = proc do |**args|

--=-=-=
Content-Type: text/plain


Is it possible to improve ruby-ts-mode to handle these cases?

--=-=-=--




Acknowledgement sent to Juri Linkov <juri@HIDDEN>:
New bug report received and forwarded. Copy sent to dmitry@HIDDEN, bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to dmitry@HIDDEN, bug-gnu-emacs@HIDDEN:
bug#67036; 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: Thu, 2 May 2024 06:45:02 UTC

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