Subject: bug#64917: 30.0.50; c-ts-mode throws warnings about missing cpp support

From: Yuan Fu <[email-masked]>
Date: Sat, 29 Jul 2023 10:46:18 -0700

> On Jul 28, 2023, at 5:11 AM, Eli Zaretskii <[email-masked]> wrote:
> 
> tags 64917 notabug
> thanks
> 
>> From: Robert Pluim <[email-masked]>
>> Date: Fri, 28 Jul 2023 11:14:15 +0200
>> 
>> I built master with tree-sitter support, and installed the c-language
>> grammar using M-x treesit-install-language-grammar. I have
>> libtree-sitter-c.so in ~/.emacs.d/tree-sitter
>> 
>> I restarted emacs, visited src/xdisp.c, and did M-x c-ts-mode, which
>> popped up a *Warnings* buffer containing:
>> 
>> ⛔ Warning (treesit): Cannot activate tree-sitter, because language grammar for cpp is unavailable (not-found): (libtree-sitter-cpp libtree-sitter-cpp.0 libtree-sitter-cpp.0.0 libtree-sitter-cpp.so libtree-sitter-cpp.so.0 libtree-sitter-cpp.so.0.0) No such file or directory
>> ⛔ Warning (treesit): Cannot activate tree-sitter, because language grammar for cpp is unavailable (not-found): (libtree-sitter-cpp libtree-sitter-cpp.0 libtree-sitter-cpp.0.0 libtree-sitter-cpp.so libtree-sitter-cpp.so.0 libtree-sitter-cpp.so.0.0) No such file or directory
>> 
>> which is less than desirable (althoug `major-mode' is c-ts-mode, so I
>> guess things worked)
> 
> Please install the C++ grammar as well.  Those two go together because
> some *.h files could be C or C++, and we can only test that at run
> time.

For future reference, that’s true but not the whole picture. The warning is caused by the call to (treesit-ready-p ‘cpp) at the end of c-ts-mode.el:

(if (treesit-ready-p 'cpp)
    (add-to-list 'auto-mode-alist
                 '("\\(\\.ii\\|\\.\\(CC?\\|HH?\\)\\|\\.[ch]\\(pp\\|xx\\|\\+\\+\\)\\|\\.\\(cc\\|hh\\)\\)\\'"
                   . c++-ts-mode)))

There was a discussion on whether we want to use (treesit-ready-p ‘cpp t) which tests for the availability of cpp grammar but doesn’t raise a warning. And your decision was to keep the warning, IIRC.

And my understanding is that these code that modifies auto-mode-alist whenever c-ts-mode.el is loaded are temporary for Emacs 29, and in the future might be removed. If they are removed, the warning will be gone.

Yuan