emacs-devel
[Top][All Lists]
Advanced

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

Re: Are variations such as these desired?


From: Stefan Monnier
Subject: Re: Are variations such as these desired?
Date: Tue, 13 Dec 2022 10:18:29 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

> So, your idea is like “align" except instead of using regular expressions, it
> would use Tree Sitter queries — or similar such concepts.

That's the idea, yes.

You could use the approach in your code: take point as a specification of
"the node to align", and then look at the children of that node and
their children's children, ...

For each level, check if all the children appear on a different line: if
they're all on the same line, we're too low in the tree and we should
stop recursing (if some are on the same line but not all, you get to
decide whether you want to try and align or not).

Otherwise, align them all together.  There might need to be some
heuristic (or major-mode-provided info) in this part so we do:

    x   = 5;
    yup = 42;

instead of

    x   = 5 ;
    yup = 42;

or

    x =   5 ;
    yup = 42;

For SMIE, we don't have "nodes", so I was thinking of having the user
specify a region of interest and look for tokens with the same
precedence placed on different lines.


        Stefan




reply via email to

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