bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#60894: 30.0.50; [PATCH] Add treesit-forward-sexp


From: Theodor Thornhill
Subject: bug#60894: 30.0.50; [PATCH] Add treesit-forward-sexp
Date: Thu, 19 Jan 2023 20:03:11 +0100

Dmitry Gutov <dgutov@yandex.ru> writes:

> On 19/01/2023 05:58, Stefan Monnier via Bug reports for GNU Emacs, the 
> Swiss army knife of text editors wrote:
>>>> I think `C-M-u` from within a LaTeX environment was one of the cases
>>>> where it misbehaved (tho that one is not using SMIE).
>>> Any chance SMIE is doing something different, or something
>>> particularly correct?
>> 
>> Could be.  Maybe its simplistic approach rules out the bad cases?
>
> Simplistic meaning one that uses a list of openers and closers?
>
>>>>> Do you mean a hook like backward-up-list-function, or something smaller?
>>>> Something like that.  Maybe it could also be used for `expand-region`
>>>> and `thing-at-point` kind of purposes maybe and could work even for
>>>> treesit nodes that aren't "matching begin..end thingies".
>>> A treesit node doesn't need an explicit "end" token, though.
>> 
>> And that's what I want: I want to use successive `C-M-u` (or
>> `expand-region`) to consider ever greater subexpressions that include
>> the position from which I started and to do that at a fine grain.
>> E.g. if I start with point on `b` in:
>> 
>>         a + b * c
>> 
>> I'd like to first consider "b" then "b * c" then the whole thing.
>
> That should be easy enough to do using the provided tree-sitter 
> framework, just by adding binary nodes to the list of types.
>
> Whether this behavior is preferable is a matter of opinion, though. My 
> guess is Ruby users will find it too fiddly, and the end result is that 
> one will have to press 'C-M-u' more times to get to the same result 
> (which would usually be to get to the beginning of a block, or a 
> method). But people can customize it.

So I pushed the changes I've made so far, after addressing Elis
comments.  Let's try it for a while and see how we feel about it going
forward.


Theo





reply via email to

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