branch: externals/matlab-mode
commit f4022c6e4481ce4d330bf321dacb674afb84cabb
Author: John Ciolfi <[email protected]>
Commit: John Ciolfi <[email protected]>

    matlab-ts-mode: font-lock string escapes sequences
---
 matlab-ts-mode.el                                         | 15 ++++++++++-----
 .../{strings_test.m => font_lock_strings.m}               |  2 +-
 ...s_test_expected.txt => font_lock_strings_expected.txt} |  2 +-
 tests/test-matlab-ts-mode-font-lock.el                    |  1 +
 4 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/matlab-ts-mode.el b/matlab-ts-mode.el
index be45df55bf..ae90f4560a 100644
--- a/matlab-ts-mode.el
+++ b/matlab-ts-mode.el
@@ -542,6 +542,12 @@ than the COMMENT-NODE start-point and end-point."
      ((string_content) ["\"" "'"]) @matlab-ts-mode-string-delimiter-face
      (string ["\"" "'"] @matlab-ts-mode-string-delimiter-face))
 
+   ;; F-Rule: escape sequences in strings e.g. \n as in "One\nTwo"
+   ;; See: ./tests/test-matlab-ts-mode-font-lock-files/font_lock_strings.m
+   :language 'matlab
+   :feature 'escape-sequence
+   '((escape_sequence) @font-lock-escape-face)
+
    ;; F-rule: operators: *, /, +, -, etc.
    ;; Note, this rule must come after the string rule because single quote (') 
can be a transpose or
    ;; string delimiter
@@ -1153,9 +1159,9 @@ is t, add the following to an Init File (e.g. 
`user-init-file' or
     (setq-local treesit-font-lock-level matlab-ts-mode-font-lock-level)
     (setq-local treesit-font-lock-settings matlab-ts-mode--font-lock-settings)
     (setq-local treesit-font-lock-feature-list
-                '((comment comment-special comment-marker definition builtins)
-                  (keyword operator string type variable command-name 
command-arg)
-                  (number bracket delimiter)
+                '((comment comment-special comment-marker definition)
+                  (keyword operator string escape-sequence type command-name 
command-arg)
+                  (variable builtins number bracket delimiter)
                   (syntax-error)))
 
     ;; Indent. See: ./tests/test-matlab-ts-mode-indent.el
@@ -1193,13 +1199,12 @@ is t, add the following to an Init File (e.g. 
`user-init-file' or
     ;; Electric pair mode. See tests/test-matlab-ts-mode-electric-pair.el
     (setq-local electric-pair-inhibit-predicate 
#'matlab-ts-mode--electric-pair-inhibit-predicate)
 
+    ;; TODO For font-lock reference tests
     ;; TODO Highlight parens OR if/end type blocks
     ;; TODO face for all built-in functions such as dbstop, quit, sin, etc.
     ;;   - maintenance/genBuiltinsHashTable.m
     ;;     Add namespaces
     ;;     
https://stackoverflow.com/questions/51942464/programmatically-return-a-list-of-all-functions/51946257
-    ;; TODO font-lock string escape sequences
-    ;;      'foo\nbar' ==> (string ' (string_content) (escape_sequence) 
(string_content) ')
     ;; TODO font-lock param=value pairs
     ;;      writelines(out, outFile, LineEnding = '\n');
     ;;      ==>     (arguments argument: (identifier) , argument: (identifier) 
, (identifier) =
diff --git a/tests/test-matlab-ts-mode-font-lock-files/strings_test.m 
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_strings.m
similarity index 91%
rename from tests/test-matlab-ts-mode-font-lock-files/strings_test.m
rename to tests/test-matlab-ts-mode-font-lock-files/font_lock_strings.m
index b3ce31acb1..d6f9909b71 100644
--- a/tests/test-matlab-ts-mode-font-lock-files/strings_test.m
+++ b/tests/test-matlab-ts-mode-font-lock-files/font_lock_strings.m
@@ -1,7 +1,7 @@
 % -*- matlab-ts -*-
 
 s1 = "abc";
-s2 = 'def';
+s2 = 'One\nTwo';
 
 A = [1 2; 3 4];
 B = A';   % transpose
diff --git 
a/tests/test-matlab-ts-mode-font-lock-files/strings_test_expected.txt 
b/tests/test-matlab-ts-mode-font-lock-files/font_lock_strings_expected.txt
similarity index 91%
rename from tests/test-matlab-ts-mode-font-lock-files/strings_test_expected.txt
rename to 
tests/test-matlab-ts-mode-font-lock-files/font_lock_strings_expected.txt
index 7395b2b155..eac6bd27a7 100644
--- a/tests/test-matlab-ts-mode-font-lock-files/strings_test_expected.txt
+++ b/tests/test-matlab-ts-mode-font-lock-files/font_lock_strings_expected.txt
@@ -1,7 +1,7 @@
 c ccc ccccccccc ccc
 
 vv o SsssSD
-vv o SsssSD
+vv o SsssEEsssSD
 
 v o bn nD n nbD
 v o doD   c ccccccccc
diff --git a/tests/test-matlab-ts-mode-font-lock.el 
b/tests/test-matlab-ts-mode-font-lock.el
index 290ff5a6ef..a20e362637 100644
--- a/tests/test-matlab-ts-mode-font-lock.el
+++ b/tests/test-matlab-ts-mode-font-lock.el
@@ -60,6 +60,7 @@ after validating it, rename it to
                            ("C" . font-lock-comment-delimiter-face)
                            ("d" . default)
                            ("D" . font-lock-delimiter-face)
+                           ("E" . font-lock-escape-face)
                            ("f" . font-lock-function-name-face)
                            ("F" . font-lock-function-call-face)
                            ("h" . font-lock-doc-face) ;; function doc help 
comment

Reply via email to