emacs-devel
[Top][All Lists]
Advanced

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

Re: Tree-sitter api


From: Yuan Fu
Subject: Re: Tree-sitter api
Date: Thu, 26 Aug 2021 22:45:06 -0700

> On Aug 24, 2021, at 5:21 PM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
> 
>> Okay, here is the (ad-hoc) infrastructure I came up with:
> 
> It's more than what I proposed, but it looks fairly good.
> See patch below which is the "side effect" of reading your code.
> 
> You'll see that I removed the "-function" from the function name (this
> suffix is used for variables holding functions rather than for the
> function themselves) and I split that function into two, the outer one
> (tree-sitter-indent) implementing basically what I suggested and the
> inner one (tree-sitter-simple-indent) implementing the extra structure
> you added to it, mediated by a new var `tree-sitter-indent-function`
> which modes can set if they want to use another algorithm than the one
> you implemented in `tree-sitter-simple-indent`.
> 
> The reason why I divided it this way is that my experience with
> indentation code is that it can be useful occasionally to call
> recursively the indentation code to know where a node *would* be
> indented.  This comes in handy when you want to be able to provide
> indentation styles like:
> 
>    let myvariable = if (foo) {
>            bar
>          } else {
>            baz
>          }
> 
> where the body of the `if` branches needs to be indented relative to the
> position where the `if` itself would be indented if it were on its own line.

Thanks, Stefan :-) I applied your patch and fixed the two FIXME’s.

Yuan


reply via email to

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