branch: externals/matlab-mode
commit 51c98365d47f2be43ccec3b9f2935514c4031201
Author: John Ciolfi <[email protected]>
Commit: John Ciolfi <[email protected]>
matlab-ts-mode--ei: handle indent of matrix in context of syntax error
---
...matlab_code_indent.org => matlab-code-indent.org} | 20 ++++++++++++++++++--
matlab-ts-mode--ei.el | 2 +-
.../electric_indent_matrix_cols_in_fcn_with_error.m | 10 ++++++++++
...c_indent_matrix_cols_in_fcn_with_error_expected.m | 10 ++++++++++
...ent_matrix_cols_in_fcn_with_error_expected_msgs.m | 10 ++++++++++
5 files changed, 49 insertions(+), 3 deletions(-)
diff --git a/doc/matlab_code_indent.org b/doc/matlab-code-indent.org
similarity index 97%
rename from doc/matlab_code_indent.org
rename to doc/matlab-code-indent.org
index 201d886483..907049119f 100644
--- a/doc/matlab_code_indent.org
+++ b/doc/matlab-code-indent.org
@@ -1,5 +1,5 @@
-# File: doc/code_indent.org
-# Copyright (C) 2025 Free Software Foundation, Inc.
+# File: matlab-code-indent.org
+# Copyright (C) 2026 Free Software Foundation, Inc.
#+startup: showall
#+startup: logdone
@@ -23,6 +23,22 @@ To indent a MATLAB ~*.m~ file,
When using matlab-ts-mode (and not matlab-mode) the MATLAB indent engine:
+* Indent FAQ
+
+1. How do I shorten long code lines?
+
+ The location of the ellipsis line continuation influences the length of
code lines. For exmaple,
+
+ #+begin_src matlab
+ longVariableNameForMatrix1 = [
+ 100, 2000, 3000
+ 4000, 5000, 6000
+ ];
+
+ #+end_src
+
+
+
* Indent Engine Design Considerations
_Simplicity is good_
diff --git a/matlab-ts-mode--ei.el b/matlab-ts-mode--ei.el
index efbb1bb665..1138f234f7 100644
--- a/matlab-ts-mode--ei.el
+++ b/matlab-ts-mode--ei.el
@@ -1044,7 +1044,7 @@ column."
(cl-return)))))
)
;; Case: unexpected matrix child node
- ((not (string-match-p (rx bos (or "[" "]" "comment"
"line_continuation") eos)
+ ((not (string-match-p (rx bos (or "[" "]" "comment"
"line_continuation" "\n") eos)
child-type))
(error "Assert: unexpected matrix child %S" child))))))
diff --git
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_matrix_cols_in_fcn_with_error.m
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_matrix_cols_in_fcn_with_error.m
new file mode 100644
index 0000000000..fc5ae69b55
--- /dev/null
+++
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_matrix_cols_in_fcn_with_error.m
@@ -0,0 +1,10 @@
+% -*- matlab-ts -*-
+
+% t-utils-test-indent: no-line-by-line-indent - when we type line-by-line, the
continuation lines
+
+% Test missing closing paren:
+
+longVariableNameForMatrix1 = myFcn([
+ 100, 2000, 3000
+ 4000, 5000, 6000
+ ];
diff --git
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_matrix_cols_in_fcn_with_error_expected.m
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_matrix_cols_in_fcn_with_error_expected.m
new file mode 100644
index 0000000000..fc5ae69b55
--- /dev/null
+++
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_matrix_cols_in_fcn_with_error_expected.m
@@ -0,0 +1,10 @@
+% -*- matlab-ts -*-
+
+% t-utils-test-indent: no-line-by-line-indent - when we type line-by-line, the
continuation lines
+
+% Test missing closing paren:
+
+longVariableNameForMatrix1 = myFcn([
+ 100, 2000, 3000
+ 4000, 5000, 6000
+ ];
diff --git
a/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_matrix_cols_in_fcn_with_error_expected_msgs.m
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_matrix_cols_in_fcn_with_error_expected_msgs.m
new file mode 100644
index 0000000000..73d2e87bd3
--- /dev/null
+++
b/tests/test-matlab-ts-mode-electric-indent-files/electric_indent_matrix_cols_in_fcn_with_error_expected_msgs.m
@@ -0,0 +1,10 @@
+% -*- matlab-ts -*- % <{Matched rule: (matlab-ts-mode--i-top-level
matlab-ts-mode--column-0 0)}>
+
+% t-utils-test-indent: no-line-by-line-indent - when we type line-by-line, the
continuation lines % <{Matched rule: (matlab-ts-mode--i-top-level
matlab-ts-mode--column-0 0)}>
+
+% Test missing closing paren: % <{Matched rule: (matlab-ts-mode--i-top-level
matlab-ts-mode--column-0 0)}>
+
+longVariableNameForMatrix1 = myFcn([ % <{Matched rule:
(matlab-ts-mode--i-top-level matlab-ts-mode--column-0 0)}>
+ 100, 2000, 3000 % <{Matched rule:
(matlab-ts-mode--i-row-matcher matlab-ts-mode--i-row-matcher-anchor
matlab-ts-mode--i-row-matcher-offset)}>
+ 4000, 5000, 6000 % <{Matched rule:
(matlab-ts-mode--i-row-matcher matlab-ts-mode--i-row-matcher-anchor
matlab-ts-mode--i-row-matcher-offset)}>
+ ]; % <{Matched rule: ((node-is
"\\`[])}]\\'") parent 0)}>