>From dbe998506f9052455d3499638930418832f5c243 Mon Sep 17 00:00:00 2001 From: Theodor Thornhill Date: Mon, 17 Oct 2022 08:29:39 +0200 Subject: [PATCH] Add correct ordering in template_substitution We want to override the template substitution contents with no coloring, because we need the font-lock-string-face not to bleed into the substitutions. The correct ordering of these forms are important. * lisp/progmodes/js.el (js--treesit-settings): Move template string related queries to top, and use the correct ordering. * lisp/progmodes/ts-mode.el (ts-mode--settings): Move template string related queries to top, and use the correct ordering. --- lisp/progmodes/js.el | 12 ++++++++---- lisp/progmodes/ts-mode.el | 10 +++++++--- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lisp/progmodes/js.el b/lisp/progmodes/js.el index 18499a466a..0cf106f482 100644 --- a/lisp/progmodes/js.el +++ b/lisp/progmodes/js.el @@ -3461,8 +3461,14 @@ js--treesit-settings :language 'javascript :feature 'basic :override t - `(;; Everything overrides template string. + `( + ;; The order of these are important. We want to keep coloring in + ;; the string, but not in the substitution, thus delegating the + ;; contents of that substitution to the usual rules (template_string) @font-lock-string-face + (template_substitution) @default ; Color everything white + (template_substitution + ["${" "}"] @font-lock-builtin-face) ((identifier) @font-lock-constant-face (:match "^[A-Z_][A-Z_\\d]*$" @font-lock-constant-face)) @@ -3559,9 +3565,7 @@ js--treesit-settings (string) @font-lock-string-face (comment) @font-lock-comment-face - [,@js--treesit-keywords] @font-lock-keyword-face - - (template_substitution ["${" "}"] @font-lock-constant-face)))) + [,@js--treesit-keywords] @font-lock-keyword-face))) (defun js-treesit-current-defun () diff --git a/lisp/progmodes/ts-mode.el b/lisp/progmodes/ts-mode.el index 10d4b7bd18..5a8f7da30a 100644 --- a/lisp/progmodes/ts-mode.el +++ b/lisp/progmodes/ts-mode.el @@ -110,7 +110,14 @@ ts-mode--settings :override t :feature 'basic '( + ;; The order of these are important. We want to keep coloring in + ;; the string, but not in the substitution, thus delegating the + ;; contents of that substitution to the usual rules (template_string) @font-lock-string-face + (template_substitution) @default ; Color everything white + (template_substitution + ["${" "}"] @font-lock-builtin-face) + ((identifier) @font-lock-constant-face (:match "^[A-Z_][A-Z_\\d]*$" @font-lock-constant-face)) @@ -225,9 +232,6 @@ ts-mode--settings (string) @font-lock-string-face (template_string) @font-lock-string-face - (template_substitution - ["${" "}"] @font-lock-constant-face) - ["!" "abstract" "as" -- 2.34.1