emacs-devel
[Top][All Lists]
Advanced

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

Re: More Tree Sitter Questions / Problems.


From: Perry Smith
Subject: Re: More Tree Sitter Questions / Problems.
Date: Wed, 14 Dec 2022 17:22:44 -0600



On Dec 14, 2022, at 15:15, Stefan Monnier <monnier@iro.umontreal.ca> wrote:

foodog = 12 + 4 *
   18 * 99 + 8

[ Trying to provide some SMIE perspective:  ]

In the context of sh-mode, I've had requests to provide that kind of
"AST-oblivious" indentation.  The result is controlled by
`sh-indent-after-continuation`.

variable = 12 + 4 *
               18 * 99 + 8

That's my favorite, yes.

You might be misunderstanding my concern (but I do appreciate all of your examples and thoughts).

My concern is if Tree Sitter modes deviate too much from the old way, they may not catch on.  Perhaps I should not worry about that.  The old modes are not going anywhere so people can keep which ever they prefer.  But, that is where my worry is coming from.

On a slightly different topic but only slightly, I discovered that my first draft also does this:

if 12 * 18 +
   45 - 19
     frog = 12
end

Rather than this:

if 12 * 18 +
   45 - 19
  frog = 12
end

I can change the code but I mention it because I bet others will be making the same mistake.

“frog” (in the first example) is indented to the bol of parent.  The parent is “then” (not if) and the “then” is on the 2nd line, not the first.  So instead of indenting two spaces from the bol of the “if", it is indented two spaces from the bol of the “then” which is the 45.

All this to say that now that I”m getting deeper into this, I plan to rethink things.  “Parent”, “grand parent”, “first-sibling”, etc are likely not going to be good for anchor points because simply adding paren’s makes a node on level deeper.  I think what will be better in the case of the “if” will be to be anchor to closest “if”.

I’m also coming to the conclusion that “parent-bol” would be better if it was (bol (parent)) so that (bol (grand-parent)) and (bol (ancestor “if”)), etc could be easily done.

These are mostly “thinking out loud” type comments.  I plan on piddling with things more.

Perry


Attachment: signature.asc
Description: Message signed with OpenPGP


reply via email to

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