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

Previous Next

Package: emacs;

Reported by: Juri Linkov <juri <at> linkov.net>

Date: Fri, 10 Nov 2023 07:53:02 UTC

Severity: normal

Fixed in version 30.0.50

Done: Juri Linkov <juri <at> linkov.net>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Dmitry Gutov <dmitry <at> gutov.dev>
To: Eli Zaretskii <eliz <at> gnu.org>, Juri Linkov <juri <at> linkov.net>, Yuan Fu <casouri <at> gmail.com>
Cc: 67036 <at> debbugs.gnu.org
Subject: bug#67036: 30.0.50; treesit-forward-sexp not working properly in ruby-ts-mode
Date: Sun, 26 Nov 2023 18:12:41 +0200
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 <at> gutov.dev
>> From: Juri Linkov <juri <at> linkov.net>
>> 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.




This bug report was last modified 1 year and 71 days ago.

Previous Next


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