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: Stefan Monnier
Subject: Re: Code navigation for sh-mode with Tree-sitter
Date: Tue, 06 Dec 2022 11:48:32 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

>> Calling beginning-of-defun-function followed by end-of-defun-function
>> (and comparing the resulting position to the start position) should be
>> sufficient to let you know whether or not you're inside the function
>> whose definition starts most closely before point.
>>
>
> Hmm. In sh-mode `beginning-of-defun-function' is nil and in the example
> below, calling `end-of-defun-function' with M-: (funcall
> end-of-defun-function) brings point to fi and not the end of the function.

Many major modes do not implement those two functions in a fully
reliable way, indeed.

`bash-ts-mode` should be able to implement them reliably, OTOH.

> In the example above, C-M-a and C-M-e do the right thing. However, in the
> presence of nested functions, C-M-a and C-M-e only navigate over top-level
> functions.  For example:

Yes, it's a common limitation when the major mode is unable to do
proper parsing of the code.


        Stefan




reply via email to

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