Subject: bug#64487: 29.0.92; Another tree-sitter warning inside Custom

From: Dmitry Gutov <[email-masked]>
Date: Mon, 26 Feb 2024 18:25:33 +0200

On 06/07/2023 12:12, Eli Zaretskii wrote:
>> Date: Thu, 06 Jul 2023 14:56:44 +0800
>> From:  Po Lu via "Bug reports for GNU Emacs,
>>   the Swiss army knife of text editors" <[email-masked]>
>>
>> Type M-x customize RET.  Click Programming and then Languages.  A
>> *Warnings* buffer will be displayed containing the following message:
>>
>>    Warning (treesit): Cannot activate tree-sitter, because language
>>    grammar for ruby is unavailable (not-found): (libtree-sitter-ruby
>>    libtree-sitter-ruby.0 libtree-sitter-ruby.0.0 libtree-sitter-ruby.so
>>    libtree-sitter-ruby.so.0 libtree-sitter-ruby.so.0.0) No such file or
>>    directory
> 
> When you customize a group, Custom loads all the packages that belong
> to the group.  So in this case it loads ruby-ts-mode, and you get the
> warning.

Which was never a problem before when simply loading a package didn't 
alter auto-mode-alist.

>> Can't these messages only be displayed when a tree-sitter major mode is
>> enabled, as opposed to whenever the file implementing the major mode is
>> loaded?
> 
> Emacs 29 deliberately checks for the grammar's availability when the
> package is loaded, to give users a prominent indication that the
> loaded package will not work.  This won't change in Emacs 29, but
> maybe as part of rethinking this after releasing Emacs 29 we could
> improve the situation with customizing a group as well.
> 
> Anyway, the warning is just a warning, and is otherwise harmless.  It
> also only appears when Emacs has been built with tree-sitter, but the
> grammar libraries required by some *-ts-mode's are not installed.

Suppose the grammar is actually available. Perhaps the user had compiled 
it at some point, or perhaps it's installed system-wide due to another 
dependency.

Do I understand it right that performing the simple steps that Po Lu 
outlined would silently assign ruby-ts-mode to *.rb files? And a bunch 
of other such modes that get loaded as well. But only until the end of 
the session.