all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: "Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Mickey Petersen <mickey@masteringemacs.org>
Cc: 59720@debbugs.gnu.org
Subject: bug#59720: 30.0.50; python-ts-mode: match/case is not fontified properly
Date: Wed, 30 Nov 2022 16:16:07 +0100	[thread overview]
Message-ID: <m1iliwscaw.fsf@yahoo.es> (raw)
In-Reply-To: <87lens21xn.fsf@masteringemacs.org> (Mickey Petersen's message of "Wed, 30 Nov 2022 10:03:33 +0000")

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

Mickey Petersen <mickey@masteringemacs.org> 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-case-and-match-to-python-treesit-keywords.patch --]
[-- Type: text/x-patch, Size: 1194 bytes --]

From 6d0a98f7d55e04713c395b25b51e737489c394a8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Daniel=20Mart=C3=ADn?= <mardani29@yahoo.es>
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


  reply	other threads:[~2022-11-30 15:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30 10:03 bug#59720: 30.0.50; python-ts-mode: match/case is not fontified properly Mickey Petersen
2022-11-30 15:16 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-12-02  3:40 ` Yuan Fu

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

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

  git send-email \
    --in-reply-to=m1iliwscaw.fsf@yahoo.es \
    --to=bug-gnu-emacs@gnu.org \
    --cc=59720@debbugs.gnu.org \
    --cc=mardani29@yahoo.es \
    --cc=mickey@masteringemacs.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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.