[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Plug treesit.el into other emacs constructs
From: |
Theodor Thornhill |
Subject: |
Re: Plug treesit.el into other emacs constructs |
Date: |
Wed, 14 Dec 2022 09:42:09 +0100 |
Yuan Fu <casouri@gmail.com> writes:
>> On Dec 13, 2022, at 3:19 PM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
[...]
>>
>>> Just a thought, but maybe we can let major modes define what’s an “abstract
>>> list”, and sexp-forward would move across the immediate children of abstract
>>> lists. Eg, abstract lists in C would contain block, argument list,
>>> statement, etc. And in the example above forward-sexp would move across
>>> X.y(z) because it’s an immediate children of the enclosing abstract list,
>>> the argument list.
>>
>> Using the semantics I advocate, the user needs to place his point just
>> to the left of `;` in order for `forward-sexp` to jump over the next
>> instruction (or to the right of the `;` in order to jump over the
>> previous instruction with `backward-sexp`).
>
> You mean in the following code
>
> int a = 0[1];
> int b = 1;[2]
>
> Forward-sexp would move [1] to [2]? But if we move over the smallest
> subtree, I’d imagine it only move across the semicolon after [1]. Even
> if it moves from [1] to [2], needing to adjust point feels very
> inconvenient to me, at least I wouldn’t want to use something like
> that. I want to type a single binding and move to where I want, and
> type that binding multiple times to move multiple steps. Both doesn’t
> seem to be possible with what you described.
>
Yeah. My intuition for forward-sexp was always "some construct bigger
than a 'word'". But in tree-sitter we also get the opportunity to make
code stay valid. For example:
void foo(String bar, int baz) | {}
In this case it wouldn't make sense for transpose-sexps to do the
following:
void foo {} | (String bar, int baz)
Because that wouldn't be valid java. But swapping the params inside
would make sense, but only when the whole node is pulled over.
And it point is directly between the paren opener and 'String',
forward-sexp would make sense to jump to the comma, because forward-word
would do the smaller movement.
Theo
- Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/12
- Re: Plug treesit.el into other emacs constructs, Eli Zaretskii, 2022/12/12
- Re: Plug treesit.el into other emacs constructs, Stefan Monnier, 2022/12/12
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/13
- Re: Plug treesit.el into other emacs constructs, Stefan Monnier, 2022/12/13
- Re: Plug treesit.el into other emacs constructs, Yuan Fu, 2022/12/13
- Re: Plug treesit.el into other emacs constructs, Perry Smith, 2022/12/13
- Re: Plug treesit.el into other emacs constructs, Stefan Monnier, 2022/12/13
- Re: Plug treesit.el into other emacs constructs, Yuan Fu, 2022/12/14
- Re: Plug treesit.el into other emacs constructs,
Theodor Thornhill <=
- Re: Plug treesit.el into other emacs constructs, Stefan Monnier, 2022/12/14
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/14
- Re: Plug treesit.el into other emacs constructs, Stefan Monnier, 2022/12/14
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/14
- Re: Plug treesit.el into other emacs constructs, Stefan Monnier, 2022/12/14
- Re: Plug treesit.el into other emacs constructs, Stefan Monnier, 2022/12/14
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/14
- Re: Plug treesit.el into other emacs constructs, Stefan Monnier, 2022/12/14
- Re: Plug treesit.el into other emacs constructs, Theodor Thornhill, 2022/12/14
- Re: Plug treesit.el into other emacs constructs, Stefan Monnier, 2022/12/14