From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Prateek Sharma 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 12:25:24 +0530 Message-ID: References: <86le58a7dv.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000e8bd5d061681b0a7" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3685"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Yuan Fu , 70478@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Apr 20 08:56:02 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 1ry4dl-0000jT-FJ for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 20 Apr 2024 08:56:02 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ry4de-00075z-Qy; Sat, 20 Apr 2024 02:55:54 -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 1ry4dX-00075L-Su for bug-gnu-emacs@gnu.org; Sat, 20 Apr 2024 02:55:49 -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 1ry4dX-0004fw-Kj for bug-gnu-emacs@gnu.org; Sat, 20 Apr 2024 02:55:47 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1ry4dm-00083B-51 for bug-gnu-emacs@gnu.org; Sat, 20 Apr 2024 02:56:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Prateek Sharma Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 20 Apr 2024 06:56:02 +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.171359616130939 (code B ref 70478); Sat, 20 Apr 2024 06:56:02 +0000 Original-Received: (at 70478) by debbugs.gnu.org; 20 Apr 2024 06:56:01 +0000 Original-Received: from localhost ([127.0.0.1]:34668 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ry4di-00082b-30 for submit@debbugs.gnu.org; Sat, 20 Apr 2024 02:56:01 -0400 Original-Received: from mail-vk1-xa29.google.com ([2607:f8b0:4864:20::a29]:56431) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ry4df-000813-3U for 70478@debbugs.gnu.org; Sat, 20 Apr 2024 02:55:56 -0400 Original-Received: by mail-vk1-xa29.google.com with SMTP id 71dfb90a1353d-4dae8b2d29bso698100e0c.0 for <70478@debbugs.gnu.org>; Fri, 19 Apr 2024 23:55:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713596135; x=1714200935; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=4cQ6nTDSKI02SzkFAO/Jep7zIA4MHEn/lihlPqfynf4=; b=lrk4oAyRNYXktTfUp6sVty0QOzpwauTfQKwTE66UHu/kN2OkRHSWY8OQlnDZaw6zsf pn+hGeeKqfie+5cgRBFeLf5s1B5SlhUMkQM0wrq5vssXgpm4AxS74X5H/Di7QV6SS3kt 3hEE3yKd+owzJ3u1geIBPHYMZebppG1rtg74xvdvQMQXBD/8O2E/nhBqevSwAV/Ed7Ah vE4Dq1j2PNuQFaRC4+SSGk+kowqRyF5c0pB/imnC06I5S8rDar3Qi1dkuWsJonZZaWos IH1QgN0YTN8ioeLqz180dqryEAXNxxIRnonIlbC55bo4rHzwZwwFid2+lZuBJ2j0+sRt cNDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713596135; x=1714200935; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4cQ6nTDSKI02SzkFAO/Jep7zIA4MHEn/lihlPqfynf4=; b=WUup9F8s2gScuhwFegKRn9lskjFMiuowK98FpL0Ht3fYJ6N7Mk3oSUTAxVcYJ5q1mR 16zz8W6RGtt8202sMGVoDKXfCp4rG7LT6mNK6K/AZqA1Lqw5Dt7rFF5xvSD9Jf9r1hJo YeE143w/DEntBe8Upcb4kZVXZbHsJnA7v5/5dCYnZDlKeGH5cLzh7IbjwgU+X/4kvKgC QMFzAl8BPLOulkrj4P/iTGvsBEdlGWEhKcwUYnZ7RiqmY4fajcOvJqZwgYfOL6ZtnqYA 4eOO/ZIbh84kWFKoe052nCD3QieUoECh9JGyrjPg9GfzjyHb6udLslpsSYZ4qNTyW+RG jleQ== X-Forwarded-Encrypted: i=1; AJvYcCVt1k7dAwP0UbGJEWAw2pqrZVE97TzglacJxYELMR8QX5OBvJjwCo9/McPQpEfI4bo0PFUJ/Nm/BvO8nWUkxaCAVLinjpI= X-Gm-Message-State: AOJu0YxMaZImNc9sUWBnIU17KlrAiCqz5iB2k0xhZKe49hXEDjJ060XS CcxLLqWpsXamvRE7iSJTvIrzs9qt33udj9RZ2QgYKK8CMpaBuf1RvZ5jlnX2gD/aSn1+3ghNHnp 6vTybY0C+p1k/tUuYd48PooCyVxc= X-Google-Smtp-Source: AGHT+IH4g0NfIdpmKSCeLDjiPAnLuIictsuuQiQk17wjFOpPoJsp6aR/IR0f26tUeqCDhzxKjpZfnQqMt3ziaNC0fuQ= X-Received: by 2002:a05:6122:32d4:b0:4c0:24e6:f49d with SMTP id ck20-20020a05612232d400b004c024e6f49dmr5037711vkb.1.1713596134897; Fri, 19 Apr 2024 23:55:34 -0700 (PDT) In-Reply-To: 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:283714 Archived-At: --000000000000e8bd5d061681b0a7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Also should I squash the changes of both the above commits into one and then create a patch file? On Sat, Apr 20, 2024 at 12:24=E2=80=AFPM Prateek Sharma < ps.prateek.sharma143@gmail.com> wrote: > Hey, Thanks for reviewing my changes. > > Here is the patch for reformatted version of the above fix. I've also > removed the announcement in the NEWS file. > > On Sat, Apr 20, 2024 at 11:43=E2=80=AFAM Eli Zaretskii wro= te: > >> > 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 ju= st >> > 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. >> > --000000000000e8bd5d061681b0a7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Also should I squash the changes of both the above commits= into one and then create a patch file?

On Sat, Apr 20, 2024 at 12:24=E2=80= =AFPM Prateek Sharma <= ps.prateek.sharma143@gmail.com> wrote:
Hey, Thanks for reviewing my= changes.

Here is the patch for reformatted=C2=A0version= of the above fix. I've also removed the announcement in the NEWS file.=

On Sat, Apr 20, 2024 at 11:43=E2=80=AFAM Eli Zaretskii <eliz@gnu.org> wrote:
> From: Prateek Shar= ma <= ps.prateek.sharma143@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 ju= st
> looks inconsistent.
>
> I have made a simple fix to the treesitter query and it seems to have<= br> > 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.=C2=A0 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:
>=C2=A0 This allows the user to specify command line arguments to the no= n
>=C2=A0 interactive Python interpreter specified by 'python-interpre= ter'.
>=C2=A0
> +*** 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<= br> > +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.
> +=C2=A0 =C2=A0`((call function: (identifier) @font-lock-builtin-face > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(:match ,(rx-to-string `(seq= bol (or ,@python--treesit-builtins) eol))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= @font-lock-builtin-face))
> +=C2=A0 =C2=A0 =C2=A0(attribute attribute: (identifier) @font-lock-bui= ltin-face
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (:match ,(rx-= to-string `(seq bol (or ,@python--treesit-special-attributes) eol))
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 @font-lock-builtin-face)))

Please reformat the whitespace here to avoid exceeding 80 columns in
each individual line.
--000000000000e8bd5d061681b0a7--