[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Code navigation for sh-mode with Tree-sitter
From: |
Yuan Fu |
Subject: |
Re: Code navigation for sh-mode with Tree-sitter |
Date: |
Tue, 6 Dec 2022 13:04:19 -0800 |
> On Dec 6, 2022, at 8:48 AM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>
>>> 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.
It seems there are not convention on whether defun movements should move across
top-level defun’s or both top-level and nested ones. I’ve seen bug report on
python-ts-mode complaining about both sides.
Should we make it configurable, then? A variable that makes tree-sitter defun
navigation switch between two modes: top-level only and not top-level only.
Yuan
- Code navigation for sh-mode with Tree-sitter, João Paulo Labegalini de Carvalho, 2022/12/03
- Re: Code navigation for sh-mode with Tree-sitter, Alan Mackenzie, 2022/12/03
- Re: Code navigation for sh-mode with Tree-sitter, João Paulo Labegalini de Carvalho, 2022/12/05
- Re: Code navigation for sh-mode with Tree-sitter, João Paulo Labegalini de Carvalho, 2022/12/06
- Re: Code navigation for sh-mode with Tree-sitter, Stefan Monnier, 2022/12/06
- Re: Code navigation for sh-mode with Tree-sitter,
Yuan Fu <=
- Re: Code navigation for sh-mode with Tree-sitter, Yuan Fu, 2022/12/06
- Re: Code navigation for sh-mode with Tree-sitter, Alan Mackenzie, 2022/12/06
- Re: Code navigation for sh-mode with Tree-sitter, João Paulo Labegalini de Carvalho, 2022/12/06
- Re: Code navigation for sh-mode with Tree-sitter, João Paulo Labegalini de Carvalho, 2022/12/06
- Re: Code navigation for sh-mode with Tree-sitter, Stefan Monnier, 2022/12/06
- Re: Code navigation for sh-mode with Tree-sitter, João Paulo Labegalini de Carvalho, 2022/12/06
- Re: Code navigation for sh-mode with Tree-sitter, Stefan Monnier, 2022/12/06
- Re: Code navigation for sh-mode with Tree-sitter, João Paulo Labegalini de Carvalho, 2022/12/06
- Re: Code navigation for sh-mode with Tree-sitter, Stefan Monnier, 2022/12/06
- Re: Code navigation for sh-mode with Tree-sitter, João Paulo Labegalini de Carvalho, 2022/12/06