emacs-devel
[Top][All Lists]
Advanced

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

Re: Average-user-facing interface for tree-sitter


From: Yuan Fu
Subject: Re: Average-user-facing interface for tree-sitter
Date: Tue, 18 Oct 2022 13:54:50 -0700


> On Oct 17, 2022, at 2:15 AM, Lars Ingebrigtsen <larsi@gnus.org> wrote:
> 
> Yuan Fu <casouri@gmail.com> writes:
> 
>> If no one has opinions on this, I’m going to implement the
>> central-variable approach, since IMO that one is most fit.
> 
> Well, my opinion is that modes is the right approach, since that's what
> we use for most of these things in Emacs, so people are used to them.
> (We've been moving a whole bunch of stuff that used to be variables to
> modes over the years.)

Ok, I installed the toggle system. Now we have treesit-mode and 
global-treesit-mode. Major modes set major-mode-backend-function and 
treesit-mode uses that function to turn on/off tree-sitter features.

mode-backend-function is pretty straightforward for major modes that supports 
both tree-sitter and no-tree-sitter. They just need to set local variables.

For separated major modes, they need to do a bit of a dance. Besides switching 
to the new major mode, they need  to add (mode . new-mode) to 
major-mode-remap-alist if global-treesit-mode is on (so next time we go 
straight to new-mode as long as global-treesit-mode is on). They also need to 
add (mode . new-mode) to treesit-remapped-major-mode-alist so 
global-treesit-mode can remove these entries when it turns off.

Yuan


reply via email to

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