GNU bug report logs - #70464
[PATCH] Add font-locking for Rust macro variables

Previous Next

Package: emacs;

Reported by: Noah Peart <noah.v.peart <at> gmail.com>

Date: Fri, 19 Apr 2024 01:44:01 UTC

Severity: normal

Tags: patch

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

To reply to this bug, email your comments to 70464 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#70464; Package emacs. (Fri, 19 Apr 2024 01:44:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Noah Peart <noah.v.peart <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 19 Apr 2024 01:44:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Noah Peart <noah.v.peart <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: [PATCH] Add font-locking for Rust macro variables
Date: Thu, 18 Apr 2024 18:42:36 -0700
[Message part 1 (text/plain, inline)]
Tags: patch


Adds some tree-sitter font-locking rules in rust-ts-mode to fontify
meta variables, their types, and repetition operators in macros.

These rules add new font-locking as indicated in the following
snippet:

    macro_rules! unsafe_raw_call {
        ($env:expr, $name:ident $(, $args:expr)*) => {
//          ^ font-lock-variable-name-face
//                  ^ font-lock-type-face
//                                              ^ font-lock-operator-face
//                                                                     ^
font-lock-operator-face
            {
                let env = $env;
//                                ^ font-lock-variable-use-face
                let result = unsafe {
                    let $name = raw_fn!(env, $name);
                    $name(env.raw $(, $args)*)
                };
                env.handle_exit(result)
            }
        };
    }

I also removed the last occurrence of the following duplicated rule from
the `type` feature:
    (type_identifier) @font-lock-type-face

In GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
3.24.33, cairo version 1.16.0) of 2024-04-18 built on noah-X580VD
Repository revision: 0a57dfcff8d0abcf4427cfbfd886264bb3b8eaab
Repository branch: master
Windowing system distributor 'The X.Org Foundation', version 11.0.12101004
System Description: Ubuntu 22.04.4 LTS

Configured using:
 'configure --prefix=/usr/local --with-modules --with-tree-sitter
--with-threads --with-x-toolkit=gtk3 --with-xwidgets --with-gnutls
--with-json --with-mailutils --with-jpeg --with-png --with-rsvg
--with-tiff --with-xml2 --with-xpm --with-imagemagick CC=gcc-12
CXX=gcc-12'
[Message part 2 (text/html, inline)]
[0001-Add-font-locking-for-Rust-macros.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70464; Package emacs. (Fri, 19 Apr 2024 07:42:03 GMT) Full text and rfc822 format available.

Message #8 received at 70464 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Noah Peart <noah.v.peart <at> gmail.com>
Cc: 70464 <at> debbugs.gnu.org
Subject: Re: bug#70464: [PATCH] Add font-locking for Rust macro variables
Date: Fri, 19 Apr 2024 00:41:01 -0700
Noah Peart <noah.v.peart <at> gmail.com> writes:

> Tags: patch
>
> Adds some tree-sitter font-locking rules in rust-ts-mode to fontify
> meta variables, their types, and repetition operators in macros.
>
> These rules add new font-locking as indicated in the following
> snippet:
>
>     macro_rules! unsafe_raw_call {
>         ($env:expr, $name:ident $(, $args:expr)*) => {
> //          ^ font-lock-variable-name-face
> //                  ^ font-lock-type-face
> //                                              ^ font-lock-operator-face
> //                                                                     ^ font-lock-operator-face
>             {
>                 let env = $env;
> //                                ^ font-lock-variable-use-face
>                 let result = unsafe {
>                     let $name = raw_fn!(env, $name);
>                     $name(env.raw $(, $args)*)
>                 };
>                 env.handle_exit(result)
>             }
>         };
>     }
>
> I also removed the last occurrence of the following duplicated rule from the `type` feature:
>     (type_identifier) @font-lock-type-face
>

Great! Thanks! I’ll merge this in some time once I figure out whether
should we apply it to emacs-29 or master.

Meanwhile, it seems that you’ve recently working on tree-sitter modes.
If you’re interested, maybe you can take a look at ert-font-lock, and
add some tests that cover the bugs your patches fixes? This is
completely optional, of course. I bought it up because I think you might
be interested.

Yuan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70464; Package emacs. (Fri, 19 Apr 2024 08:03:04 GMT) Full text and rfc822 format available.

Message #11 received at 70464 <at> debbugs.gnu.org (full text, mbox):

From: Vladimir Kazanov <vekazanov <at> gmail.com>
To: Yuan Fu <casouri <at> gmail.com>
Cc: Noah Peart <noah.v.peart <at> gmail.com>, 70464 <at> debbugs.gnu.org
Subject: Re: bug#70464: [PATCH] Add font-locking for Rust macro variables
Date: Fri, 19 Apr 2024 09:02:02 +0100
Noah,

...and if you decide to add ert-font-lock tests and something is not
working as expected - let me know, happy to fix or extend
ert-font-lock.

Thanks!

On Fri, 19 Apr 2024 at 08:42, Yuan Fu <casouri <at> gmail.com> wrote:
>
>
> Noah Peart <noah.v.peart <at> gmail.com> writes:
>
> > Tags: patch
> >
> > Adds some tree-sitter font-locking rules in rust-ts-mode to fontify
> > meta variables, their types, and repetition operators in macros.
> >
> > These rules add new font-locking as indicated in the following
> > snippet:
> >
> >     macro_rules! unsafe_raw_call {
> >         ($env:expr, $name:ident $(, $args:expr)*) => {
> > //          ^ font-lock-variable-name-face
> > //                  ^ font-lock-type-face
> > //                                              ^ font-lock-operator-face
> > //                                                                     ^ font-lock-operator-face
> >             {
> >                 let env = $env;
> > //                                ^ font-lock-variable-use-face
> >                 let result = unsafe {
> >                     let $name = raw_fn!(env, $name);
> >                     $name(env.raw $(, $args)*)
> >                 };
> >                 env.handle_exit(result)
> >             }
> >         };
> >     }
> >
> > I also removed the last occurrence of the following duplicated rule from the `type` feature:
> >     (type_identifier) @font-lock-type-face
> >
>
> Great! Thanks! I’ll merge this in some time once I figure out whether
> should we apply it to emacs-29 or master.
>
> Meanwhile, it seems that you’ve recently working on tree-sitter modes.
> If you’re interested, maybe you can take a look at ert-font-lock, and
> add some tests that cover the bugs your patches fixes? This is
> completely optional, of course. I bought it up because I think you might
> be interested.
>
> Yuan
>
>
>


-- 
Regards,

Vladimir Kazanov




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70464; Package emacs. (Fri, 19 Apr 2024 16:46:05 GMT) Full text and rfc822 format available.

Message #14 received at 70464 <at> debbugs.gnu.org (full text, mbox):

From: Noah Peart <noah.v.peart <at> gmail.com>
To: Vladimir Kazanov <vekazanov <at> gmail.com>
Cc: Yuan Fu <casouri <at> gmail.com>, 70464 <at> debbugs.gnu.org
Subject: Re: bug#70464: [PATCH] Add font-locking for Rust macro variables
Date: Fri, 19 Apr 2024 09:44:26 -0700
[Message part 1 (text/plain, inline)]
Sounds good!

> If you’re interested, maybe you can take a look at ert-font-lock, and
add some tests that cover the bugs your patches fixes?

Sure thing, Ill look into that.

On Fri, Apr 19, 2024 at 1:02 AM Vladimir Kazanov <vekazanov <at> gmail.com>
wrote:

> Noah,
>
> ...and if you decide to add ert-font-lock tests and something is not
> working as expected - let me know, happy to fix or extend
> ert-font-lock.
>
> Thanks!
>
> On Fri, 19 Apr 2024 at 08:42, Yuan Fu <casouri <at> gmail.com> wrote:
> >
> >
> > Noah Peart <noah.v.peart <at> gmail.com> writes:
> >
> > > Tags: patch
> > >
> > > Adds some tree-sitter font-locking rules in rust-ts-mode to fontify
> > > meta variables, their types, and repetition operators in macros.
> > >
> > > These rules add new font-locking as indicated in the following
> > > snippet:
> > >
> > >     macro_rules! unsafe_raw_call {
> > >         ($env:expr, $name:ident $(, $args:expr)*) => {
> > > //          ^ font-lock-variable-name-face
> > > //                  ^ font-lock-type-face
> > > //                                              ^
> font-lock-operator-face
> > > //
>  ^ font-lock-operator-face
> > >             {
> > >                 let env = $env;
> > > //                                ^ font-lock-variable-use-face
> > >                 let result = unsafe {
> > >                     let $name = raw_fn!(env, $name);
> > >                     $name(env.raw $(, $args)*)
> > >                 };
> > >                 env.handle_exit(result)
> > >             }
> > >         };
> > >     }
> > >
> > > I also removed the last occurrence of the following duplicated rule
> from the `type` feature:
> > >     (type_identifier) @font-lock-type-face
> > >
> >
> > Great! Thanks! I’ll merge this in some time once I figure out whether
> > should we apply it to emacs-29 or master.
> >
> > Meanwhile, it seems that you’ve recently working on tree-sitter modes.
> > If you’re interested, maybe you can take a look at ert-font-lock, and
> > add some tests that cover the bugs your patches fixes? This is
> > completely optional, of course. I bought it up because I think you might
> > be interested.
> >
> > Yuan
> >
> >
> >
>
>
> --
> Regards,
>
> Vladimir Kazanov
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#70464; Package emacs. (Fri, 19 Apr 2024 17:39:02 GMT) Full text and rfc822 format available.

Message #17 received at 70464 <at> debbugs.gnu.org (full text, mbox):

From: Noah Peart <noah.v.peart <at> gmail.com>
To: Vladimir Kazanov <vekazanov <at> gmail.com>
Cc: Yuan Fu <casouri <at> gmail.com>, 70464 <at> debbugs.gnu.org
Subject: Re: bug#70464: [PATCH] Add font-locking for Rust macro variables
Date: Fri, 19 Apr 2024 10:38:07 -0700
[Message part 1 (text/plain, inline)]
I've attached a patch with font-locking tests for the recent additions
in (bug#70464) and (bug#70465).  So, it will fail without those being
merged.

Thanks!

On Fri, Apr 19, 2024 at 9:44 AM Noah Peart <noah.v.peart <at> gmail.com> wrote:

> Sounds good!
>
> > If you’re interested, maybe you can take a look at ert-font-lock, and
> add some tests that cover the bugs your patches fixes?
>
> Sure thing, Ill look into that.
>
> On Fri, Apr 19, 2024 at 1:02 AM Vladimir Kazanov <vekazanov <at> gmail.com>
> wrote:
>
>> Noah,
>>
>> ...and if you decide to add ert-font-lock tests and something is not
>> working as expected - let me know, happy to fix or extend
>> ert-font-lock.
>>
>> Thanks!
>>
>> On Fri, 19 Apr 2024 at 08:42, Yuan Fu <casouri <at> gmail.com> wrote:
>> >
>> >
>> > Noah Peart <noah.v.peart <at> gmail.com> writes:
>> >
>> > > Tags: patch
>> > >
>> > > Adds some tree-sitter font-locking rules in rust-ts-mode to fontify
>> > > meta variables, their types, and repetition operators in macros.
>> > >
>> > > These rules add new font-locking as indicated in the following
>> > > snippet:
>> > >
>> > >     macro_rules! unsafe_raw_call {
>> > >         ($env:expr, $name:ident $(, $args:expr)*) => {
>> > > //          ^ font-lock-variable-name-face
>> > > //                  ^ font-lock-type-face
>> > > //                                              ^
>> font-lock-operator-face
>> > > //
>>  ^ font-lock-operator-face
>> > >             {
>> > >                 let env = $env;
>> > > //                                ^ font-lock-variable-use-face
>> > >                 let result = unsafe {
>> > >                     let $name = raw_fn!(env, $name);
>> > >                     $name(env.raw $(, $args)*)
>> > >                 };
>> > >                 env.handle_exit(result)
>> > >             }
>> > >         };
>> > >     }
>> > >
>> > > I also removed the last occurrence of the following duplicated rule
>> from the `type` feature:
>> > >     (type_identifier) @font-lock-type-face
>> > >
>> >
>> > Great! Thanks! I’ll merge this in some time once I figure out whether
>> > should we apply it to emacs-29 or master.
>> >
>> > Meanwhile, it seems that you’ve recently working on tree-sitter modes.
>> > If you’re interested, maybe you can take a look at ert-font-lock, and
>> > add some tests that cover the bugs your patches fixes? This is
>> > completely optional, of course. I bought it up because I think you might
>> > be interested.
>> >
>> > Yuan
>> >
>> >
>> >
>>
>>
>> --
>> Regards,
>>
>> Vladimir Kazanov
>>
>
[Message part 2 (text/html, inline)]
[0001-Add-rust-ts-mode-font-locking-tests.patch (text/x-patch, attachment)]

Reply sent to Yuan Fu <casouri <at> gmail.com>:
You have taken responsibility. (Mon, 22 Apr 2024 05:02:01 GMT) Full text and rfc822 format available.

Notification sent to Noah Peart <noah.v.peart <at> gmail.com>:
bug acknowledged by developer. (Mon, 22 Apr 2024 05:02:01 GMT) Full text and rfc822 format available.

Message #22 received at 70464-done <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Noah Peart <noah.v.peart <at> gmail.com>
Cc: Vladimir Kazanov <vekazanov <at> gmail.com>, 70464-done <at> debbugs.gnu.org
Subject: Re: bug#70464: [PATCH] Add font-locking for Rust macro variables
Date: Sun, 21 Apr 2024 22:00:40 -0700

> On Apr 19, 2024, at 10:38 AM, Noah Peart <noah.v.peart <at> gmail.com> wrote:
> 
> I've attached a patch with font-locking tests for the recent additions
> in (bug#70464) and (bug#70465).  So, it will fail without those being
> merged.
> 
> Thanks!

This is great! Thanks a ton!! I’ve applied both patches, and they work brilliantly, thanks to you both, Noah and Vladimir!

Yuan





This bug report was last modified 12 days ago.

Previous Next


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