[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 16:41:01 -0800 |
>
>>> 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.
>
> In CC Mode, it has been configurable via the user option c-defun-tactic
> for somewhere between ten and fifteen years. When c-defun-tactic is t,
> C-M-a/e go to the start/end of the top level defuns. When it is the
> symbol go-outward, C-M-a/e move to the next start/end of defun, if any,
> at the current level of class/namespace nesting, and move outwards to
> the next level of class/namespace nesting when a class/namespace boundary
> is reached.
>
> I don't remember any complaints about this mechanism.
Ah, very good. I’ll try to make tree-sitter to do the same.
>
>> And for functions nested in a class: if you type C-M-e at the beginning
>> of a class, should it go to the end of the first function in that
>> class, or should it go to the end of the class? Right now because of
>> how end-of-defun works, it will jump to the end of the class if point
>> is at the beginning of the class (1), and jump to the first function if
>> point is before the beginning of the class (2).
>
> This doesn't seem sensible.
I agree.
>> (2)
>> (1)class class1():
>> prop = 0
>> def method1(self):
>> pass
>
>> def method2(self):
>> pass
How would cc-mode’s C-M-e move in position (2) under the go-outward tactic?
Would it go to the end of method1, or the end of class1? From your description
it seems that it will move to the end of class1. Is there anyway to configure
it to move to the end of method1 in this case?
Yuan
- Re: New defun navigation for tree-sitter (Was: Code navigation for sh-mode with Tree-sitter), (continued)
- Re: New defun navigation for tree-sitter (Was: Code navigation for sh-mode with Tree-sitter), Yuan Fu, 2022/12/13
- Re: New defun navigation for tree-sitter (Was: Code navigation for sh-mode with Tree-sitter), João Paulo Labegalini de Carvalho, 2022/12/13
- Re: New defun navigation for tree-sitter (Was: Code navigation for sh-mode with Tree-sitter), Yuan Fu, 2022/12/13
- Re: New defun navigation for tree-sitter (Was: Code navigation for sh-mode with Tree-sitter), João Paulo Labegalini de Carvalho, 2022/12/13
- Re: New defun navigation for tree-sitter (Was: Code navigation for sh-mode with Tree-sitter), Yuan Fu, 2022/12/15
- Re: New defun navigation for tree-sitter (Was: Code navigation for sh-mode with Tree-sitter), João Paulo Labegalini de Carvalho, 2022/12/16
- Re: New defun navigation for tree-sitter (Was: Code navigation for sh-mode with Tree-sitter), Yuan Fu, 2022/12/17
- Re: Code navigation for sh-mode with Tree-sitter,
Yuan Fu <=