emacs-devel
[Top][All Lists]
Advanced

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

Re: Tree-sitter api


From: Stefan Monnier
Subject: Re: Tree-sitter api
Date: Fri, 17 Sep 2021 13:18:16 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> It can be both, with one being the underlying mechanism for the other. (That's
> what I do in my packages.) The alist is a central place that's more convenient
> for users (not mode writers) to customize, e.g. in case a major mode hasn't
> added itself yet:
>
>     (add-hook 'foo-mode-hook (lambda () (setq tree-sitter-language-name 
> 'foo)))
>
> is less convenient than
>
>     (add-to-list 'tree-sitter-major-mode-language-alist '(foo-mode . foo))

Since in most cases TS support will require a fair bit more than just
the language's name, I'm not sure it will be useful for very many users.
So I'd start with just `tree-sitter-language-name` (which should anyway
be the main/canonical way to provide the language's name).

An alist indexed by a major mode is a "design smell" in my book.

>> [ Among other things because it won't signal an error when
>>   `tree-sitter.el` is not loaded.  ]
> We can make `tree-sitter-major-mode-language-list` autoloaded.

Autoloaded variables are also a design smell ;-)


        Stefan




reply via email to

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