emacs-devel
[Top][All Lists]
Advanced

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

Re: Plug treesit.el into other emacs constructs


From: Stefan Monnier
Subject: Re: Plug treesit.el into other emacs constructs
Date: Mon, 12 Dec 2022 10:46:17 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

Cool, thanks, a few comments (based on my experience with adding
similar things based on `smie`):

> ** Forward-sexp:
> Executing C-M-f repeatedly will go from:
> ```
> public void foo(|String bar, String baz) {}
> ```
> to
> ```
> public void foo(String bar|, String baz) {}
> ```

That looks wrong.  `String` is a valid AST node.  Whether it gets a node
in tree-sitter or not, I don't know, but here there are several "sexps"
that start at point and I think `forward-sexp` should be conservative
and keep advancing by the smallest option.

There can be many more than 2 choices, of course, e.g.:

    x = |f (x) * 3 + 2;

Here "f" is the smallest sexp after point, "f (x)" is the next one up,
then "f (x) * 3" and finally "f (x) * 3 + 2".

> ```
> public void foo(String bar, String baz|) {}
> ```

That one's right :-)

> ** transpose-sexp:
> Executing C-M-t repeatedly will go from:
> ```
> public void foo(int bar,| String baz) {}
> ```
> to
> ```
> public void foo(String baz, int bar|) {}
> ```

And this one it right as well (regardless if | starts after or before the 
comma).

Does it work as well for infix keywords that are made of normal letters,
like say `else` (or the `and` and `or` used in some languages instead
of `&&` and `||`)?


        Stefan




reply via email to

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