Subject: Re: bug#73877: 30; rust-ts-mode: highlight the possible type suffix of number literals

From: Eli Zaretskii <[email-masked]>
Date: Sat, 02 Nov 2024 13:01:20 +0200

> Cc: "[email-masked]" <[email-masked]>,
>  Stefan Kangas <[email-masked]>
> From: Christophe TROESTLER <[email-masked]>
> Date: Mon, 28 Oct 2024 21:56:52 +0000
> 
> Here is an updated patch that (hopefully) addresses all of your remarks except the last one: when executing the tests interactively in the instance of Emacs one works with, it is good IMHO that global variables are not changed under our feet.  That being said, it is not a strong opinion and I can remove the reset if you wish.

Thanks, a few more nits to be fixed:

> * lisp/progmodes/rust-ts-mode.el (rust-ts-mode--fontify-number-literal):
> perform the improved fontification of numbers.

The description should start with a capital letter.

Also, please mention the bug number somewhere in the log message.

> +---
> +*** New user option 'rust-ts-mode-fontify-number-suffix-as-type'.
> +Rust number literals may have an optional type suffix.  When this option
> +is non-nil, this suffix is fontified as a type.
                                        ^^^^^^^^^
I think "using the 'font-lock-type-face'" is a more clear description
than "as a type".

> +(defcustom rust-ts-mode-fontify-number-suffix-as-type nil
> +  "If non-nil, fontify the optional type suffix of number literals with
> +`font-lock-type-face' instead of `font-lock-number-face'."

The first line of a doc string should be a single complete sentence.
So please make it a summary of what this option does, and describe the
details in the subsequent sentences.

> +(defconst rust-ts-mode--number-types
> +  (regexp-opt '("u8" "i8" "u16" "i16" "u32" "i32" "u64"
> +                "i64" "u128" "i128" "usize" "isize" "f32" "f64"))
> +  "Regexp that matches any suffix on number literals as documented
> +at https://doc.rust-lang.org/reference/tokens.html#suffixes.")

Same here.

> +(defun rust-ts-mode--fontify-number-literal (node override start stop &rest _)
> +  "Fontify number literals, highlighting the optional suffix as a type
> +based on the value of `rust-ts-mode-highlight-number-literal-type'."

And here.