From: Vincenzo Pupillo <v.pupillo@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>, Yuan Fu <casouri@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: Define treesit-font-lock-level as buffer local
Date: Tue, 17 Dec 2024 12:31:21 +0100 [thread overview]
Message-ID: <5719751.rdbgypaU67@3-191.divsi.unimi.it> (raw)
In-Reply-To: <2528408.XAFRqVoOGU@fedora>
[-- Attachment #1: Type: text/plain, Size: 818 bytes --]
Ciao Yuan,
I found a bug in python-ts-mode, it does not handle treesit-font-lock-level
even as a list. The attached patch fixes this bug.
Thank you.
Vincenzo
In data sabato 14 dicembre 2024 12:14:02 Ora standard dell’Europa centrale,
Vincenzo Pupillo ha scritto:
> In data domenica 8 dicembre 2024 08:44:25 Ora standard dell’Europa centrale,
> Yuan Fu ha scritto:
> > Ok, following the recent discussion, I implemented the original idea,
> > which
> > is an alist mapping major modes to font lock levels. The check is made
> > with
> > derived-mode-p, so c-mode should work for c-ts-mode too, but I still used
> > c-ts-mode in the example in the docstring since I don’t want to complicate
> > it. The change is pushed to master.
> >
> > Yuan
>
> Thank you Yuan!
>
> Vincenzo
[-- Attachment #2: 0001-python-ts-mode-now-handles-the-treesit-font-lock-lev.patch --]
[-- Type: text/x-patch, Size: 1456 bytes --]
From ec63146bfcb54c78af7fac3cb0791b94cb1a43ca Mon Sep 17 00:00:00 2001
From: Vincenzo Pupillo <vincenzo.pupillo@unimi.it>
Date: Tue, 17 Dec 2024 12:14:29 +0100
Subject: [PATCH] python-ts-mode now handles the treesit-font-lock-level
correctly.
'treesit-font-lock-level' can be a number or a list, it should be
handled using 'treesit--compute-font-lock-level'.
* lisp/progmodes/python.el (python--treesit-fontify-string): Apply
'treesit--compute-font-lock-level' to 'treesit-font-lock-level'.
---
lisp/progmodes/python.el | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/python.el b/lisp/progmodes/python.el
index dca0936c826..de1c6f551c4 100644
--- a/lisp/progmodes/python.el
+++ b/lisp/progmodes/python.el
@@ -1108,7 +1108,8 @@ python--treesit-fontify-string
(ignore-interpolation (not
(seq-some
(lambda (feats) (memq 'string-interpolation feats))
- (seq-take treesit-font-lock-feature-list treesit-font-lock-level))))
+ (seq-take treesit-font-lock-feature-list
+ (treesit--compute-font-lock-level treesit-font-lock-level)))))
;; If interpolation is enabled, highlight only
;; string_start/string_content/string_end children. Do not
;; touch interpolation node that can occur inside of the
--
2.47.1
next prev parent reply other threads:[~2024-12-17 11:31 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-07 10:30 Define treesit-font-lock-level as buffer local Vincenzo Pupillo
2024-11-07 11:03 ` Eli Zaretskii
2024-11-07 11:08 ` Vincenzo Pupillo
2024-11-09 8:36 ` Yuan Fu
2024-11-09 8:54 ` Eli Zaretskii
2024-11-10 8:04 ` Yuan Fu
2024-11-23 12:20 ` Eli Zaretskii
2024-11-29 5:49 ` Tree-sitter central configuration variable Yuan Fu
2024-11-29 7:12 ` Eshel Yaron
2024-11-29 8:42 ` Yuan Fu
2024-11-29 8:04 ` Eli Zaretskii
2024-11-29 9:07 ` Yuan Fu
2024-11-29 12:02 ` Eli Zaretskii
2024-11-29 17:01 ` Stefan Monnier
2024-11-29 17:22 ` Ship Mints
2024-12-03 6:40 ` Yuan Fu
2024-12-03 13:14 ` Eli Zaretskii
2024-12-07 12:04 ` Define treesit-font-lock-level as buffer local Eli Zaretskii
2024-12-08 7:44 ` Yuan Fu
2024-12-14 11:14 ` Vincenzo Pupillo
2024-12-17 11:31 ` Vincenzo Pupillo [this message]
2024-12-17 21:37 ` 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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5719751.rdbgypaU67@3-191.divsi.unimi.it \
--to=v.pupillo@gmail.com \
--cc=casouri@gmail.com \
--cc=eliz@gnu.org \
--cc=emacs-devel@gnu.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 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).