Subject: bug#59720: 30.0.50; python-ts-mode: match/case is not fontified properly

From: Daniel Martín <[email-masked]>
Date: Wed, 30 Nov 2022 16:16:07 +0100

Mickey Petersen <[email-masked]> writes:

> 1. Visit a python file. It will use the regular python mode.
> 2. Write:
>
>     def foo():
>          match foo:
>              case 10:
>                  pass
>
> 3. It is highlighted correctly: match and case are fontified with `font-lock-keyword-face'.
> 4. Type M-x python-ts-mode.
> 5. Highlighting is now off for match/case. Text properties for the `m' character are:
>
>     Character code properties: customize what to show
>       name: LATIN SMALL LETTER M
>       general-category: Ll (Letter, Lowercase)
>       decomposition: (109) ('m')
>       uppercase: 77 (M)
>       titlecase: 77 (M)
>
>     There are text properties here:
>       fontified            t
>

The following patch solves the issue by adding "case" and "match" to the
list of keywords that python-ts-mode recognizes.

>From 6d0a98f7d55e04713c395b25b51e737489c394a8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <[email-masked]>
Date: Wed, 30 Nov 2022 16:11:46 +0100
Subject: [PATCH] Add case and match to python--treesit-keywords

* lisp/progmodes/python.el (python--treesit-keywords): Add "case" and
"match" keywords.
---
 lisp/progmodes/python.el | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index acfee21135..d02ab92121 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -962,9 +962,9 @@ python-dotty-syntax-table
 ;; merge with `python-font-lock-keywords-level-2'.
 
 (defvar python--treesit-keywords
-  '("as" "assert" "async" "await" "break" "class" "continue" "def"
+  '("as" "assert" "async" "await" "break" "case" "class" "continue" "def"
     "del" "elif" "else" "except" "exec" "finally" "for" "from"
-    "global" "if" "import" "lambda" "nonlocal" "pass" "print"
+    "global" "if" "import" "lambda" "match" "nonlocal" "pass" "print"
     "raise" "return" "try" "while" "with" "yield"
     ;; These are technically operators, but we fontify them as
     ;; keywords.
-- 
2.34.1