GNU bug report logs - #70478
30.0.50; [PATCH] Fix treesitter-font-lock-settings for built-in functions and attributes.

Previous Next

Package: emacs;

Reported by: Prateek Sharma <ps.prateek.sharma143 <at> gmail.com>

Date: Fri, 19 Apr 2024 23:06:33 UTC

Severity: normal

Tags: patch

Found in version 30.0.50

Fixed in version 30.1

Done: Yuan Fu <casouri <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Eli Zaretskii <eliz <at> gnu.org>
To: Prateek Sharma <ps.prateek.sharma143 <at> gmail.com>, Yuan Fu <casouri <at> gmail.com>
Cc: 70478 <at> debbugs.gnu.org
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
> From: Prateek Sharma <ps.prateek.sharma143 <at> gmail.com>
> 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.




This bug report was last modified 1 year and 88 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.