unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Theodor Thornhill via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: "Jostein Kjønigsen" <jostein@secure.kjonigsen.net>
Cc: 59906@debbugs.gnu.org, casouri@gmail.com
Subject: bug#59906: 29.0.60; typescript-ts-mode is not highlighting escape sequences
Date: Thu, 08 Dec 2022 16:19:51 +0100	[thread overview]
Message-ID: <87cz8tdiso.fsf@thornhill.no> (raw)
In-Reply-To: <b5b92538-5fa5-3a8d-dbe8-e0a944d0bd6b@secure.kjonigsen.net> ("Jostein Kjønigsen"'s message of "Thu, 8 Dec 2022 16:04:05 +0100")

[-- Attachment #1: Type: text/plain, Size: 1333 bytes --]

Jostein Kjønigsen <jostein@secure.kjonigsen.net> writes:

> In a buffer with typescript-ts-mode activated, write the following code:
>
> const test = "quoted\"string\" contents";
>
> The entire text, include the \" is highlighted as strings, and escape sequences are not handled:
>
> This code has the following tree-sitter syntax tree:
>
>  (lexical_declaration kind: const
>   (variable_declarator name: (identifier) value: =
>    (string " (string_fragment) (escape_sequence) (string_fragment) (escape_sequence) (string_fragment) "))
>   ;)
>
> In typescript-ts-mode we seemingly have rules to handle fontification of escape sequences: 
>
>     :language language
>     :feature 'escape-sequence
>     :override t
>     '((escape_sequence) @font-lock-escape-face))
>
> This feature is however not activated in the major-mode setup: 
>
>      (setq-local treesit-font-lock-feature-list
>                  '((comment declaration)
>                    (keyword string)
>                    (constant expression identifier number pattern property)
>                    (bracket delimiter)))
>
> Naively I assumed that simply adding this feature would activate this rule, but still \" is fontified as string.

Yeah, there was an error there.  See below patch.

Yuan, can you install this?

Theo


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-escape-sequence-feature-in-typescript-ts-mode-bu.patch --]
[-- Type: text/x-diff, Size: 1592 bytes --]

From 1b0f2a181c38902804e323b064ab85cf84d88ff5 Mon Sep 17 00:00:00 2001
From: Theodor Thornhill <theo@thornhill.no>
Date: Thu, 8 Dec 2022 16:17:49 +0100
Subject: [PATCH] Fix escape-sequence feature in typescript-ts-mode (bug#59906)

* lisp/progmodes/typescript-ts-mode.el: (typescript-ts-mode,
tsx-ts-mode): Use escape-sequence feature.
---
 lisp/progmodes/typescript-ts-mode.el | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/lisp/progmodes/typescript-ts-mode.el b/lisp/progmodes/typescript-ts-mode.el
index a56568ae78..d5ca813e34 100644
--- a/lisp/progmodes/typescript-ts-mode.el
+++ b/lisp/progmodes/typescript-ts-mode.el
@@ -362,8 +362,7 @@ typescript-ts-mode
     (setq-local treesit-font-lock-settings
                 (typescript-ts-mode--font-lock-settings 'typescript))
     (setq-local treesit-font-lock-feature-list
-                '((comment declaration)
-                  (keyword string)
+                '((comment declaration keyword string escape-sequence)
                   (constant expression identifier number pattern property)
                   (bracket delimiter)))
 
@@ -397,8 +396,7 @@ tsx-ts-mode
     (setq-local treesit-font-lock-settings
                 (typescript-ts-mode--font-lock-settings 'tsx))
     (setq-local treesit-font-lock-feature-list
-                '((comment declaration)
-                  (keyword string)
+                '((comment declaration keyword string escape-sequence)
                   (constant expression identifier jsx number pattern property)
                   (bracket delimiter)))
 
-- 
2.34.1


  reply	other threads:[~2022-12-08 15:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-08 15:04 bug#59906: 29.0.60; typescript-ts-mode is not highlighting escape sequences Jostein Kjønigsen
2022-12-08 15:19 ` Theodor Thornhill via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2022-12-08 17:23   ` Jostein Kjønigsen
2022-12-09 20:41 ` Yuan Fu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87cz8tdiso.fsf@thornhill.no \
    --to=bug-gnu-emacs@gnu.org \
    --cc=59906@debbugs.gnu.org \
    --cc=casouri@gmail.com \
    --cc=jostein@secure.kjonigsen.net \
    --cc=theo@thornhill.no \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).