From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Yuan Fu Newsgroups: gmane.emacs.bugs Subject: bug#64830: 30.0.50 C++ treesitter mode no coloration Date: Sun, 25 Aug 2024 15:40:31 -0700 Message-ID: References: <868qwy8ii9.fsf@gnu.org> <86o75s5pu0.fsf@gnu.org> <86mslc5plq.fsf@gnu.org> <86h6bk5nnu.fsf@gnu.org> <3C502C2B-829D-42C3-A74A-2A783F5880CE@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3776.700.51\)) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5139"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 64830@debbugs.gnu.org, Eli Zaretskii To: Alan Mackenzie Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Aug 26 00:42:41 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1siLwW-0001Bg-Fl for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 26 Aug 2024 00:42:40 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1siLw6-0003yg-IR; Sun, 25 Aug 2024 18:42:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1siLw4-0003y6-Kv for bug-gnu-emacs@gnu.org; Sun, 25 Aug 2024 18:42:12 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1siLw4-00088x-C2 for bug-gnu-emacs@gnu.org; Sun, 25 Aug 2024 18:42:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=References:Date:In-Reply-To:From:Mime-Version:To:Subject; bh=hYBQVTW3+XOpIo/edszHV+VUwgS/EkrUCrQWoy+sP0Q=; b=eSUQt2mMmv4HRUZ8OFI2znZ9kTJNL48IEMsmlWr7xWI+EaPE+CU/ALsCMKrlsOl0I8uHfZwifIDyLdZeoUrEmEaTAowkcHDooUByXcQD4wPCQSS8KAZ35ibSuP0oDLv5MwKsGfZav5akPNJHCZT+bezIa0rQ0qRrAbT811dnCWWYdxPy0RMbU03hyP6zOmheDZEtB000F7Ox6OVRajjMOShJB6Oh/oNd6DP/Fxvl3osWv/zJtYm/QcZGHgofoFnxZDm6YHAx9wzcME5J33nJS4eEbebeoKFQ+oLhMSxD+pZrvYkIVSmj0XyodIl/FRbyUhTwCyWyEXRGcoCfJ2VghA==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1siLws-0005Hf-DL for bug-gnu-emacs@gnu.org; Sun, 25 Aug 2024 18:43:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Yuan Fu Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 25 Aug 2024 22:43:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 64830 X-GNU-PR-Package: emacs Original-Received: via spool by 64830-submit@debbugs.gnu.org id=B64830.172462576320278 (code B ref 64830); Sun, 25 Aug 2024 22:43:02 +0000 Original-Received: (at 64830) by debbugs.gnu.org; 25 Aug 2024 22:42:43 +0000 Original-Received: from localhost ([127.0.0.1]:43427 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1siLwY-0005H0-R8 for submit@debbugs.gnu.org; Sun, 25 Aug 2024 18:42:43 -0400 Original-Received: from mail-pj1-f46.google.com ([209.85.216.46]:55688) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1siLwW-0005Gl-4J for 64830@debbugs.gnu.org; Sun, 25 Aug 2024 18:42:41 -0400 Original-Received: by mail-pj1-f46.google.com with SMTP id 98e67ed59e1d1-2d60f48a2ccso3056433a91.3 for <64830@debbugs.gnu.org>; Sun, 25 Aug 2024 15:41:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724625644; x=1725230444; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=hYBQVTW3+XOpIo/edszHV+VUwgS/EkrUCrQWoy+sP0Q=; b=TgJ5j07upTULFGj+bXLfo5KCgUg5SaO2KpMcZJ4Qqfj1LKFA05aC2jIQ3zhnWtAkUa l6x/wd7Re4M+urCe/JJKgsWVkrCXBzQ7lLH9OQbF/kdMjVDm8DymMrG3LezwVmRQHi/j r+iTVHJm/qhtpy+8bOE8zkzcMzTxE2+L+ziWcDSemlmHKIJIvk8CyVwP8VspCUY4k5G9 cFOn4fWcv/DXAQfQKUGkUzMAX3fQs3VbHAPeojvsj3HSC/k3eKC2mr/7+pKVwY+Hr2wT GfkOgBgc+GkeNTYw67mmSt2kMp1UCs+SqAaBv9hHS2mCcpxGqSfqsS7jScZF3flHyCT3 UXXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724625644; x=1725230444; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hYBQVTW3+XOpIo/edszHV+VUwgS/EkrUCrQWoy+sP0Q=; b=wWIPnuCr2usE7NnwH16mMp6u+ewLMLbbOaya2KzCFfI4qUOCcR99/PyE2+tseb0SqQ VY2gg3T1OAd+FsntLEkOuzyOQLPVjUpvwIhKdmbuSIeO096qE8pRwebJVYwVnAgO/rDY jVfOKJnqYF54kEAr1vRfIjtFObO57V6O3p6W21NB3KcVMWe9QwHj0oM3sXe2AqzdY/P7 0++18ZXI0cdMLOra2RV7DOBVCfDLW5qkf4ILtPjhbnHlgoXjZpjnn3coI5d+8QILI8Qz cYM2BVtKACiwFsYAFbZ50bhUGFjukja65G4/zZOFSME0BHzowKzpcTuM1xwfpzZ5PQIE TTVA== X-Forwarded-Encrypted: i=1; AJvYcCXb1wmZA+8zKvvJLP9E3bXoBhg/pXotpq7RiR8C8RzROJP3R1jnzUSCUW+FdNoMPOYnr5WjfQ==@debbugs.gnu.org X-Gm-Message-State: AOJu0Yxv/s7mBeMSKqIjxC1DfclIDCV0pbAyvkll7hePqoXTRn26zdPF i9j7mBgMFJ61bsDlKni8n65rw/EBegQmX+dS05YMVzoJNTMmfiFl X-Google-Smtp-Source: AGHT+IH47ijBhq1J/kF1ME2n3o/WgvoZzaoSaRVxNBmQriQnPEaBwtvCJaiZ3Ts7EOOxDkf7EtJUzA== X-Received: by 2002:a17:90a:8983:b0:2cb:4f14:2a70 with SMTP id 98e67ed59e1d1-2d646d2483amr9133190a91.30.1724625643468; Sun, 25 Aug 2024 15:40:43 -0700 (PDT) Original-Received: from smtpclient.apple ([2601:646:8f81:6120:3470:5bab:363c:9aa2]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d613af1879sm8306326a91.46.2024.08.25.15.40.42 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 25 Aug 2024 15:40:42 -0700 (PDT) In-Reply-To: X-Mailer: Apple Mail (2.3776.700.51) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:290766 Archived-At: > On Aug 24, 2024, at 7:19=E2=80=AFPM, Alan Mackenzie = wrote: >=20 > Hello, Yuan. >=20 > On Sat, Aug 24, 2024 at 13:43:25 -0700, Yuan Fu wrote: >=20 >=20 >>> On Aug 24, 2024, at 12:38=E2=80=AFPM, Alan Mackenzie = wrote: >>> On Sat, Aug 24, 2024 at 11:35:36 -0700, Yuan Fu wrote: >>>>> On Aug 19, 2024, at 8:46=E2=80=AFPM, Yuan Fu = wrote: >>>>>> On Aug 16, 2024, at 11:27=E2=80=AFAM, Eli Zaretskii = wrote: >=20 >>>>>>> Date: Fri, 16 Aug 2024 18:06:31 +0000 >>>>>>> Cc: 64830@debbugs.gnu.org, casouri@gmail.com, acm@muc.de >>>>>>> From: Alan Mackenzie >=20 >>>>>>>> Maybe your Emacs 30 build is old? >=20 >>>>>>> No. I updated it on Wednesday, the most recent commit I have = being: >=20 >>>>>>> commit 9bedb957bebdca99b1bb96f58ea790e20ed48dee (HEAD -> = emacs-30, >>>>>>> origin/emacs-30) >>>>>>> Author: Eli Zaretskii >>>>>>> Date: Wed Aug 14 11:35:48 2024 +0300 >=20 >>>>>>> Improve documentation of time-parsing functions >=20 >>>>>>> .. I will update it right now and retry .... >=20 >>>>>>> ..... DONE. It makes no difference. I don't understand either >>>>>>> why I see this bug and you don't. >=20 >>>>>> Maybe try updating the C++ grammar library? >=20 >>>>>> Yuan, any ideas? >=20 >>>>> Nothing obviously wrong from a glance. I=E2=80=99m very busy = recently but >>>>> I=E2=80=99ll have some time this week to look into this. Sorry for = the >>>>> delay :-) >=20 >>>>> Yuan >=20 >>>> Upon closer inspection, I think this is caused by a recent change = in >>>> c-ts-mode font-lock rules, in >>>> 014aab9847a0d3d898cb8cbc7224143f2d741abb. >=20 >>>> Alan, could you do this: don=E2=80=99t upgrade your c++ grammar and = try this >>>> patch, if I was right it should fix your problem. Thanks! >=20 >>> I updated my emacs-30 branch, checked that that commit was included, >>> and rebuilt it. The problem still exists on my copy of Emacs 30. >>> :-( >=20 >> No no I mean apply the attached patch and see if it fixes the = problem. >> The commit hash I mentioned is the source of the bug, not the fix ;-) >=20 > Sorry about the misunderstanding. >=20 > I've now applied your patch, the one whose first hunk's header is: >=20 > @@ -537,6 +537,16 @@ c-ts-mode--top-level-label-matcher >=20 > , but it unfortunately doesn't solve the bug. On templates-21.cc, one = of > the test files from CC Mode, on doing M-x c++-ts-mode, there is no > fontification at all. In *Messages* we have >=20 > 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'") >=20 > That "Node type error at" 677 isn't a buffer position - the buffer is > only 325 characters long. >=20 > Is there anything else I could do to help, here? Yes, could you try evaluating this three forms, and tell me their = result? (treesit-query-validate 'cpp '("virtual" @cap)) (treesit-query-validate 'cpp '((virtual) @cap)) (treesit-query-validate 'cpp '((auto) @font-lock-keyword-face (this) @font-lock-keyword-face (virtual) @font-lock-keyword-face)) To give more context, in the error you see, position 677 is a position = in the query string, which points to the (virtual) part. That leads me = to believe your grammar doesn=E2=80=99t recognize the (virtual) query. = So in the patch I provided earlier, I added a function that tests = whether the grammar recognizes (virtual), and if not, it uses the = =E2=80=9Cvirtual=E2=80=9D query instead. The difference between = (virtual) and =E2=80=9Cvirtual=E2=80=9D in the query is that (virtual) = is a named node, and =E2=80=9Cvirtual=E2=80=9D is a keyword. I=E2=80=99m still not sure why you have this problem though, because I = built libtree-sitter-cpp v0.22.2 and v0.22.0 and tested them locally, = and they recognize (virtual) just fine. Anyway, evaluating those three = forms will tell us what=E2=80=99s going on. And to your question for building tree-sitter grammar, you can use the = script at https://github.com/casouri/tree-sitter-module You can either run ./batch to build all the languages, or run ./build = cpp to only build for cpp. Then just copy the grammar file in dist to = ~/.emacs.d/tree-sitter. Yuan=