Subject: bug#72228: 31.0.50; Wrong number fontification in cmake-ts-mode

From: Randy Taylor <[email-masked]>
Date: Wed, 07 Aug 2024 01:00:01 +0000

On Monday, July 22nd, 2024 at 22:32, Randy Taylor <[email-masked]> wrote:
> 
> 
> On Sunday, July 21st, 2024 at 07:13, Ergus via "Bug reports for GNU Emacs, the Swiss army knife of text editors" [email-masked] wrote:
> 
> > When using cmake-ts-mode the numbers have 3 different faces:
> > 
> > 1, 2, 100: font-lock-number-face (OK)
> > 
> > 0 : font-lock-constant-face. The cmake-ts-mode--constants takes
> > precedence over regex in font-lock-number-face. It is not clear that
> > this one can be fixed.
> 
> 
> 1 also gets font-lock-constant-face.
> 
> I think we should just remove "1" and "0" from cmake-ts-mode--constants.
> 
> > -1, -2 : Not fontified. This seems simpler to fix, the regex in
> > font-lock-number-face is missing a `-?' before the first [[:digit:]])
> 
> 
> Indeed. Would you like to submit a patch for that and the above?

I haven't heard anything back, so I've attached a patch doing so.

From 4a104bd11f56dcb0136b32852d14756e0f13c9d9 Mon Sep 17 00:00:00 2001
From: Randy Taylor <[email-masked]>
Date: Tue, 6 Aug 2024 20:10:52 -0400
Subject: [PATCH] Fix cmake-ts-mode number fontification (Bug#72228)

* lisp/progmodes/cmake-ts-mode.el (cmake-ts-mode--constants):
Remove "1" and "0".
(cmake-ts-mode--font-lock-settings): Match negative numbers.
---
 lisp/progmodes/cmake-ts-mode.el | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/cmake-ts-mode.el b/lisp/progmodes/cmake-ts-mode.el
index b70806f4c30..854adf4ade7 100644
--- a/lisp/progmodes/cmake-ts-mode.el
+++ b/lisp/progmodes/cmake-ts-mode.el
@@ -73,8 +73,7 @@ cmake-ts-mode--indent-rules
   "Tree-sitter indent rules for `cmake-ts-mode'.")
 
 (defvar cmake-ts-mode--constants
-  '("1" "ON" "TRUE" "YES" "Y" "0" "OFF" "FALSE" "NO" "N" "IGNORE"
-    "NOTFOUND")
+  '("ON" "TRUE" "YES" "Y" "OFF" "FALSE" "NO" "N" "IGNORE" "NOTFOUND")
   "CMake constants for tree-sitter font-locking.")
 
 (defvar cmake-ts-mode--keywords
@@ -164,7 +163,7 @@ cmake-ts-mode--font-lock-settings
    :language 'cmake
    :feature 'number
    '(((unquoted_argument) @font-lock-number-face
-      (:match "\\`[[:digit:]]*\\.?[[:digit:]]*\\.?[[:digit:]]+\\'"
+      (:match "\\`-?[[:digit:]]*\\.?[[:digit:]]*\\.?[[:digit:]]+\\'"
               @font-lock-number-face)))
 
    :language 'cmake
-- 
2.46.0