GNU bug report logs -
#78503
30.0.92; tree-sitter elixir-ts-mode structural movement broken
Previous Next
To reply to this bug, email your comments to 78503 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78503
; Package
emacs
.
(Tue, 20 May 2025 04:30:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Bart Otten <bart.otten85 <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Tue, 20 May 2025 04:30:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Greetings and salutions,
Trying to use elixir treesit mode, it seems the navigation of defun and lists seems broken.
1.) `defmodule` is considered a function definition and so moving up from the first
actual function definition `def my_fun do` causes the point to jump to
'defmodule my_mod do'. Invoking `end-of-defun` jumps to the end of the defmodule block.
Effectively, you have been ejected from the module body.
;; current scoped workaround
;; does not jump up to defmodule when using `beginning-of-defun`
(defun elixir-ts--defun-p (node)
"Return non-nil when NODE is a defun."
(member (treesit-node-text
(treesit-node-child-by-field-name node "target"))
(append
(remove "defmodule" elixir-ts--definition-keywords)
elixir-ts--test-definition-keywords)))
2.) When you use `down-list` while on a function definition line,
nothing happens. I tried to fix it, ony to find out that
`backward-up-list` will jump to `defmodule` when invoked while point is at a
function argument, instead of navigating out of the argument list only.
Structural movement might need some extra love.
Cheers,
Bart
Major mode: Elixir
Minor modes in effect:
electric-pair-mode: t
eglot--managed-mode: t
exunit-mode: t
mix-minor-mode: t
global-org-modern-mode: t
display-line-numbers-mode: t
global-treesit-auto-mode: t
doom-modeline-mode: t
which-key-mode: t
org-super-agenda-mode: t
undo-fu-session-global-mode: t
undo-fu-session-mode: t
apprentice-mode: t
apprentice-hooks-mode: t
flymake-mode: t
yas-minor-mode: t
treesit-inspect-mode: t
global-visual-wrap-prefix-mode: t
visual-wrap-prefix-mode: t
override-global-mode: t
tooltip-mode: t
global-eldoc-mode: t
eldoc-mode: t
show-paren-mode: t
electric-indent-mode: t
mouse-wheel-mode: t
prettify-symbols-mode: t
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78503
; Package
emacs
.
(Tue, 20 May 2025 06:56:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 78503 <at> debbugs.gnu.org (full text, mbox):
> Trying to use elixir treesit mode, it seems the navigation of defun and lists seems broken.
>
> 1.) `defmodule` is considered a function definition and so moving up from the first
> actual function definition `def my_fun do` causes the point to jump to
> 'defmodule my_mod do'. Invoking `end-of-defun` jumps to the end of the defmodule block.
> Effectively, you have been ejected from the module body.
>
> ;; current scoped workaround
> ;; does not jump up to defmodule when using `beginning-of-defun`
> (defun elixir-ts--defun-p (node)
> "Return non-nil when NODE is a defun."
> (member (treesit-node-text
> (treesit-node-child-by-field-name node "target"))
> (append
> (remove "defmodule" elixir-ts--definition-keywords)
> elixir-ts--test-definition-keywords)))
This behavior may look logically flawed,
but still it makes sense for user convenience:
while navigating with 'C-M-a' it's handy
to use the same key to move over modules too.
The same navigation exists in other ts-modes as well:
for example, in java-ts-mode 'C-M-a' moves over classes, etc.
OTOH, in ruby-ts-mode it's restricted to methods only.
> 2.) When you use `down-list` while on a function definition line,
> nothing happens. I tried to fix it, ony to find out that
> `backward-up-list` will jump to `defmodule` when invoked while point is at a
> function argument, instead of navigating out of the argument list only.
>
> Structural movement might need some extra love.
This part is not reproducible. Do you use the latest master?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78503
; Package
emacs
.
(Tue, 20 May 2025 12:08:01 GMT)
Full text and
rfc822 format available.
Message #11 received at 78503 <at> debbugs.gnu.org (full text, mbox):
> From: Bart Otten <bart.otten85 <at> gmail.com>
> Date: Tue, 20 May 2025 00:10:54 +0200
>
> Greetings and salutions,
>
> Trying to use elixir treesit mode, it seems the navigation of defun and lists seems broken.
>
> 1.) `defmodule` is considered a function definition and so moving up from the first
> actual function definition `def my_fun do` causes the point to jump to
> 'defmodule my_mod do'. Invoking `end-of-defun` jumps to the end of the defmodule block.
> Effectively, you have been ejected from the module body.
>
> ;; current scoped workaround
> ;; does not jump up to defmodule when using `beginning-of-defun`
> (defun elixir-ts--defun-p (node)
> "Return non-nil when NODE is a defun."
> (member (treesit-node-text
> (treesit-node-child-by-field-name node "target"))
> (append
> (remove "defmodule" elixir-ts--definition-keywords)
> elixir-ts--test-definition-keywords)))
>
>
> 2.) When you use `down-list` while on a function definition line,
> nothing happens. I tried to fix it, ony to find out that
> `backward-up-list` will jump to `defmodule` when invoked while point is at a
> function argument, instead of navigating out of the argument list only.
>
> Structural movement might need some extra love.
Thanks.
Wilhelm and Juri, any comments?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78503
; Package
emacs
.
(Tue, 20 May 2025 16:49:01 GMT)
Full text and
rfc822 format available.
Message #14 received at 78503 <at> debbugs.gnu.org (full text, mbox):
>>> 1.) `defmodule` is considered a function definition and so moving up from the first
>>> actual function definition `def my_fun do` causes the point to jump to
>>> 'defmodule my_mod do'. Invoking `end-of-defun` jumps to the end of the defmodule block.
>>> Effectively, you have been ejected from the module body.
>>>
>>
>> This behavior may look logically flawed,
>> but still it makes sense for user convenience:
>> while navigating with 'C-M-a' it's handy
>> to use the same key to move over modules too.
>
> This would be convenient if list-down would make you jump into the
> module body, ready for a jump to the next defun. But currently it does
> not.
This is exactly what 'down-list' does after removing
'treesit-cycle-sexp-type' from 'elixir-ts-mode'. (You can use
the command 'M-x treesit-cycle-sexp-type RET' to toggle interactively.)
So 'C-M-f' navigation should use the 'sexp' thing
while 'C-M-d' should use 'list' thing.
Then let's add a new variable like 'treesit-sexp-type-regexp'
e.g. named 'treesit-down-list-regexp' (maybe without a command
to toggle it).
> Also Elixir files usually have only one module, so the optimalization
> to move to other modules might have more downsides than advantages.
Agreed.
>>> 2.) When you use `down-list` while on a function definition line,
>>> nothing happens. I tried to fix it, ony to find out that
>>> `backward-up-list` will jump to `defmodule` when invoked while point is at a
>>> function argument, instead of navigating out of the argument list only.
>>>
>>> Structural movement might need some extra love.
>>
>> This part is not reproducible. Do you use the latest master?
>
> Now I do. The issue does not replicate in the same way, but still the
> behavior is unextected to me and less convienient than hoped for.
>
> ```
> def foo(arg) do
> IO.inspect("some")
> end
> ```
>
> Expected:
> - into args
> - nice to have: into do block (after do)
> - into argument list
> - into quoted string
This is exactly how 'C-M-d' already works when you toggle
'M-x treesit-cycle-sexp-type RET'.
> Actual:
> - after def
> - after closing paren
> - after do
> - onto opening paren
> - into argument list
> - into quoted string
>
> ```
> defmodule Foo do
> def my_fun(), do: :bar
> end
> ```
>
> Expected:
> - into module body (after do)
This is what 'C-M-d' already does after 'M-x treesit-cycle-sexp-type RET'.
So let's enable 'treesit-cycle-sexp-type' by default, but only for 'down-list'.
> Actual:
> - after defmodule
> - after Foo
> - into module body (after do)
Ok, I will create a new variable 'treesit-down-list-regexp' for 'down-list'.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78503
; Package
emacs
.
(Wed, 21 May 2025 06:35:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 78503 <at> debbugs.gnu.org (full text, mbox):
>>> 1.) `defmodule` is considered a function definition and so moving up from the first
>>> actual function definition `def my_fun do` causes the point to jump to
>>> 'defmodule my_mod do'. Invoking `end-of-defun` jumps to the end of the defmodule block.
>>
>> Also Elixir files usually have only one module, so the optimalization
>> to move to other modules might have more downsides than advantages.
Let's wait when Wilhelm will confirm this change.
>>>> 2.) When you use `down-list` while on a function definition line,
>>>> nothing happens. I tried to fix it, ony to find out that
>>>> `backward-up-list` will jump to `defmodule` when invoked while point is at a
>>>> function argument, instead of navigating out of the argument list only.
>
> Ok, I will create a new variable 'treesit-down-list-regexp' for 'down-list'.
A new variable is added now, so this part is fixed.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78503
; Package
emacs
.
(Thu, 22 May 2025 06:47:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 78503 <at> debbugs.gnu.org (full text, mbox):
>>> ```
>>> def foo(arg) do
>>> IO.inspect("some")
>>> end
>>> ```
>>>
>>> Expected:
>>> - into args
>>> - nice to have: into do block (after do)
>>> - into argument list
>>> - into quoted string
>>
>> This is exactly how 'C-M-d' already works when you toggle
>> 'M-x treesit-cycle-sexp-type RET'.
>
> It does jump to into args (inside the parens), but after that it does nothing but show a
> message indicating it is at the bottom level. Which afaik it is not.
>
> To be clear:
> - on a of arg
> - nice to have: into do block (after do)
> - on " of "some"
> - nice to have: on s of "some"
'down-list' can't go out of a position inside "(arg)"
because it is at the bottom level of parenthesis.
This is what 'up-list' intended to do. So you need
to type 'M-)' or anything that is bound to 'up-list'.
>> This is what 'C-M-d' already does after 'M-x treesit-cycle-sexp-type RET'.
>
> Confirmed
>
>> So let's enable 'treesit-cycle-sexp-type' by default, but only for
>> 'down-list'.
>
> Would be great.
Thanks, done.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78503
; Package
emacs
.
(Fri, 23 May 2025 12:51:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 78503 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Thu, May 22, 2025 at 8:46 AM Juri Linkov <juri <at> linkov.net> wrote:
> >>> ```
> >>> def foo(arg) do
> >>> IO.inspect("some")
> >>> end
> >>> ```
> >>>
> >>> Expected:
> >>> - into args
> >>> - nice to have: into do block (after do)
> >>> - into argument list
> >>> - into quoted string
> >>
> >> This is exactly how 'C-M-d' already works when you toggle
> >> 'M-x treesit-cycle-sexp-type RET'.
> >
> > It does jump to into args (inside the parens), but after that it does
> nothing but show a
> > message indicating it is at the bottom level. Which afaik it is not.
> >
> > To be clear:
> > - on a of arg
> > - nice to have: into do block (after do)
> > - on " of "some"
> > - nice to have: on s of "some"
>
> 'down-list' can't go out of a position inside "(arg)"
> because it is at the bottom level of parenthesis.
> This is what 'up-list' intended to do. So you need
> to type 'M-)' or anything that is bound to 'up-list'.
>
> >> This is what 'C-M-d' already does after 'M-x treesit-cycle-sexp-type
> RET'.
> >
> > Confirmed
> >
> >> So let's enable 'treesit-cycle-sexp-type' by default, but only for
> >> 'down-list'.
> >
> > Would be great.
>
> Thanks, done.
>
Hi, sorry for the delay.
I had a look at the latest changes and it makes sense to me. Thanks again
Juri :).
Kind regards,
Wilhelm
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78503
; Package
emacs
.
(Fri, 23 May 2025 18:29:02 GMT)
Full text and
rfc822 format available.
Message #26 received at 78503 <at> debbugs.gnu.org (full text, mbox):
> Hi, sorry for the delay.
>
> I had a look at the latest changes and it makes sense to me. Thanks again
> Juri :).
This was only the second part. But what do you think about the
first part about removing `defmodule` from 'C-M-a' defun navigation:
1.) `defmodule` is considered a function definition and so moving up from the first
actual function definition `def my_fun do` causes the point to jump to
'defmodule my_mod do'. Invoking `end-of-defun` jumps to the end of the defmodule block.
Effectively, you have been ejected from the module body.
;; current scoped workaround
;; does not jump up to defmodule when using `beginning-of-defun`
(defun elixir-ts--defun-p (node)
"Return non-nil when NODE is a defun."
(member (treesit-node-text
(treesit-node-child-by-field-name node "target"))
(append
(remove "defmodule" elixir-ts--definition-keywords)
elixir-ts--test-definition-keywords)))
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78503
; Package
emacs
.
(Mon, 26 May 2025 06:53:01 GMT)
Full text and
rfc822 format available.
Message #29 received at 78503 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
On Fri, May 23, 2025 at 8:28 PM Juri Linkov <juri <at> linkov.net> wrote:
> > Hi, sorry for the delay.
> >
> > I had a look at the latest changes and it makes sense to me. Thanks again
> > Juri :).
>
> This was only the second part. But what do you think about the
> first part about removing `defmodule` from 'C-M-a' defun navigation:
>
> 1.) `defmodule` is considered a function definition and so moving up
> from the first
> actual function definition `def my_fun do` causes the point to jump to
> 'defmodule my_mod do'. Invoking `end-of-defun` jumps to the end of the
> defmodule block.
> Effectively, you have been ejected from the module body.
>
> ;; current scoped workaround
> ;; does not jump up to defmodule when using `beginning-of-defun`
> (defun elixir-ts--defun-p (node)
> "Return non-nil when NODE is a defun."
> (member (treesit-node-text
> (treesit-node-child-by-field-name node "target"))
> (append
> (remove "defmodule" elixir-ts--definition-keywords)
> elixir-ts--test-definition-keywords)))
>
It is not ideal to be ejected from the module body and was not the initial
desired behaviour. modules can be nested and there can be multiple in a
single file, so not being able to navigate with C-M-a is less ideal imo. I
remember trying to solve this issue in the early days of treesit.el, but it
became too complex, perhaps there is an easier way now?
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78503
; Package
emacs
.
(Tue, 27 May 2025 06:56:02 GMT)
Full text and
rfc822 format available.
Message #32 received at 78503 <at> debbugs.gnu.org (full text, mbox):
> 1.) `defmodule` is considered a function definition and so moving up
> from the first
> actual function definition `def my_fun do` causes the point to jump to
> 'defmodule my_mod do'. Invoking `end-of-defun` jumps to the end of
> the defmodule block.
> Effectively, you have been ejected from the module body.
>
> ;; current scoped workaround
> ;; does not jump up to defmodule when using `beginning-of-defun`
> (defun elixir-ts--defun-p (node)
> "Return non-nil when NODE is a defun."
> (member (treesit-node-text
> (treesit-node-child-by-field-name node "target"))
> (append
> (remove "defmodule" elixir-ts--definition-keywords)
> elixir-ts--test-definition-keywords)))
>
> It is not ideal to be ejected from the module body and was not the initial
> desired behaviour. modules can be nested and there can be multiple in a
> single file, so not being able to navigate with C-M-a is less ideal imo. I
> remember trying to solve this issue in the early days of treesit.el, but it
> became too complex, perhaps there is an easier way now?
An easier way is proposed above with (remove "defmodule" elixir-ts--definition-keywords).
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#78503
; Package
emacs
.
(Sun, 08 Jun 2025 07:21:01 GMT)
Full text and
rfc822 format available.
Message #35 received at 78503 <at> debbugs.gnu.org (full text, mbox):
> 1.) `defmodule` is considered a function definition and so moving up from the first
> actual function definition `def my_fun do` causes the point to jump to
> 'defmodule my_mod do'. Invoking `end-of-defun` jumps to the end of the defmodule block.
> Effectively, you have been ejected from the module body.
Hopefully defun navigation will be fixed in bug#68664 and bug#78703.
This bug report was last modified 11 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.