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: Wed, 14 Dec 2022 16:34:48 -0500
User-agent: Gnus/5.13 (Gnus v5.13)

> Great.  It seems there has been almost no development, nor documentation
> done in this area for a long time.  Should I try to improve on this part
> of the code while I'm at it?

That would be welcome, yes.

> Yeah, that's what I'm thinking too.  I'm just thinking we should be
> clear on what a word/sexp/sentence/paragraph/defun etc is in non-lisp
> and non-human languages.

In the context of SMIE I came up with a usable meaning for sexp (which
I've been trying to explain in this thread), but for sentence and
paragraph it seems harder and is likely to depend on the specifics of
the language (e.g. for some languages "sentence" might be mapped to
"instruction" or maybe "instruction that doesn't itself contain nested
instructions", but some languages don't have a notion of instruction).

>>> Now I'm having issues where movement over sexps ends up not in the
>>> same place.
>> Same place as?
> IIRC there's no guarantee that the movement sequence used for
> transpose-sexp moves over the same blocks of code, so in non-lisp
> languages there's no real semantic to go from.

I guess in general it can be difficult to be consistent, indeed.
In SMIE I preserve the following (or at least I try to):

    <FOO> infix <BAR>
    ^   ^       ^   ^
    AB  AE      BB  BE

if `transpose-sexp` swaps FOO and BAR, then `forward-sexp` from AE goes
to BE and `backward-sexp` from BB goes to AB.  But when you start to
consider mixfix syntax it can become much less clear what needs to
be done.  I don't think we should worry too much if `transpose-sexp` and
`forward/backward-sexp` don't align 100% is all cases: we should strive
to keep them consistent, but it's OK to break down in corner cases.


        Stefan




reply via email to

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