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

From: Wilhelm Kirschbaum <[email-masked]>
Date: Tue, 15 Apr 2025 09:00:52 +0200

On Mon, Apr 14, 2025 at 7:08 PM Juri Linkov <[email-masked]> wrote:

> > I just tested the latest changes and the forward-sexp is not working
> > correctly. I will look at the changes when I have a minute.
>
> 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? 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.
Before the changes it is possible to navigate or kill the next x functions,
now it is unpredictable. The Elixir grammar is a bit more complicated than
most other languages unfortunately.

>
> To keep jumping from "def" to "end" a possible change is to add
>
>   (or (and "\\`call\\'" ,#'elixir-ts--defun-p)
>
> to the 'list' thing in 'treesit-thing-settings'.
>

It's not just for the "def" to "end" this change breaks forward-sexp for
function calls, case blocks etc...

>
> But there is a new command 'treesit-cycle-sexp-type'
> that switches from jumping "do"->"end" to "def"->"end".
>

I don't see any scenario where this will be useful to navigate Elixir code.

Apologies, I see I replied to you directly and not to the thread.  Added
the thread again.