* bug#59720: 30.0.50; python-ts-mode: match/case is not fontified properly
@ 2022-11-30 10:03 Mickey Petersen
2022-11-30 15:16 ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-02 3:40 ` Yuan Fu
0 siblings, 2 replies; 3+ messages in thread
From: Mickey Petersen @ 2022-11-30 10:03 UTC (permalink / raw)
To: 59720
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
In GNU Emacs 30.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version
3.24.20, cairo version 1.16.0) of 2022-11-29 built on mickey-work
Repository revision: 7939184f8e0370e7a3397d492812c6d202c2a193
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12013000
System Description: Ubuntu 20.04.3 LTS
Configured using:
'configure --with-native-compilation --with-json --with-mailutils
--without-compress-install --with-imagemagick CC=gcc-10'
Configured features:
ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GPM GSETTINGS HARFBUZZ
IMAGEMAGICK JPEG JSON LCMS2 LIBOTF LIBSELINUX LIBSYSTEMD LIBXML2
M17N_FLT MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PNG RSVG SECCOMP
SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER X11 XDBE
XIM XINPUT2 XPM GTK3 ZLIB
Important settings:
value of $LC_MONETARY: en_GB.UTF-8
value of $LC_NUMERIC: en_GB.UTF-8
value of $LC_TIME: en_GB.UTF-8
value of $LANG: en_GB.UTF-8
value of $XMODIFIERS: @im=ibus
locale-coding-system: utf-8-unix
Major mode: EL
Memory information:
((conses 16 1470611 151650)
(symbols 48 83975 12)
(strings 32 412115 14879)
(string-bytes 1 12040593)
(vectors 16 146926)
(vector-slots 8 3669783 89353)
(floats 8 829 511)
(intervals 56 18032 4083)
(buffers 992 58))
^ permalink raw reply [flat|nested] 3+ messages in thread
* bug#59720: 30.0.50; python-ts-mode: match/case is not fontified properly
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
2022-12-02 3:40 ` Yuan Fu
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors @ 2022-11-30 15:16 UTC (permalink / raw)
To: Mickey Petersen; +Cc: 59720
[-- 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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* bug#59720: 30.0.50; python-ts-mode: match/case is not fontified properly
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
@ 2022-12-02 3:40 ` Yuan Fu
1 sibling, 0 replies; 3+ messages in thread
From: Yuan Fu @ 2022-12-02 3:40 UTC (permalink / raw)
To: Daniel Martín; +Cc: 59720-done, mickey
Daniel Martín <mardani29@yahoo.es> writes:
> 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.
Applied, thanks!
Yuan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-12-02 3:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2022-12-02 3:40 ` Yuan Fu
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).