Subject: Re: bug#60961: 29.0.60; Compiling emacs-29 without treesitter outputs warnings

From: Eli Zaretskii <[email-masked]>
Date: Fri, 20 Jan 2023 15:36:27 +0200

> From: Robert Pluim <[email-masked]>
> Date: Fri, 20 Jan 2023 11:30:33 +0100
> 
> 
> This is emacs-29 as of 6b2f85caa6c
> 
>   ELC      progmodes/csharp-mode.elc
>   Warning (treesit): Cannot activate tree-sitter, because tree-sitter library is not compiled with Emacs
>   Warning (treesit): Cannot activate tree-sitter, because tree-sitter library is not compiled with Emacs
>   Warning (treesit): Cannot activate tree-sitter, because tree-sitter library is not compiled with Emacs
>   ELC      progmodes/dockerfile-ts-mode.elc
>   ELC      progmodes/go-ts-mode.elc
>   ELC      progmodes/java-ts-mode.elc
>   Warning (treesit): Cannot activate tree-sitter, because tree-sitter library is not compiled with Emacs
>   Warning (treesit): Cannot activate tree-sitter, because tree-sitter library is not compiled with Emacs
>   Warning (treesit): Cannot activate tree-sitter, because tree-sitter library is not compiled with Emacs
>   ELC      progmodes/js.elc
>   Warning (treesit): Cannot activate tree-sitter, because tree-sitter library is not compiled with Emacs
>   Warning (treesit): Cannot activate tree-sitter, because tree-sitter library is not compiled with Emacs
>   Warning (treesit): Cannot activate tree-sitter, because tree-sitter library is not compiled with Emacs
>   ELC      progmodes/json-ts-mode.elc
>   ELC      progmodes/python.elc
>   ELC      progmodes/ruby-mode.elc
>   ELC      progmodes/ruby-ts-mode.elc
>   ELC      progmodes/rust-ts-mode.elc
>   Warning (treesit): Cannot activate tree-sitter, because tree-sitter library is not compiled with Emacs
>   Warning (treesit): Cannot activate tree-sitter, because tree-sitter library is not compiled with Emacs
>   Warning (treesit): Cannot activate tree-sitter, because tree-sitter library is not compiled with Emacs
>   ELC      progmodes/typescript-ts-mode.elc
>   Warning (treesit): Cannot activate tree-sitter, because tree-sitter library is not compiled with Emacs
>   Warning (treesit): Cannot activate tree-sitter, because tree-sitter library is not compiled with Emacs
>   Warning (treesit): Cannot activate tree-sitter, because tree-sitter library is not compiled with Emacs

Yes, I've seen these as well.  The reason is that some modes 'require'
c-ts-mode, because they want to use their comment-related functions.
But the changes I made recently call treesit-ready-p when c-ts-mode is
being loaded, and that emits the warning.  I can shut up the warning
by calling treesit-ready-p with a non-nil QUIET argument, but then the
warning will not be emitted if users load c-ts-mode from their init
files or manually, which is not good.  I tried several other
solutions, but they either didn't work or were not clean enough for my
palate.

Yuan/Theo, please find a solution for this.  If no better idea comes
up, I think the c-ts-mode functions that other modes want to use
should be moved to a separate file, and that file that can be
'require'd by all those which want it, including by c-ts-mode.el.

TIA.