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: Yuan Fu
Subject: Re: Plug treesit.el into other emacs constructs
Date: Wed, 14 Dec 2022 16:05:10 -0800


> On Dec 14, 2022, at 3:31 PM, Yuan Fu <casouri@gmail.com> wrote:
> 
> 
> 
>> On Dec 14, 2022, at 6:01 AM, Stefan Monnier <monnier@iro.umontreal.ca> wrote:
>> 
>>> I would argue that the purpose of forward-sexp is to move over items in
>>> a list.
>> 
>> There are different ways to look at it.  In the Lisp context where it
>> emerged, we only have "identifiers" and "parenthesized thingies", so
>> that doesn't give much guidance about what to do in-between.
> 
> I see, so maybe sexp means the general, flexible AST entity. And thinking of 
> it, my idea is just forward-list :-) And we definitely should include 
> forward-list into the list of navigation commands we want to support, among 
> the ones that are already brought up.

Ok, upon closer inspection, forward-list isn’t exactly what I’m thinking about, 
it moves over lists, but I’m thinking about moving over elements of a list.

If you think about it, there are two kinds of constructs in an AST/grammar: 
those are repeatable, and those are not. Statements are repeatable, you can 
stack multiple ones together and it still makes sense. Identifiers are not 
repeatable, put two together doesn’t make sense (in most languages).

And these repeatable constructs appears at every level of the AST, from 
top-level stuff like function definition, to statements, to small stuff like 
arguments in an argument list. That makes them very good unit of navigation.

Navigation commands, IMO, needs to be extremely easy to predict and requires no 
thinking. That’s the reason why avy never grow on me: yes you can move to 
anywhere you want, but it takes so much cognitive load to use. Much better to 
type a few C-n, C-M-f, etc to get their, because I don’t need to think about it.

Does this make sense? 

Yuan


reply via email to

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