branch: externals/matlab-mode
commit e944e495cee43701da9c8653a0dd4d3dae06115d
Author: John Ciolfi <[email protected]>
Commit: John Ciolfi <[email protected]>
matlab-ts-mode--ei: added alignment of enums, other minor cleanup
---
NEWS.org | 51 ++++++--
matlab-ts-mode--ei.el | 139 +++++++--------------
matlab-ts-mode.el | 6 +-
.../electric_indent_enum.m | 9 ++
.../electric_indent_enum_expected.m | 9 ++
.../electric_indent_enum_expected_msgs.m | 9 ++
tests/test-matlab-ts-mode-electric-indent-xr.el | 4 +-
tests/test-matlab-ts-mode-electric-indent.el | 4 +-
tests/test-matlab-ts-mode-indent-xr.el | 2 +-
tests/test-matlab-ts-mode-indent.el | 2 +-
.../electric_indent_enum.m | 9 ++
.../electric_indent_enum_expected.txt | 15 +++
.../electric_indent_start_pt_offset.m | 15 +++
.../electric_indent_start_pt_offset_expected.txt | 32 +++++
14 files changed, 194 insertions(+), 112 deletions(-)
diff --git a/NEWS.org b/NEWS.org
index 779e619a11..250038cdb5 100644
--- a/NEWS.org
+++ b/NEWS.org
@@ -16,7 +16,7 @@ To indent a MATLAB ~*.m~ file,
Electric indent will
-1. *Canonicalize language element spacing*
+1. *Standardize language element spacing*
Example:
@@ -48,7 +48,18 @@ Electric indent will
rArea = rLength * rWidth;
#+end_src
-3. *Align properties*
+ For alignment, the statements must be consecutive. For example, the
following contains two
+ sections of consecutive statement alignment:
+
+ #+begin_src matlab
+ aReallyLongVariable = 10;
+ bShortVar = 5;
+
+ c = aReallyLongVariable + bShortVar;
+ c2 = c * 2;
+ #+end_src
+
+3. *Align consecutive properties*
Example:
@@ -74,7 +85,7 @@ Electric indent will
end
#+end_src
-4. *Align arguments*
+4. *Align consecutive arguments*
Example:
@@ -100,7 +111,33 @@ Electric indent will
end
#+end_src
-5. *Align trailing comments*
+5. *Align enumeration members*
+
+ Example:
+
+ #+begin_src matlab
+ classdef TrafficLightColors < double
+ enumeration
+ red (1)
+ green(2)
+ yellow(3)
+ end
+ end
+ #+end_src
+
+ Indents to:
+
+ #+begin_src matlab
+ classdef TrafficLightColors < double
+ enumeration
+ red (1)
+ green (2)
+ yellow (3)
+ end
+ end
+ #+end_src
+
+6. *Align consecutive trailing comments*
Example:
@@ -120,7 +157,7 @@ Electric indent will
disp(distance1) % Report how far we've gone
#+end_src
-6. *Add missing commas in arrays (matrices and cells)*
+7. *Add missing commas in arrays (matrices and cells)*
Example:
@@ -134,7 +171,7 @@ Electric indent will
mat1 = [1234, 234, 12234.24];
#+end_src
-7. *Align multi-line matrix columns*
+8. *Align multi-line matrix columns*
Example
@@ -150,7 +187,7 @@ Electric indent will
1, 2, 3.41];
#+end_src
-8. *Untabify (convert TAB Characters to spaces)*
+9. *Untabify (convert TAB Characters to spaces)*
Conversion of tab characters to spaces ensures that code looks the same
when using different
levels of tab stops. For example, UNIX (POSIX) uses tab stops of 8 whereas
Microsoft uses tab
diff --git a/matlab-ts-mode--ei.el b/matlab-ts-mode--ei.el
index 014b371f96..84b5a636ad 100644
--- a/matlab-ts-mode--ei.el
+++ b/matlab-ts-mode--ei.el
@@ -25,7 +25,9 @@
;;; Commentary:
;;
-;; Electric indent for matlab-ts-mode, see `matlab-ts-mode-electric-indent'
custom variable.
+;; Electric indent: standardize language element spacing, align consecutive
statements, columns,
+;; align trailing comments, add missing commas to arrays, aligns multi-line
matrices columns, and
+;; remove tabs.
;;; Code:
@@ -40,52 +42,7 @@
:prefix "matlab-ts-mode-"
:group 'languages)
-(defcustom matlab-ts-mode-electric-indent t
- "*If t, indent (format) language elements within code.
-
-- Canonicalize language element spacing
- Example | Indent result
- ----------------------------- | -----------------------------
- a=b+c *d ; | a = b + c * d;
-
-- Align consecutive assignments
- Example | Indent result
- ----------------------------- | -----------------------------
- rLength =12354 ; | rLength = 12354;
- rWidth=2; | rWidth = 2;
- rArea=rLength *rWidth; | rArea = rLength * rWidth;
-
-- Align properties and arguments
- Example | Indent result
- ----------------------------- | -----------------------------
- classdef c1 | classdef c1
- properties | properties
- foo (1,3) | foo (1,3)
- foobar (1,1) | foobar (1,1)
- p1 (1,1) | p1 (1,1)
- end | end
- end | end
-
-- Align trailing comments
- Example | Indent result
- ----------------------------- | -----------------------------
- a = myFcn1(1, 2); % comment 1 | a = myFcn1(1, 2); % comment 1
- a = a + 5; % comment 2 | a = a + 2; % comment 2
-
-- Add missing commas in arrays (matrices and cells)
-
- Example | Indent result
- ----------------------------- | -----------------------------
- mat1 = [1234,234 12234.24]; | mat1 = [1234, 234, 12234.24];
-
-- Align matrix columns
- Example | Indent result
- ----------------------------- | -----------------------------
- mat2 = [1234,234 12234.24 | mat2 = [1234, 234, 12234.24
- 1,2 3.41]; | 1, 2, 3.41];
-
-- Untabify (convert TAB characters to spaces)"
- :type 'boolean)
+(defvar matlab-ts-mode--electric-indent t) ;; This shouldn't be disabled -
it's here for testing.
(defvar matlab-ts-mode--electric-indent-verbose nil)
(defvar matlab-ts-mode--indent-assert) ;; from matlab-ts-mode.el
@@ -117,8 +74,7 @@
"spmd"
"switch"
"try"
- "while")
- ))
+ "while")))
(defvar matlab-ts-mode--ei-pad-op-re
(rx bos (or "+" "-" "*" "/" ".*" "./" ".\\" "\\"
@@ -146,7 +102,6 @@
("." ,(rx bos (or "comment"
"line_continuation") eos) 1)
-
;; Case: property dimension
;; foo1 (1, :) {mustBeNumeric, mustBeReal} = [0, 0, 0];
("." ,(rx bos "prop-dim" eos)
0)
@@ -176,7 +131,7 @@
;; Case: anything after a ".", e.g. foo.bar, s.(fieldName)
(,(rx bos "." eos) "."
0)
- (,(rx bos (or "," ";" "command_argument" "command_name") eos) "."
1)
+ (,(rx bos (or "," ";" "command_argument" "command_name" "enum-id") eos)
"." 1)
(,matlab-ts-mode--ei-0-after-re "."
0)
@@ -259,9 +214,7 @@ there are non-whitespace characters on the line, nil
otherwise."
(defun matlab-ts-mode--ei-get-node-to-use (node)
"Given NODE, adjust it for electric indent.
-
Returns (NODE . MODIFIED-NODE-TYPE) pair.
-
For example, when node parent is a string, we return the parent. When
node is a \"+\" and parent is a unary_operator, we return MODIFIED-NODE-TYPE to
be unary-op even though the node type is \"+\"."
@@ -281,16 +234,16 @@ be unary-op even though the node type is \"+\"."
;; arguments name=value
(setq node-type "n=v"))
- ;; convert property identifier to property-id node-type
- ((and (string= node-type "identifier")
- (or
- ;; propertyWithOutDot?
- (and (string= parent-type "property")
- (equal (treesit-node-child parent 0) node))
- ;; property.nameWithDot?
- (and (string= parent-type "property_name")
- (equal (treesit-node-child (treesit-node-parent parent) 0)
parent))))
- (setq node-type "property-id"))
+ ;; (1) property identifier => property-id, (2) enum identifier => enum-id
+ ((string= node-type "identifier")
+ (cond ((or
+ (and (string= parent-type "property") ;; propertyWithOutDot?
+ (equal (treesit-node-child parent 0) node))
+ (and (string= parent-type "property_name") ;;
property.nameWithDot?
+ (equal (treesit-node-child (treesit-node-parent parent) 0)
parent)))
+ (setq node-type "property-id"))
+ ((and (string= node-type "identifier") (string= parent-type
"enum"))
+ (setq node-type "enum-id"))))
;; Unary operator sign, + or -, e.g. [0 -e] or g = - e
((and (string= parent-type "unary_operator")
@@ -1064,18 +1017,18 @@ See `matlab-ts-mode--ei-get-new-line' for EI-INFO
contents."
(defun matlab-ts-mode--ei-get-prop-node (ei-info)
"Return property or argument node for first node in EI-INFO.
-Returns nil if not a property or argument node."
+Returns nil if not a property, enum field, or argument node."
(let* ((first-node-in-line (nth 3 ei-info))
- (parent (when first-node-in-line (treesit-node-parent
first-node-in-line)))
- (prop-node (pcase (treesit-node-type parent)
- ("property"
+ (modified-node-type (cdr (matlab-ts-mode--ei-get-node-to-use
first-node-in-line)))
+ (prop-node (pcase modified-node-type
+ ((or "property-id" "enum-id")
first-node-in-line)
("property_name"
- parent))))
- ;; properties / arguments can span multiple lines, so skip these
- (when (= (line-number-at-pos (treesit-node-start prop-node))
- (line-number-at-pos (treesit-node-end prop-node)))
- prop-node)))
+ (treesit-node-parent first-node-in-line)))))
+ ;; skip multi-line nodes for alignment (properties / arguments can
span multiple lines)
+ (when (= (line-number-at-pos (treesit-node-start prop-node))
+ (line-number-at-pos (treesit-node-end prop-node)))
+ prop-node)))
(defun matlab-ts-mode--ei-prop-length (ei-info)
"Get the property length from the electric indented line in EI-INFO."
@@ -1447,7 +1400,7 @@ to it's logical location when the line is updated."
)))
(defun matlab-ts-mode--ei-move-to-loc (start-pt-linenum start-pt-offset)
- "Move to locatation START-PT-LINENUM at column START-PT-OFFSET."
+ "Move to location START-PT-LINENUM at column START-PT-OFFSET."
(goto-char (point-min))
(forward-line (1- start-pt-linenum))
(let ((eol-col (- (pos-eol) (pos-bol))))
@@ -1456,6 +1409,20 @@ to it's logical location when the line is updated."
(setq start-pt-offset eol-col)))
(forward-char start-pt-offset))
+(defun matlab-ts-mode--ei-set-alist-caches (init)
+ "Setup electric indent alist caches.
+If INIT is non-nil, set to initial value, otherwise set to nil"
+ (let ((value (when init '((-1 . 0))))) ;; Entries of form (LINENUM . INFO)
+ (setq-local matlab-ts-mode--ei-align-assign-alist value
+ matlab-ts-mode--ei-align-prop-alist value
+ matlab-ts-mode--ei-align-comment-alist value
+ matlab-ts-mode--ei-m-matrix-col-widths-alist value
+ matrix-ts-mode--ei-m-matrix-first-col-extra-alist value
+ matlab-ts-mode--ei-is-m-matrix-alist value
+ matlab-ts-mode--ei-align-matrix-alist value
+ matlab-ts-mode--ei-errors-alist (when init
(matlab-ts-mode--ei-get-errors-alist))
+ matlab-ts-mode--ei-orig-line-node-types-alist value)))
+
(defun matlab-ts-mode--ei-indent-region (beg end)
"Indent BEG END region by adjusting spacing around elements.
If BEG is not at start of line, it is moved to start of the line.
@@ -1489,18 +1456,7 @@ This expansion of the region is done to simplify
electric indent."
(unwind-protect
(progn
- ;; Add an invalid entry to each of the following associative lists.
This entry is used
- ;; as a marker to activate caching. Each entry in the lists is a
cons cell `(LINENUM
- ;; . INFO) where -1 is not a valid line number.
- (setq-local matlab-ts-mode--ei-align-assign-alist '((-1 . 0))
- matlab-ts-mode--ei-align-prop-alist '((-1 . 0))
- matlab-ts-mode--ei-align-comment-alist '((-1 . 0))
- matlab-ts-mode--ei-m-matrix-col-widths-alist '((-1 . 0))
- matrix-ts-mode--ei-m-matrix-first-col-extra-alist '((-1
. 0))
- matlab-ts-mode--ei-is-m-matrix-alist '((-1 . 0))
- matlab-ts-mode--ei-align-matrix-alist '((-1 . ""))
- matlab-ts-mode--ei-errors-alist
(matlab-ts-mode--ei-get-errors-alist)
- matlab-ts-mode--ei-orig-line-node-types-alist '((-1 .
0)))
+ (matlab-ts-mode--ei-set-alist-caches t)
(save-excursion
(save-restriction
@@ -1552,23 +1508,14 @@ This expansion of the region is done to simplify
electric indent."
(setq end (point)))))))
(matlab-ts-mode--ei-move-to-loc start-pt-linenum start-pt-offset) ;;
for indent-region
-
(treesit-indent-region beg end))
- ;; unwind-protect cleanup
- (setq-local matlab-ts-mode--ei-align-assign-alist nil
- matlab-ts-mode--ei-align-prop-alist nil
- matlab-ts-mode--ei-align-comment-alist nil
- matlab-ts-mode--ei-m-matrix-col-widths-alist nil
- matrix-ts-mode--ei-m-matrix-first-col-extra-alist nil
- matlab-ts-mode--ei-is-m-matrix-alist nil
- matlab-ts-mode--ei-align-matrix-alist nil
- matlab-ts-mode--ei-errors-alist nil)
+ (matlab-ts-mode--ei-set-alist-caches nil)
(kill-buffer new-content-buf))))
(provide 'matlab-ts-mode--ei)
;;; matlab-ts-mode--ei.el ends here
;; LocalWords: SPDX gmail treesit defcustom bos eos isstring defun eol eobp
setq curr cdr xr progn
-;; LocalWords: listp alist dolist setf tmp buf utils linenum nums bobp pcase
Untabify untabify SPC
+;; LocalWords: listp alist dolist setf tmp buf utils linenum nums bobp pcase
untabify SPC
;; LocalWords: linenums reindent bol fubar
diff --git a/matlab-ts-mode.el b/matlab-ts-mode.el
index b96bb3936d..27c2657b07 100644
--- a/matlab-ts-mode.el
+++ b/matlab-ts-mode.el
@@ -2482,7 +2482,7 @@ Example:
(cl-return-from matlab-ts-mode--i-row-matcher))
;; When electric indent AND parent node is a multi-line matrix (m-matrix)
- (when (and matlab-ts-mode-electric-indent
+ (when (and matlab-ts-mode--electric-indent
(string= "matrix" (treesit-node-type parent))
(matlab-ts-mode--ei-is-m-matrix parent))
;; Align to first column width
@@ -2910,7 +2910,7 @@ Example:
(defun matlab-ts-mode--treesit-indent ()
"Call `treesit-indent', then do electric indent."
(treesit-indent) ;; treesit-indent before electric indent to get updated
point on the line
- (when matlab-ts-mode-electric-indent
+ (when matlab-ts-mode--electric-indent
(save-restriction
(widen)
(matlab-ts-mode--ei-workaround-143 (pos-bol) (pos-eol) (point))
@@ -2921,7 +2921,7 @@ Example:
;; `treesit-indent-region' will not alter the number of lines, but it may
reduce the buffer size,
;; thus grab the start/end lines for
`matlab-ts-mode--ei-indent-elements-in-line'.
- (if matlab-ts-mode-electric-indent
+ (if matlab-ts-mode--electric-indent
;; do electric indent, then indent-region
(matlab-ts-mode--ei-indent-region beg end)
;; just indent-region
diff --git
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_enum.m
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_enum.m
new file mode 100644
index 0000000000..0232d1a27f
--- /dev/null
+++ b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_enum.m
@@ -0,0 +1,9 @@
+% -*- matlab-ts -*-
+
+classdef electric_indent_enum < Simulink.IntEnumType
+ enumeration
+ a (1)
+ bLongEnumField (2)
+ abc (3)
+ end
+end
diff --git
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_enum_expected.m
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_enum_expected.m
new file mode 100644
index 0000000000..0232d1a27f
--- /dev/null
+++
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_enum_expected.m
@@ -0,0 +1,9 @@
+% -*- matlab-ts -*-
+
+classdef electric_indent_enum < Simulink.IntEnumType
+ enumeration
+ a (1)
+ bLongEnumField (2)
+ abc (3)
+ end
+end
diff --git
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_enum_expected_msgs.m
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_enum_expected_msgs.m
new file mode 100644
index 0000000000..1d3960cd92
--- /dev/null
+++
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_enum_expected_msgs.m
@@ -0,0 +1,9 @@
+% -*- matlab-ts -*- % <{Matched rule: (matlab-ts-mode--i-top-level
matlab-ts-mode--column-0 0)}>
+
+classdef electric_indent_enum < Simulink.IntEnumType % <{Matched rule:
(matlab-ts-mode--i-top-level matlab-ts-mode--column-0 0)}>
+ enumeration % <{Matched rule: ((node-is
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
parent 4)}>
+ a (1) % <{Matched rule: ((node-is
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
parent 4)}>
+ bLongEnumField (2) % <{Matched rule: ((node-is
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
parent 4)}>
+ abc (3) % <{Matched rule: ((node-is
"\\`\\(?:arguments_statement\\|block\\|e\\(?:num\\(?:eration\\)?\\|vents\\)\\|function_definition\\|methods\\|propert\\(?:ies\\|y\\)\\)\\'")
parent 4)}>
+ end % <{Matched rule: ((node-is
"\\`\\(?:catch_clause\\|e\\(?:lse\\(?:\\(?:if\\)?_clause\\)\\|nd\\)\\)\\'")
parent 0)}>
+end % <{Matched rule: ((node-is
"\\`\\(?:catch_clause\\|e\\(?:lse\\(?:\\(?:if\\)?_clause\\)\\|nd\\)\\)\\'")
parent 0)}>
diff --git a/tests/test-matlab-ts-mode-electric-indent-xr.el
b/tests/test-matlab-ts-mode-electric-indent-xr.el
index 155dc6bc18..6fc8bcac05 100644
--- a/tests/test-matlab-ts-mode-electric-indent-xr.el
+++ b/tests/test-matlab-ts-mode-electric-indent-xr.el
@@ -1,6 +1,6 @@
;;; test-matlab-ts-mode-electric-indent-xr.el --- -*- lexical-binding: t -*-
-;; Copyright (C) 2025 Free Software Foundation, Inc.
+;; Copyright (C) 2025-2026 Free Software Foundation, Inc.
;;
;; This file is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published
@@ -54,7 +54,7 @@ after validating it, rename it to
(m-files (t-utils-get-files test-name
:base-regexp (rx ".m" eos)
:file-to-use
test-matlab-ts-mode-electric-indent-xr--file))
- (matlab-ts-mode-electric-indent t)
+ (matlab-ts-mode--electric-indent t)
(matlab-ts-mode--indent-assert t)
(matlab-ts-mode--electric-indent-verbose nil))
(t-utils-error-if-no-treesit-for 'matlab test-name)
diff --git a/tests/test-matlab-ts-mode-electric-indent.el
b/tests/test-matlab-ts-mode-electric-indent.el
index 50f3fd7ccf..8c89cefbec 100644
--- a/tests/test-matlab-ts-mode-electric-indent.el
+++ b/tests/test-matlab-ts-mode-electric-indent.el
@@ -1,6 +1,6 @@
;;; test-matlab-ts-mode-electric-indent.el --- -*- lexical-binding: t -*-
-;; Copyright (C) 2025 Free Software Foundation, Inc.
+;; Copyright (C) 2025-2026 Free Software Foundation, Inc.
;;
;; This file is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published
@@ -67,7 +67,7 @@ after validating them, rename them to
(setq matlab-ts-mode--function-indent-level
test-matlab-ts-mode-electric-indent--current-indent-level)))
;; Enable electric indent
- (matlab-ts-mode-electric-indent t)
+ (matlab-ts-mode--electric-indent t)
(matlab-ts-mode--indent-assert t)
(matlab-ts-mode--electric-indent-verbose nil))
(t-utils-error-if-no-treesit-for 'matlab test-name)
diff --git a/tests/test-matlab-ts-mode-indent-xr.el
b/tests/test-matlab-ts-mode-indent-xr.el
index e1164e614b..2478c7d83e 100644
--- a/tests/test-matlab-ts-mode-indent-xr.el
+++ b/tests/test-matlab-ts-mode-indent-xr.el
@@ -54,7 +54,7 @@ after validating it, rename it to
(m-files (t-utils-get-files test-name
:base-regexp (rx ".m" eos)
:file-to-use
test-matlab-ts-mode-indent-xr--file))
- (matlab-ts-mode-electric-indent nil))
+ (matlab-ts-mode--electric-indent nil))
(t-utils-error-if-no-treesit-for 'matlab test-name)
(t-utils-test-xr test-name m-files)))
diff --git a/tests/test-matlab-ts-mode-indent.el
b/tests/test-matlab-ts-mode-indent.el
index 589d1c7b0e..07a18b9342 100644
--- a/tests/test-matlab-ts-mode-indent.el
+++ b/tests/test-matlab-ts-mode-indent.el
@@ -74,7 +74,7 @@ after validating them, rename them to
(when (string= (treesit-node-type parent)
"ERROR")
(insert " ")))
(forward-line))))
- (matlab-ts-mode-electric-indent nil))
+ (matlab-ts-mode--electric-indent nil))
(t-utils-error-if-no-treesit-for 'matlab test-name)
(t-utils-test-indent test-name m-files
:indent-checker indent-checker
diff --git
a/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_enum.m
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_enum.m
new file mode 100644
index 0000000000..0232d1a27f
--- /dev/null
+++
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_enum.m
@@ -0,0 +1,9 @@
+% -*- matlab-ts -*-
+
+classdef electric_indent_enum < Simulink.IntEnumType
+ enumeration
+ a (1)
+ bLongEnumField (2)
+ abc (3)
+ end
+end
diff --git
a/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_enum_expected.txt
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_enum_expected.txt
new file mode 100644
index 0000000000..5a2afd42b7
--- /dev/null
+++
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_enum_expected.txt
@@ -0,0 +1,15 @@
+# -*- t-utils-ts-parse-tree -*-
+(source_file<1,184> (comment[1,20]@{% -*- matlab-ts -*-}@) \n[20,22]
+ (class_definition<22,183> classdef[22,30] name:
(identifier[31,51]@{electric_indent_enum}@)
+ (superclasses<52,74> <[52,53]
+ (property_name<54,74> (identifier[54,62]@{Simulink}@) .[62,63]
(identifier[63,74]@{IntEnumType}@)))
+ \n[74,75]
+ (enumeration<79,179> enumeration[79,90] \n[90,91]
+ (enum<99,117> (identifier[99,100]@{a}@) ([114,115] (number[115,116]@{1}@)
)[116,117])
+ \n[117,118]
+ (enum<126,144> (identifier[126,140]@{bLongEnumField}@) ([141,142]
(number[142,143]@{2}@) )[143,144])
+ \n[144,145]
+ (enum<153,171> (identifier[153,156]@{abc}@) ([168,169]
(number[169,170]@{3}@) )[170,171])
+ \n[171,172] end[176,179])
+ \n[179,180] end[180,183])
+ \n[183,184])
diff --git
a/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_start_pt_offset.m
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_start_pt_offset.m
new file mode 100644
index 0000000000..9844b9f8bd
--- /dev/null
+++
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_start_pt_offset.m
@@ -0,0 +1,15 @@
+% -*- matlab-ts -*-
+
+% t-utils-test-indent: no-line-by-line-indent - line-by-line typing results in
error nodes
+
+function electric_indent_start_pt_offset()
+
+% This exercises
+% (when (> start-pt-offset eol-col) ;; be robust too big a start-pt-offset
+% (setq start-pt-offset eol-col)))
+% in matlab-ts-mode--ei-move-to-loc
+
+foobar('Parameters', ...
+ {'A', 'B', 'C', 'D', 'E', 'F'}, ...
+ 'Values', ...
+ {1 , 1, 1, 1, 1, 1});
diff --git
a/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_start_pt_offset_expected.txt
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_start_pt_offset_expected.txt
new file mode 100644
index 0000000000..8d47610ffe
--- /dev/null
+++
b/tests/test-matlab-ts-mode-parser-files/copy-of-test-matlab-ts-mode-electric-indent-files/electric_indent_start_pt_offset_expected.txt
@@ -0,0 +1,32 @@
+# -*- t-utils-ts-parse-tree -*-
+(source_file<1,500> (comment[1,20]@{% -*- matlab-ts -*-}@) (comment[22,112]@{%
t-utils-test-indent: no-line-by-line-indent - li...}@) \n[112,114]
+ (function_definition<114,500> function[114,122] name:
(identifier[123,154]@{electric_indent_start_pt_offset}@)
+ (function_arguments<154,156> ([154,155] )[155,156])
+ (comment[158,330]@{% This exercises\n% (when (> start-pt-offset e...}@)
\n[330,332]
+ (block<332,500>
+ (function_call<332,498> name: (identifier[332,338]@{foobar}@) ([338,339]
+ (arguments<339,497>
+ argument: (string<339,351> '[339,340]
(string_content[340,350]@{Parameters}@) '[350,351])
+ ,[351,352] (line_continuation[353,357]@{...\n}@)
+ (cell<364,394> {[364,365]
+ (row<365,393>
+ (string<365,368> '[365,366] (string_content[366,367]@{A}@) '[367,368])
+ ,[368,369]
+ (string<370,373> '[370,371] (string_content[371,372]@{B}@) '[372,373])
+ ,[373,374]
+ (string<375,378> '[375,376] (string_content[376,377]@{C}@) '[377,378])
+ ,[378,379]
+ (string<380,383> '[380,381] (string_content[381,382]@{D}@) '[382,383])
+ ,[383,384]
+ (string<385,388> '[385,386] (string_content[386,387]@{E}@) '[387,388])
+ ,[388,389]
+ (string<390,393> '[390,391] (string_content[391,392]@{F}@) '[392,393]))
+ }[393,394])
+ ,[394,395] (line_continuation[396,400]@{...\n}@)
+ (string<407,415> '[407,408] (string_content[408,414]@{Values}@)
'[414,415])
+ ,[415,416] (line_continuation[417,421]@{...\n}@)
+ (cell<457,497> {[457,458]
+ (row<458,496> (number[458,459]@{1}@) ,[481,482] (number[483,484]@{1}@)
,[484,485] (number[486,487]@{1}@) ,[487,488] (number[489,490]@{1}@) ,[490,491]
(number[492,493]@{1}@) ,[493,494] (number[495,496]@{1}@))
+ }[496,497]))
+ )[497,498])
+ ;[498,499] \n[499,500])))