From: Yuan Fu <casouri@gmail.com>
To: Perry Smith <pedz@easesoftware.com>
Cc: Stefan Monnier <monnier@iro.umontreal.ca>,
emacs-devel <emacs-devel@gnu.org>
Subject: Re: More Tree Sitter Questions / Problems.
Date: Wed, 14 Dec 2022 15:48:10 -0800 [thread overview]
Message-ID: <CD6935D0-63E2-4220-AE6B-14E72195E1C5@gmail.com> (raw)
In-Reply-To: <18305331-97C3-4118-BF7B-8EED588C50F6@easesoftware.com>
> On Dec 14, 2022, at 3:22 PM, Perry Smith <pedz@easesoftware.com> wrote:
>
>
>
>> 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.
Yes, we’ve seen the same problem in other languages, like in bug#59686.
>
> 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.
Where exactly would you insert the parenthesizes? Because if you add them around frog = 12, ie, the following:
if 12 * 18 +
45 - 19
(frog = 12)
end
then we are now indenting the (frog = 12), not frog = 12, so we are still in the same level, and using grand-parent-bol would still work. And there is no need for searching for the “if” node.
> 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.
That’ll depend on how many combinations we end up needing. If we really only need (bol (parent)) and (bol (grand-parent)), simply adding them as parent-bol and grandparent-bol is better (for code complexity, for understanding, for documentation, etc).
Yuan
next prev parent reply other threads:[~2022-12-14 23:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-14 20:43 More Tree Sitter Questions / Problems Perry Smith
2022-12-14 21:15 ` Stefan Monnier
2022-12-14 23:22 ` Perry Smith
2022-12-14 23:48 ` Yuan Fu [this message]
2022-12-14 23:53 ` Stefan Monnier
2022-12-15 6:56 ` Eli Zaretskii
2022-12-26 16:28 ` Dmitry Gutov
2022-12-15 6:05 ` Yuri Khan
2022-12-26 16:24 ` Dmitry Gutov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CD6935D0-63E2-4220-AE6B-14E72195E1C5@gmail.com \
--to=casouri@gmail.com \
--cc=emacs-devel@gnu.org \
--cc=monnier@iro.umontreal.ca \
--cc=pedz@easesoftware.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).