emacs-devel
[Top][All Lists]
Advanced

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

Re: Code navigation for sh-mode with Tree-sitter


From: João Paulo Labegalini de Carvalho
Subject: Re: Code navigation for sh-mode with Tree-sitter
Date: Tue, 6 Dec 2022 16:43:39 -0700



On Tue, Dec 6, 2022 at 3:57 PM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
Ah, I think I get it.  You mean your set the `[EB]OD-function` variables
to your two functions/commands, right?

Exactly. 
 
To figure out whether the problem is inside `end-of-defun` or in the
way `[EB]OD-function` are expected to behave, you'll have to single-step
through `end-of-defun`, I think.

It seems that the problem originates from the function which `EOD-function' is set to be called after via the `BOD-raw'. With a positive argument all is good, since the navigation functions for bash-ts-mode have symmetric behavior -- both bring point to beginning/end of the closest function that encloses point.

However, with negative arguments that does not happen, as `sh-mode--treesit-beginning-of-defun' moves point to (beginning of) the closest sibling function (after point) and `sh-mode--treesit-end-of-defun' moves point to (end of) the closest sibling function (before point). In this case, the selected functions to which point move to are not the same.

A second look revealed that the function set to `end-of-defun-function' is called without arguments, thus when used can only produce motions that are symmetric to `beginning-of-defun-function'.

Since that is not the case for the functions I am proposing for bash-ts-mode, I believe that binding them as commands to C-M-a/e is the only option. Unless I am missing something.

--
João Paulo L. de Carvalho
Ph.D Computer Science |  IC-UNICAMP | Campinas , SP - Brazil
Postdoctoral Research Fellow | University of Alberta | Edmonton, AB - Canada
joao.carvalho@ic.unicamp.br
joao.carvalho@ualberta.ca

reply via email to

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