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: Stefan Monnier
Subject: Re: Average-user-facing interface for tree-sitter
Date: Tue, 18 Oct 2022 18:31:10 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux)

>> Too much magic, IMO.  Let each case handle it manually, since I suspect
>> that every case will be different and the best thing to do will vary (it
>> depends on whether the two modes are still actively maintained, whether
>> by the same authors or not, the relative age and popularity of the
>> respective modes, …)
>
> So we don’t do anything in global-treesit-mode? Ie,
>
> (define-globalized-minor-mode global-treesit-mode treesit-mode
>   global-treesit-mode--turn-on
>   :version "29.1"
>   :group 'treesit
>   :predicate t
>   (when (not global-treesit-mode)
>     (dolist (map treesit-remapped-major-mode-alist)
>       (setq major-mode-remap-alist
>             (remove map major-mode-remap-alist)))))
>
> to
>
> (define-globalized-minor-mode global-treesit-mode treesit-mode
>   global-treesit-mode--turn-on
>   :version "29.1"
>   :group 'treesit
>   :predicate t
>   )
>
> And remove treesit-remapped-major-mode-alist?

That's I'd do, yes.

It's much easier to add features later (if they prove to satisfy
a common need) than to remove unused features.

BTW, I see that `global-treesit-mode--turn-on` is currently a (non
official) alias of `treesit-mode`, but I think it should only call
`treesit-mode` in those buffers where there is some indication that the
major mode provides some treesit-mode support (e.g., currently that
could be if `major-mode-backend-function` is set).

And then maybe `treesit-mode` should signal an error (and turn itself
off) if it's enabled in a buffer whose major mode does not provide any
support for `treesit-mode`.


        Stefan




reply via email to

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