Subject: Re: bug#71518: 30.0.50; Errors during redisplay with c++-ts-mode

From: Vincenzo Pupillo <[email-masked]>
Date: Sat, 22 Jun 2024 18:14:54 +0200

In data sabato 22 giugno 2024 17:57:21 CEST, Eli Zaretskii ha scritto:
> > From: Vincenzo Pupillo <[email-masked]>
> > Cc: [email-masked]
> > Date: Sat, 22 Jun 2024 16:42:09 +0200
> > 
> > fortunately, this time it was easier than usual!
> 
> Thanks, but this change will _require_ the new version of the grammar
> library, right?  I think we usually fix these problems in a way that
> both the old and the new versions are supported, because people could
> have different versions installed.

In the tests I have done, it works with both the new and the old grammar.

> 
> Could you please amend the fix along these lines?
Okay, done. Can this be okay? 

Thanks.
Vincenzo
>From 5f88ff0001e8c4edb7519d1a85ebb13390d1a285 Mon Sep 17 00:00:00 2001
From: Vincenzo Pupillo <[email-masked]>
Date: Sat, 22 Jun 2024 16:22:16 +0200
Subject: [PATCH] Fix for grammar change of keyword "virtual" in
 tree-sitter-cpp

The new rule works with both the new (>= 0.22.1) and the old (<= 0.22.0)
grammar.

* lisp/progmodes/c-ts-mode.el (c-ts-mode--keywords):
  Removed the keyword "virtual".
* lisp/progmodes/c-ts-mode.el (c-ts-mode--font-lock-settings):
  New font lock rule. (Bug#71518)
---
 lisp/progmodes/c-ts-mode.el | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/c-ts-mode.el b/lisp/progmodes/c-ts-mode.el
index f453392ff7f..7bfb84baecb 100644
--- a/lisp/progmodes/c-ts-mode.el
+++ b/lisp/progmodes/c-ts-mode.el
@@ -572,7 +572,7 @@ c-ts-mode--keywords
                   "not" "not_eq" "operator" "or"
                   "or_eq" "override" "private" "protected"
                   "public" "requires" "template" "throw"
-                  "try" "typename" "using" "virtual"
+                  "try" "typename" "using"
                   "xor" "xor_eq"))
       (append '("auto") c-keywords))))
 
@@ -632,7 +632,8 @@ c-ts-mode--font-lock-settings
 
    :language mode
    :feature 'keyword
-   `([,@(c-ts-mode--keywords mode)] @font-lock-keyword-face
+   `((virtual) @font-lock-keyword-face
+     [,@(c-ts-mode--keywords mode)] @font-lock-keyword-face
      ,@(when (eq mode 'cpp)
          '((auto) @font-lock-keyword-face
            (this) @font-lock-keyword-face)))
-- 
2.45.2