unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Yuan Fu <casouri@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 64830@debbugs.gnu.org, Alan Mackenzie <acm@muc.de>
Subject: bug#64830: 30.0.50 C++ treesitter mode no coloration
Date: Sat, 24 Aug 2024 11:35:36 -0700	[thread overview]
Message-ID: <3C502C2B-829D-42C3-A74A-2A783F5880CE@gmail.com> (raw)
In-Reply-To: <F8EAFCE5-A6D8-43FC-8F97-FC34A2520CAD@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1377 bytes --]



> On Aug 19, 2024, at 8:46 PM, Yuan Fu <casouri@gmail.com> wrote:
> 
> 
> 
>> On Aug 16, 2024, at 11:27 AM, Eli Zaretskii <eliz@gnu.org> wrote:
>> 
>>> Date: Fri, 16 Aug 2024 18:06:31 +0000
>>> Cc: 64830@debbugs.gnu.org, casouri@gmail.com, acm@muc.de
>>> From: Alan Mackenzie <acm@muc.de>
>>> 
>>>> Maybe your Emacs 30 build is old?
>>> 
>>> No.  I updated it on Wednesday, the most recent commit I have being:
>>> 
>>> commit 9bedb957bebdca99b1bb96f58ea790e20ed48dee (HEAD -> emacs-30,
>>> origin/emacs-30)
>>> Author: Eli Zaretskii <eliz@gnu.org>
>>> Date:   Wed Aug 14 11:35:48 2024 +0300
>>> 
>>>   Improve documentation of time-parsing functions
>>> 
>>> ..  I will update it right now and retry ....
>>> 
>>> ..... DONE.  It makes no difference.  I don't understand either why I see
>>> this bug and you don't.
>> 
>> Maybe try updating the C++ grammar library?
>> 
>> Yuan, any ideas?
> 
> Nothing obviously wrong from a glance. I’m very busy recently but I’ll have some time this week to look into this. Sorry for the delay :-)
> 
> Yuan

Upon closer inspection, I think this is caused by a recent change in c-ts-mode font-lock rules, in 014aab9847a0d3d898cb8cbc7224143f2d741abb.

Alan, could you do this: don’t upgrade your c++ grammar and try this patch, if I was right it should fix your problem. Thanks!

Yuan


[-- Attachment #2: cpp-font-lock.patch --]
[-- Type: application/octet-stream, Size: 1832 bytes --]

From a171709cadd915f48d6c8ed3f9e1e19f6a4fde19 Mon Sep 17 00:00:00 2001
From: Yuan Fu <casouri@gmail.com>
Date: Sat, 24 Aug 2024 11:32:43 -0700
Subject: [PATCH] Fix c-ts-mode font-lock for older c++ grammar (bug#64830)

* lisp/progmodes/c-ts-mode.el:
(c-ts-mode--virtual-named-p): New function.
(c-ts-mode--font-lock-settings): Use either keyword or named node
depending on grammar version.
---
 lisp/progmodes/c-ts-mode.el | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index 6c406a8acd9..66e4999677b 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -537,6 +537,16 @@ c-ts-mode--top-level-label-matcher
        (equal "function_definition"
               (treesit-node-type (treesit-node-parent parent)))))
 
+;;; Grammar checks
+
+;; Ref: https://github.com/tree-sitter/tree-sitter-cpp/commit/c51ffe9d7b67aa9500db01c26d8c075cfe032d0f
+(defun c-ts-mode--virtual-named-p ()
+  "Return t if virtual is a named node instead of a keyword."
+  (ignore-errors
+    (progn
+      (treesit-query-compile 'c++ "(virtual) @cap")
+      t)))
+
 ;;; Font-lock
 
 (defvar c-ts-mode--feature-list
@@ -635,9 +645,11 @@ c-ts-mode--font-lock-settings
    :feature 'keyword
    `([,@(c-ts-mode--keywords mode)] @font-lock-keyword-face
      ,@(when (eq mode 'cpp)
-         '((auto) @font-lock-keyword-face
+         `((auto) @font-lock-keyword-face
            (this) @font-lock-keyword-face
-           (virtual) @font-lock-keyword-face)))
+           ,@(if (c-ts-mode--virtual-named-p)
+                 '((virtual) @font-lock-keyword-face)
+               '("virtual" @font-lock-keyword-face)))))
 
    :language mode
    :feature 'operator
-- 
2.39.5 (Apple Git-151)


  reply	other threads:[~2024-08-24 18:35 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-24  9:13 bug#64830: 29.1; C++ treesitter mode no coloration David Come
2023-07-24 12:32 ` Eli Zaretskii
2024-08-14 17:35 ` bug#64830: 30.0.50 " Alan Mackenzie
2024-08-15  5:25   ` Eli Zaretskii
2024-08-16 16:44     ` Alan Mackenzie
2024-08-16 17:40       ` Eli Zaretskii
2024-08-16 17:45         ` Eli Zaretskii
2024-08-16 18:06           ` Alan Mackenzie
2024-08-16 18:27             ` Eli Zaretskii
2024-08-20  3:46               ` Yuan Fu
2024-08-24 18:35                 ` Yuan Fu [this message]
2024-08-24 19:38                   ` Alan Mackenzie
2024-08-24 20:43                     ` Yuan Fu
2024-08-25  2:19                       ` Alan Mackenzie
2024-08-25  4:54                         ` Eli Zaretskii
2024-08-25 12:08                           ` Alan Mackenzie
2024-08-25 12:17                             ` Eli Zaretskii
2024-08-25 22:40                         ` Yuan Fu
2024-08-26 17:25                           ` Alan Mackenzie
2024-08-26 17:51                             ` Eli Zaretskii
2024-08-26 19:50                               ` Alan Mackenzie
2024-08-26 22:25                                 ` Stefan Kangas
2024-08-27  1:58                                   ` Yuan Fu
2024-08-27 12:09                                     ` Eli Zaretskii
2024-08-28  5:36                                       ` Yuan Fu
2024-08-28 12:33                                         ` Eli Zaretskii
2024-08-29  4:54                                           ` Yuan Fu
2024-08-29  6:01                                             ` Eli Zaretskii
2024-09-11  5:09                                               ` Yuan Fu
2024-09-11 12:09                                                 ` Eli Zaretskii
2024-09-12  8:06                                                   ` Yuan Fu
2024-08-27 12:01                                 ` Eli Zaretskii
2024-08-27 11:03                             ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3C502C2B-829D-42C3-A74A-2A783F5880CE@gmail.com \
    --to=casouri@gmail.com \
    --cc=64830@debbugs.gnu.org \
    --cc=acm@muc.de \
    --cc=eliz@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).