Subject: Re: bug#64830: 30.0.50 C++ treesitter mode no coloration

From: Alan Mackenzie <[email-masked]>
Date: Fri, 16 Aug 2024 16:44:33 +0000

Hello, Eli.

On Thu, Aug 15, 2024 at 08:25:34 +0300, Eli Zaretskii wrote:
> > Date: Wed, 14 Aug 2024 17:35:05 +0000
> > From: Alan Mackenzie <[email-masked]>

> > In my emacs-30 build (updated earlier today), C++ source in c++-ts-mode
> > is not getting fontified, except for comments and preprocessor
> > constructs.

> I cannot reproduce this, at least not with a random C++ source file I
> tried to.  Does this happen for you in "emacs -Q" and for every C++
> file?

Yes, and yes.  Here's a recipe:

Create the file ~/class-3.cc with the following contents:
/////////////////////////////////////////////////////////////////////////
// foo
class A
{
    struct B {
        int i;
    };
    struct B {
        int i;
    };
};
/////////////////////////////////////////////////////////////////////////

(i) emacs -Q
(ii) M-x load-library <RET> c-ts-mode <RET>
(iii) C-x C-f ~/class-3.cc <RET>

The buffer, in c++-ts-mode, has no fontification apart from the comment
on its first line.

> If this happens with any file and in 'emacs -Q", do you see redisplay
> error messages in *Messages*?  If so, what are those messages?

Yes, I see a single message after the above recipe.  It's:

Error during redisplay: (jit-lock-function 1) signaled
(treesit-query-error "Node type error at" 677 "[\"_Atomic\" \"break\"
\"case\" \"const\" \"continue\" \"default\" \"do\" \"else\" \"enum\"
\"extern\" \"for\" \"goto\" \"if\" \"inline\" \"register\" \"restrict\"
\"return\" \"sizeof\" \"static\" \"struct\" \"switch\" \"typedef\"
\"union\" \"volatile\" \"while\" \"and\" \"and_eq\" \"bitand\" \"bitor\"
\"catch\" \"class\" \"co_await\" \"co_return\" \"co_yield\" \"compl\"
\"\concept\" \"consteval\" \"constexpr\" \"constinit\" \"decltype\"
\"delete\" \"explicit\" \"final\" \"friend\" \"mutable\" \"namespace\"
\"new\" \"noexcept\" \"not\" \"not_eq\" \"operator\" \"or\" \"or_eq\"
\"override\" \"private\" \"protected\" \"public\" \"requires\"
\"template\" \"throw\" \"try\" \"typename\" \"using\" \"xor\"
\"xor_eq\"] @font-lock-keyword-face (auto) @font-lock-keyword-face
(this) @font-lock-keyword-face (virtual) @font-lock-keyword-face" "Debug
the query with `treesit-query-validate'")

> > I think I'm using tree-sitter-cpp version 0.22.2 as downloaded from the
> > Gentoo repository.  Is there an easy way to check this from inside
> > Emacs?

> No, not AFAIK.  And the problem is not the version of tree-sitter, it
> is usually the version of the C++ grammar library.  Do you know the
> version of that one you have installed?

I have libtree-sitter-cpp.so.0.14, built and installed on 2024-08-04.
The package is (confusingly) called dev-libs/tree-sitter-cpp-0.22.2.

> > This would appear to be bug 64818/64830, which are still open in
> > debbugs.  Shouldn't they be closed before the first/next emacs-30
> > pretest?

> Those bugs were fixed.  The reason they are not closed is that we
> raised a more general issue there, and that is not yet resolved.

OK.

-- 
Alan Mackenzie (Nuremberg, Germany).