From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Eli Zaretskii Newsgroups: gmane.emacs.bugs Subject: bug#70478: 30.0.50; [PATCH] Fix treesitter-font-lock-settings for built-in functions and attributes. Date: Sat, 20 Apr 2024 09:13:48 +0300 Message-ID: <86le58a7dv.fsf@gnu.org> References: Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10317"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 70478@debbugs.gnu.org To: Prateek Sharma , Yuan Fu Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 20 08:15:06 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1ry40A-0002Th-L5 for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 20 Apr 2024 08:15:06 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ry3zx-0003ty-Up; Sat, 20 Apr 2024 02:14:53 -0400 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 1ry3zv-0003tY-OB for bug-gnu-emacs@gnu.org; Sat, 20 Apr 2024 02:14:51 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ry3zu-0003Rg-4i for bug-gnu-emacs@gnu.org; Sat, 20 Apr 2024 02:14:50 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ry408-0003JV-BT for bug-gnu-emacs@gnu.org; Sat, 20 Apr 2024 02:15:04 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 20 Apr 2024 06:15:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 70478 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: patch Original-Received: via spool by 70478-submit@debbugs.gnu.org id=B70478.171359365612394 (code B ref 70478); Sat, 20 Apr 2024 06:15:04 +0000 Original-Received: (at 70478) by debbugs.gnu.org; 20 Apr 2024 06:14:16 +0000 Original-Received: from localhost ([127.0.0.1]:34491 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ry3zK-0003DS-IE for submit@debbugs.gnu.org; Sat, 20 Apr 2024 02:14:15 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:56156) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ry3zG-0003CP-Qe for 70478@debbugs.gnu.org; Sat, 20 Apr 2024 02:14:12 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ry3yw-0003L8-TQ; Sat, 20 Apr 2024 02:13:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=References:Subject:In-Reply-To:To:From:Date: mime-version; bh=uRrKcIB6W4P53aDrkuhEImkVF5wzrf2qT9VfNNPBqQc=; b=ltRhcu7e8Fe8 xDM+rh/QExuGS7mUvXFmgU/7ZlydHtMLk6uDS84tP/YSqeXQw9EsDnKVsXpbkfWhASgVUkExFe9T9 WJjQXDhCBu28c9W6qZhatoynYBVOAQaYyZZUgI/GpfrwzLGksKdWX5Qp07NPudRh0C6GfAcvCZI+2 uI42eg6h7PUMeEgMIxBzQA7w6N3oiq+wnCZyyeAYhv/p4r+1x1JHrQrnP7cXIZFVkxbUBOgqLHa5x wPQS6hsFHd56JAzc/YZQBYMBdMD/sUAIVKuEUEtXiK9n32PM4Zns2WRaY5F/Zkm70C4hseA/ISt67 IKYqlUY2BIFnWF3IqY0ozQ==; In-Reply-To: (message from Prateek Sharma on Sat, 20 Apr 2024 02:30:17 +0530) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:283711 Archived-At: > From: Prateek Sharma > Date: Sat, 20 Apr 2024 02:30:17 +0530 > > I do a lot of programming in python and have noticed that if there is a > method of a class defined with the same name as a builtin function. It > gets highlighted with the face for builtin functions and it looks > different for all the other functions and confuses me sometimes and just > looks inconsistent. > > I have made a simple fix to the treesitter query and it seems to have > fixed the problem. > > Please share you thoughts on this fix. This is my first time > contributing to an open-source project and to emacs. Very excited to > hear from you guys!!! Thanks. Yuan, any comments? I have a few minor comments below. > diff --git a/etc/NEWS b/etc/NEWS > index 8ad1e78ca60..e5cd70b6106 100644 > --- a/etc/NEWS > +++ b/etc/NEWS > @@ -1319,6 +1319,15 @@ instead of: > This allows the user to specify command line arguments to the non > interactive Python interpreter specified by 'python-interpreter'. > > +*** Treesitter syntax highlighting for built-in functions fixed > +The fix highlights only the correct built-in function calls and > +attributes with font-lock-builtin-face. When some class defines > +a function with the same name as a built-in function, earlier it was > +being highlighted with the same font-lock-builtin-face, which was > +incorrect. Now, normal user defined functions will be highlighted > +with font-lock-function-call-face face and built-in functions and > +attributes will be highlighted with font-lock-builtin-face. This part is not needed, I think: we don't document bugfixes in NEWS. > + `((call function: (identifier) @font-lock-builtin-face > + (:match ,(rx-to-string `(seq bol (or ,@python--treesit-builtins) eol)) > + @font-lock-builtin-face)) > + (attribute attribute: (identifier) @font-lock-builtin-face > + (:match ,(rx-to-string `(seq bol (or ,@python--treesit-special-attributes) eol)) > + @font-lock-builtin-face))) Please reformat the whitespace here to avoid exceeding 80 columns in each individual line.