From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Vincenzo Pupillo Newsgroups: gmane.emacs.devel Subject: Re: Define treesit-font-lock-level as buffer local Date: Tue, 17 Dec 2024 12:31:21 +0100 Message-ID: <5719751.rdbgypaU67@3-191.divsi.unimi.it> References: <4929184.OV4Wx5bFTl@3-191.divsi.unimi.it> <2528408.XAFRqVoOGU@fedora> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="nextPart3585313.LZWGnKmheA" Content-Transfer-Encoding: 7Bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="35613"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Eli Zaretskii , Yuan Fu Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Dec 17 12:32:55 2024 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1tNVot-00093h-JP for ged-emacs-devel@m.gmane-mx.org; Tue, 17 Dec 2024 12:32:55 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tNVnV-0002SC-Kc; Tue, 17 Dec 2024 06:31:29 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tNVnU-0002Rr-I0 for emacs-devel@gnu.org; Tue, 17 Dec 2024 06:31:28 -0500 Original-Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1tNVnS-00087x-Tk; Tue, 17 Dec 2024 06:31:28 -0500 Original-Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-432d86a3085so34394005e9.2; Tue, 17 Dec 2024 03:31:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1734435083; x=1735039883; darn=gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=3nKYvPBEv8wIt4viuyNqHbupyl8HXHpFesfc/BO8b5Y=; b=GjmnUgaiPIYifqyoULAk/4UqQOPa07PFP1Gnpj+Tcp0aRvRSNm6SaE/ne5KYRa5Mc+ ZpgvI+/iIFBRsc6wGcwascwSme9sT7kHpelGW773IK3hK7SzRq9QQ3Ikd0YuzVInd8If KRrpl4qGjas5MStykvDwhTsZaY5tLq3oyRwFhymAHVe/0vztpk1qYG2Ld35ilprU7j7t KUHPjh/XlVNOUzjScBkqTqGo+iSUJcFvXZkDNoKYu5MjkVv7+HvG3+MvdGk76z22DHDk Twf1RGUErZBHRQawKv/eJwQETGLAuYMT2UGJfAs2YnquA3hzOdvIHNZKHvxE/tTRd1l9 qDNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1734435083; x=1735039883; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3nKYvPBEv8wIt4viuyNqHbupyl8HXHpFesfc/BO8b5Y=; b=Hqj5Gt9J66HyXvkmEl/yVqf0It5x9pg7jzpHuyBlXHfhCkSc1MuJ6vcw69h9/ctXUN zztE5aGTP/kb0Ppl8XLD4ogRInVj0jNh0fHds5tu1uTJUcZXeEiR4BIgJw4s5RNQtXSV QKUGf41bBUcYrQ7zLd9ep7wsFtnwYwn22s5jXv/F1QCCIW48UoI57UZOj0Ml6jh79s/c N+CQhMFIu8CT5TV5DE6D+pI83X2DPSoFM+H4kZUeOtyQ70VKAElljivru3Gh8VHKkxlf QpJ5yRlxephD6U7SYW0DHX2nEQLoB1b53kGKiD1FbdhWdOw1y2ptYAK0+V2IpJNv9ulV FLdw== X-Gm-Message-State: AOJu0YxEgk2gq09NELLrAApiHwEqXFmYfhjcmeeiJiLNBeiRI+pkiCf5 svjmqlve409fhd0wOoGUDgToPN9IWxCMkNGWas8zRK7mGzOeRxT86Ok6jg== X-Gm-Gg: ASbGnct6jtYX/dPt20Nu0NWTJ9/qg03XWp98L30YcF+wXY/6iHL/vdwmuXAJ3P6InHd G4ZS6Rwe7vmPOgKmLQkDHhmL0Tk4rojobpN7x5m7QleAOO/VdwpuCX1erNezpZ+FGYF4bbqvifp rdBTeAYFPzpM6lQlkDjA2RGmiqNDmSokqRse+lXEb8I8hvEcl31dxXD5M3cutPi4zHy2IzNA5Fv 58QcAg4xS/b4201FRgYEdhLIbhkzqy0XP6Gh0ExLvLHiaBbgZFVt/YJ9OM6FqCWF0XBqNkQehDc 6u4Am19Ikw== X-Google-Smtp-Source: AGHT+IG99Ia+aqNMUy+YH2IM4htUU4KNRzcGIDY6QdJuHLcyHmcdj/FN299/BQAdQEBKPAkVF/2OJg== X-Received: by 2002:a05:600c:871b:b0:434:fddf:5c13 with SMTP id 5b1f17b1804b1-4362aa2ea38mr153389935e9.14.1734435082645; Tue, 17 Dec 2024 03:31:22 -0800 (PST) Original-Received: from 3-191.divsi.unimi.it (3-191.divsi.unimi.it. [159.149.3.191]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-43625550563sm169652145e9.4.2024.12.17.03.31.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Dec 2024 03:31:22 -0800 (PST) In-Reply-To: <2528408.XAFRqVoOGU@fedora> Received-SPF: pass client-ip=2a00:1450:4864:20::333; envelope-from=v.pupillo@gmail.com; helo=mail-wm1-x333.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:326585 Archived-At: This is a multi-part message in MIME format. --nextPart3585313.LZWGnKmheA Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Ciao Yuan, I found a bug in python-ts-mode, it does not handle treesit-font-lock-level= =20 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=E2=80=99Europa c= entrale,=20 Vincenzo Pupillo ha scritto: > In data domenica 8 dicembre 2024 08:44:25 Ora standard dell=E2=80=99Europ= a 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 us= ed > > c-ts-mode in the example in the docstring since I don=E2=80=99t want to= complicate > > it. The change is pushed to master. > >=20 > > Yuan >=20 > Thank you Yuan! >=20 > Vincenzo --nextPart3585313.LZWGnKmheA Content-Disposition: attachment; filename="0001-python-ts-mode-now-handles-the-treesit-font-lock-lev.patch" Content-Transfer-Encoding: 7Bit Content-Type: text/x-patch; charset="UTF-8"; name="0001-python-ts-mode-now-handles-the-treesit-font-lock-lev.patch" >From ec63146bfcb54c78af7fac3cb0791b94cb1a43ca Mon Sep 17 00:00:00 2001 From: Vincenzo Pupillo 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 --nextPart3585313.LZWGnKmheA--