Subject: bug#59831: 29.0.60; typescript-ts-mode: Variables, properties & fields are often not fontified

From: Theodor Thornhill <[email-masked]>
Date: Wed, 07 Dec 2022 10:33:29 +0100

Jostein Kjønigsen <[email-masked]> writes:

> Hey everyone.
>
> I'd like to add one more change to this particular bug, which makes 
> fontification of variables more consistent when used in other 
> expressions and statements.
>
> Please see attached patch.
>
> In short this patch changes the following:
>
>   * fontifies property-access in general expressions
>   * fontifies variables and property-access in if-expressions
>
> --
> Jostein
>
> On 05.12.2022 21:13, Yuan Fu wrote:
>>
>>> On Dec 5, 2022, at 1:24 AM, Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors<[email-masked]>  wrote:
>>>
>>> Jostein Kjønigsen<[email-masked]>  writes:
>>>
>>>> Attached is another patch with some further improvements.
>>>>
>>>> These too OK with you, Theodor?
>>>>
>>> Yep!
>> I squashed the two commits and applied them, Thanks!
>>
>> Yuan
> From 0817a9a9ce00bf44e6368a3d74262f83e49ebbf3 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Jostein=20Kj=C3=B8nigsen?= <[email-masked]>
> Date: Wed, 7 Dec 2022 09:27:42 +0100
> Subject: [PATCH] lisp/progmodes/typescript-ts-mode.el: Improve fontification
>  of variables
>
> ---
>  lisp/progmodes/typescript-ts-mode.el | 43 +++++++++++++++++-----------
>  1 file changed, 27 insertions(+), 16 deletions(-)
>
> diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el
> index 3da690567e2..33f332d66d6 100644
> --- a/lisp/progmodes/typescript-ts-mode.el
> +++ b/lisp/progmodes/typescript-ts-mode.el
> @@ -220,7 +220,32 @@ typescript-ts-mode--font-lock-settings
>       (binary_expression left: (identifier) @font-lock-variable-name-face)
>       (binary_expression right: (identifier) @font-lock-variable-name-face)
>  
> -     (arguments (identifier) @font-lock-variable-name-face))
> +     (arguments (identifier) @font-lock-variable-name-face)
> +
> +     (parenthesized_expression (identifier) @font-lock-variable-name-face))
> +
> +   :language language
> +   :override t
> +   :feature 'property
> +   `((property_signature
> +      name: (property_identifier) @font-lock-property-face)
> +     (public_field_definition
> +      name: (property_identifier) @font-lock-property-face)
> +     (member_expression
> +      object: (identifier) @font-lock-variable-name-face
> +      property: (_) @font-lock-property-face)
> +     (member_expression
> +      object: (this) @font-lock-keyword-face

Do we need this (this) here, or could that just go into the keyword feature?

Otherwise LGTM.  Go ahead and install, Yuan, unless you have something
else to add :-)

Theo