bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#76788: treesit-thing-settings for elixir-ts-mode


From: Juri Linkov
Subject: bug#76788: treesit-thing-settings for elixir-ts-mode
Date: Wed, 16 Apr 2025 20:33:01 +0300
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/31.0.50 (x86_64-pc-linux-gnu)

>>>> Previously C-M-f jumped from "def" to "end":
>>>
>>> Yes, this is desired. The expression starts with "def" and the do -> end is
>>> just an argument to the "def" macro.  
>>>
>>>       def fun(a) do
>>>       end
>>>
>>>     The change is to jump only from "do" to "end" like in other ts-modes.
>>>
>>> Why is this better?
>>
>> Because otherwise there is no easy way to navigate to the function name
>> and its arguments.  There were many complaints that unlike smie-based sexp
>> now tree-sitter jumps too far directly to the end of functions.
>> So sadly an idealistic promise of tree-sitter doesn't fit perfectly
>> into the real world.
>
> In Elixir 
>
>    def foo(bar), do: bar 
>
> is pretty much the same as 
>
> (defun foo (bar) bar)
>
> So I think the original implementation is more natural to Emacs users, and
> yes there is one slight downside, but at the cost of a multitude of
> improvements for navigation. The majority of users I got feedback from
> prefer how the new forward-sexp works. The smie-based sexp hardly worked in
> any expected way as well.

Emacs users also use many other ts-modes and complained that
forward-sexp relies too much on tree-sitter to jump too far.
For example, in c-ts-mode forward-sexp jumped to the function end
like 'end-of-defun' does:

  void foo (void *bar) {
    bar()
  }

> Look at how ruby-mode works with navigation ( I have not tried
> ruby-ts-mode ), as it also properly treats def end blocks as sexps.

Ruby is different since its function body is not enclosed
within delimiters such as "do...end" in Elixir.

>>> The one huge advantage that elixir-ts-mode brought to
>>> the table was to navigate between functions, the existing elixir-mode could
>>> not get this right. 
>>
>> The new command 'treesit-cycle-sexp-type' keeps this advantage
>> while allowing the users to toggle the traditional behavior
>> where C-M-f moves over the arguments.
>
> How do I enable this? Is this a new setting?

Ok, since you prefer treesit-based navigation by default, now I enabled
'treesit-cycle-sexp-type' by default in 'elixir-ts-mode'.

> Will it make the navigation work as before?

Yes, now by default the navigation works as before.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]