branch: externals/matlab-mode
commit 84cb6a2413658853d77ef756e6fa44f1a29a096b
Author: John Ciolfi <[email protected]>
Commit: John Ciolfi <[email protected]>
matlab-ts-mode: update to abi/14 17db994
---
.../indent_fcn_ellipsis.skip.typing.txt | 100 -----------------
.../indent_line_cont_in_row_cell.m | 5 +-
.../indent_line_cont_in_row_cell_expected.m | 1 -
.../indent_line_cont_in_row_cell_expected_msgs.m | 5 +-
.../indent_line_cont_in_row_matrix.m | 1 -
.../indent_line_cont_in_row_matrix_expected.m | 1 -
.../indent_line_cont_in_row_matrix_expected_msgs.m | 5 +-
.../indent_multiple_arg_blocks_issue113.skip.txt | 1 -
.../indent_xr_fun5_expected.org | 119 +++++++++------------
9 files changed, 58 insertions(+), 180 deletions(-)
diff --git
a/tests/test-matlab-ts-mode-indent-files/indent_fcn_ellipsis.skip.typing.txt
b/tests/test-matlab-ts-mode-indent-files/indent_fcn_ellipsis.skip.typing.txt
deleted file mode 100644
index b7e289b850..0000000000
--- a/tests/test-matlab-ts-mode-indent-files/indent_fcn_ellipsis.skip.typing.txt
+++ /dev/null
@@ -1,100 +0,0 @@
-# -*- org -*-
-
-Don't seem to have enough info to get typing via line-by-line.
-Given foo.m containg, TAB on the 3rd line using the following patch works.
-
-#+begin_src matlab
- function ...
- [ ...
- a, ...
-#+end_src
-
-which has parse tree
-
-#+begin_example
-(function_definition function name: (line_continuation)
- (ERROR [)
- (line_continuation) (identifier) , (line_continuation) \n)
-#+end_example
-
-If we then add a 4th line
-#+begin_src matlab
- function ...
- [ ...
- a, ...
- b ...
-#+end_src
-
-We don't have enough info to indent (TAB on 4th line). For the 4 lines, we
have parse tree:
-
-#+begin_example
-(function_definition function name: (line_continuation)
- (ERROR [)
- (line_continuation) (identifier) , (line_continuation)
- (block (identifier) (line_continuation) \n \n))
-#+end_example
-
-#+begin_src diff
---- matlab-ts-mode.el 2025-10-29 11:56:39.000000000 -0400
-+++ matlab-ts-mode-fcn-cont.el 2025-10-29 11:55:24.447575406 -0400
-@@ -2015,6 +2015,23 @@
-
- (cons prev-sibling-to-check prev-sibling-error-node)))
-
-+(defun matlab-ts-mode--is-near-ancestor-an-error (node parent)
-+ "Is NODE or PARENT an error node or within a near error node?"
-+ ;; Is node, parent, or grandparent an error? We could look to other
ancestors,
-+ ;; but that would indicate many syntax errors and result in unexpected
indent.
-+ (or (and node (string= (treesit-node-type node) "ERROR"))
-+ (string-match-p (rx (seq bos (or "ERROR" "\n") eos)) (treesit-node-type
parent))
-+ (equal (treesit-node-type (treesit-node-parent parent)) "ERROR")))
-+
-+(defun matlab-ts-mode--is-near-sibling-an-error (node)
-+ "Is NODE near sibling an error node, if so return the error node."
-+ (let ((prev-sibling (treesit-node-prev-sibling node)))
-+ (while (and prev-sibling
-+ (string= (treesit-node-type prev-sibling)
"line_continuation"))
-+ (setq prev-sibling (treesit-node-prev-sibling prev-sibling)))
-+ (when (string= (treesit-node-type prev-sibling) "ERROR")
-+ prev-sibling)))
-+
- (cl-defun matlab-ts-mode--i-next-line-matcher (node parent bol &rest _)
- "Matcher for indent on a newline being inserted when in presence of errors.
- If so, set `matlab-ts-mode--i-next-line-pair'.
-@@ -2049,11 +2066,8 @@
- (setq parent last-child-of-error-node))
-
- (when (or last-child-of-error-node
-- ;; Is node, parent, or grandparent an error? We could look to
other ancestors,
-- ;; but that would indicate many syntax errors and result in
unexpected indent.
-- (and node (string= (treesit-node-type node) "ERROR"))
-- (string-match-p (rx (seq bos (or "ERROR" "\n") eos))
(treesit-node-type parent))
-- (equal (treesit-node-type (treesit-node-parent parent))
"ERROR"))
-+ (matlab-ts-mode--is-near-ancestor-an-error node parent)
-+ (matlab-ts-mode--is-near-sibling-an-error node))
-
- (let ((node-to-check (or last-child-of-error-node node parent))
- ancestor-error-node ;; is node, parent, or one of it's ancestors
an ERROR?
-@@ -2090,7 +2104,11 @@
- ;; We use regular matching rules when there is NO error.
- (when (and (not ancestor-error-node)
- (not prev-sibling-error-node))
-- (cl-return-from matlab-ts-mode--i-next-line-matcher nil))
-+ (when prev-sibling-to-check
-+ (setq ancestor-to-check nil
-+ prev-sibling-error-node
(matlab-ts-mode--is-near-sibling-an-error node)))
-+ (when (not prev-sibling-error-node)
-+ (cl-return-from matlab-ts-mode--i-next-line-matcher nil)))
-
- (let ((anchor-node (or ancestor-to-check
- prev-sibling-to-check)))
-@@ -3142,7 +3160,7 @@
- ;; in1, ... comment about in1
- ;; See:
test-matlab-ts-mode-on-save-fixes-files/on_save_no_fix_syntax_error.m
- (cl-return))
--
-+
- (let* ((def-name-node (treesit-node-child-by-field-name
child "name"))
- (def-name (treesit-node-text def-name-node))
- (file-name (file-name-nondirectory (or
(buffer-file-name) (buffer-name))))
-#+end_src
diff --git
a/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_cell.m
b/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_cell.m
index 405cf77ce2..93cca3f792 100644
--- a/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_cell.m
+++ b/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_cell.m
@@ -3,8 +3,8 @@
% See: https://github.com/acristoffers/tree-sitter-matlab/issues/116
fcn1({a() ...
- newline ...
- b()});
+ newline ...
+ b()});
function fcn1(x)
disp(x);
@@ -17,4 +17,3 @@ end
function out = b
out = "b string";
end
-
diff --git
a/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_cell_expected.m
b/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_cell_expected.m
index 405cf77ce2..88ca9b6788 100644
---
a/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_cell_expected.m
+++
b/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_cell_expected.m
@@ -17,4 +17,3 @@ end
function out = b
out = "b string";
end
-
diff --git
a/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_cell_expected_msgs.m
b/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_cell_expected_msgs.m
index eb24e610ce..6ef3093ee2 100644
---
a/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_cell_expected_msgs.m
+++
b/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_cell_expected_msgs.m
@@ -3,8 +3,8 @@
% See: https://github.com/acristoffers/tree-sitter-matlab/issues/116 %
<{Matched rule: ((lambda (node parent _bol &rest _) (and node (not (string=
(treesit-node-type node) "line_continuation")) (equal (treesit-node-type
parent) "source_file"))) (lambda (_node _parent bol &rest _) (save-excursion
(goto-char bol) (line-beginning-position))) 0)}>
fcn1({a() ... % <{Matched rule: ((lambda (node parent _bol &rest _) (and node
(not (string= (treesit-node-type node) "line_continuation")) (equal
(treesit-node-type parent) "source_file"))) (lambda (_node _parent bol &rest _)
(save-excursion (goto-char bol) (line-beginning-position))) 0)}>
- newline ... % <{No matched rule}>
- b()}); % <{No matched rule}>
+ newline ... % <{Matched rule: ((parent-is
"\\`\\(?:function_output\\|row\\)\\'") parent 0)}>
+ b()}); % <{Matched rule: ((parent-is
"\\`\\(?:function_output\\|row\\)\\'") parent 0)}>
function fcn1(x) % <{Matched rule: ((lambda (node parent _bol &rest _) (and
node (not (string= (treesit-node-type node) "line_continuation")) (equal
(treesit-node-type parent) "source_file"))) (lambda (_node _parent bol &rest _)
(save-excursion (goto-char bol) (line-beginning-position))) 0)}>
disp(x); % <{Matched rule: ((parent-is "\\`function_definition\\'")
parent matlab-ts-mode--set-function-indent-level-for-gp)}>
@@ -17,4 +17,3 @@ end % <{Matched rule: ((node-is
"\\`\\(?:catch_clause\\|e\\(?:lse\\(?:\\(?:if\\
function out = b % <{Matched rule: ((lambda (node parent _bol &rest _) (and
node (not (string= (treesit-node-type node) "line_continuation")) (equal
(treesit-node-type parent) "source_file"))) (lambda (_node _parent bol &rest _)
(save-excursion (goto-char bol) (line-beginning-position))) 0)}>
out = "b string"; % <{Matched rule: ((parent-is
"\\`function_definition\\'") parent
matlab-ts-mode--set-function-indent-level-for-gp)}>
end % <{Matched rule: ((node-is
"\\`\\(?:catch_clause\\|e\\(?:lse\\(?:\\(?:if\\)?_clause\\)\\|nd\\)\\)\\'")
parent 0)}>
-
diff --git
a/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_matrix.m
b/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_matrix.m
index 7c8003a53a..9ce5a8804d 100644
--- a/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_matrix.m
+++ b/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_matrix.m
@@ -17,4 +17,3 @@ end
function out = b
out = "b string";
end
-
diff --git
a/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_matrix_expected.m
b/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_matrix_expected.m
index 7c8003a53a..9ce5a8804d 100644
---
a/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_matrix_expected.m
+++
b/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_matrix_expected.m
@@ -17,4 +17,3 @@ end
function out = b
out = "b string";
end
-
diff --git
a/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_matrix_expected_msgs.m
b/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_matrix_expected_msgs.m
index ab8c35c81a..bfe2e42b2c 100644
---
a/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_matrix_expected_msgs.m
+++
b/tests/test-matlab-ts-mode-indent-files/indent_line_cont_in_row_matrix_expected_msgs.m
@@ -3,8 +3,8 @@
% See: https://github.com/acristoffers/tree-sitter-matlab/issues/116 %
<{Matched rule: ((lambda (node parent _bol &rest _) (and node (not (string=
(treesit-node-type node) "line_continuation")) (equal (treesit-node-type
parent) "source_file"))) (lambda (_node _parent bol &rest _) (save-excursion
(goto-char bol) (line-beginning-position))) 0)}>
fcn1([a() ... % <{Matched rule: ((lambda (node parent _bol &rest _) (and node
(not (string= (treesit-node-type node) "line_continuation")) (equal
(treesit-node-type parent) "source_file"))) (lambda (_node _parent bol &rest _)
(save-excursion (goto-char bol) (line-beginning-position))) 0)}>
- newline ... % <{No matched rule}>
- b()]); % <{No matched rule}>
+ newline ... % <{Matched rule: ((parent-is
"\\`\\(?:function_output\\|row\\)\\'") parent 0)}>
+ b()]); % <{Matched rule: ((parent-is
"\\`\\(?:function_output\\|row\\)\\'") parent 0)}>
function fcn1(x) % <{Matched rule: ((lambda (node parent _bol &rest _) (and
node (not (string= (treesit-node-type node) "line_continuation")) (equal
(treesit-node-type parent) "source_file"))) (lambda (_node _parent bol &rest _)
(save-excursion (goto-char bol) (line-beginning-position))) 0)}>
disp(x); % <{Matched rule: ((parent-is "\\`function_definition\\'")
parent matlab-ts-mode--set-function-indent-level-for-gp)}>
@@ -17,4 +17,3 @@ end % <{Matched rule: ((node-is
"\\`\\(?:catch_clause\\|e\\(?:lse\\(?:\\(?:if\\
function out = b % <{Matched rule: ((lambda (node parent _bol &rest _) (and
node (not (string= (treesit-node-type node) "line_continuation")) (equal
(treesit-node-type parent) "source_file"))) (lambda (_node _parent bol &rest _)
(save-excursion (goto-char bol) (line-beginning-position))) 0)}>
out = "b string"; % <{Matched rule: ((parent-is
"\\`function_definition\\'") parent
matlab-ts-mode--set-function-indent-level-for-gp)}>
end % <{Matched rule: ((node-is
"\\`\\(?:catch_clause\\|e\\(?:lse\\(?:\\(?:if\\)?_clause\\)\\|nd\\)\\)\\'")
parent 0)}>
-
diff --git
a/tests/test-matlab-ts-mode-indent-files/indent_multiple_arg_blocks_issue113.skip.txt
b/tests/test-matlab-ts-mode-indent-files/indent_multiple_arg_blocks_issue113.skip.txt
deleted file mode 100644
index 5cd43d1f4b..0000000000
---
a/tests/test-matlab-ts-mode-indent-files/indent_multiple_arg_blocks_issue113.skip.txt
+++ /dev/null
@@ -1 +0,0 @@
-See https://github.com/acristoffers/tree-sitter-matlab/issues/113
diff --git
a/tests/test-matlab-ts-mode-indent-xr-files/indent_xr_fun5_expected.org
b/tests/test-matlab-ts-mode-indent-xr-files/indent_xr_fun5_expected.org
index a74f9c4676..9bb5ff710b 100644
--- a/tests/test-matlab-ts-mode-indent-xr-files/indent_xr_fun5_expected.org
+++ b/tests/test-matlab-ts-mode-indent-xr-files/indent_xr_fun5_expected.org
@@ -148,27 +148,25 @@
- Invoking : "C-m" = newline
Start point : 1048
- Moved to point: 1052
- : 36:4:
- : ^
+ Moved to point: 1057
+ : 36:8:
+ : ^
Buffer modified:
#+begin_src diff
--- start_contents
+++ end_contents
-@@ -32,4 +32,5 @@
- %}
+@@ -33,3 +33,4 @@
function ...
[ ...
-- b ... comment for b
-+ b ... comment for b
-+
+ b ... comment for b
++
#+end_src diff
- Invoking : (insert "] = ...")
- Start point : 1052
- Moved to point: 1059
- : 36:11: ] = ...
- : ^
+ Start point : 1057
+ Moved to point: 1064
+ : 36:15: ] = ...
+ : ^
Buffer modified:
#+begin_src diff
--- start_contents
@@ -176,30 +174,32 @@
@@ -33,4 +33,4 @@
function ...
[ ...
- b ... comment for b
--
-+ ] = ...
+ b ... comment for b
+-
++ ] = ...
#+end_src diff
- Invoking : "C-m" = newline
- Start point : 1059
- Moved to point: 1064
+ Start point : 1064
+ Moved to point: 1065
: 37:4:
: ^
Buffer modified:
#+begin_src diff
--- start_contents
+++ end_contents
-@@ -34,3 +34,4 @@
+@@ -33,4 +33,5 @@
+ function ...
[ ...
- b ... comment for b
- ] = ...
+ b ... comment for b
+- ] = ...
++ ] = ...
+
#+end_src diff
- Invoking : (insert "indent_xr_fun5 ...")
- Start point : 1064
- Moved to point: 1082
+ Start point : 1065
+ Moved to point: 1083
: 37:22: indent_xr_fun5 ...
: ^
Buffer modified:
@@ -208,15 +208,15 @@
+++ end_contents
@@ -34,4 +34,4 @@
[ ...
- b ... comment for b
+ b ... comment for b
] = ...
-
+ indent_xr_fun5 ...
#+end_src diff
- Invoking : "C-m" = newline
- Start point : 1082
- Moved to point: 1087
+ Start point : 1083
+ Moved to point: 1088
: 38:4:
: ^
Buffer modified:
@@ -224,15 +224,15 @@
--- start_contents
+++ end_contents
@@ -35,3 +35,4 @@
- b ... comment for b
+ b ... comment for b
] = ...
indent_xr_fun5 ...
+
#+end_src diff
- Invoking : (insert "( ...")
- Start point : 1087
- Moved to point: 1092
+ Start point : 1088
+ Moved to point: 1093
: 38:9: ( ...
: ^
Buffer modified:
@@ -240,7 +240,7 @@
--- start_contents
+++ end_contents
@@ -35,4 +35,4 @@
- b ... comment for b
+ b ... comment for b
] = ...
indent_xr_fun5 ...
-
@@ -248,8 +248,8 @@
#+end_src diff
- Invoking : "C-m" = newline
- Start point : 1092
- Moved to point: 1098
+ Start point : 1093
+ Moved to point: 1099
: 39:5:
: ^
Buffer modified:
@@ -264,8 +264,8 @@
#+end_src diff
- Invoking : (insert "a ... comment for a")
- Start point : 1098
- Moved to point: 1117
+ Start point : 1099
+ Moved to point: 1118
: 39:24: a ... comment for a
: ^
Buffer modified:
@@ -281,8 +281,8 @@
#+end_src diff
- Invoking : "C-m" = newline
- Start point : 1117
- Moved to point: 1123
+ Start point : 1118
+ Moved to point: 1124
: 40:5:
: ^
Buffer modified:
@@ -297,8 +297,8 @@
#+end_src diff
- Invoking : (insert ")")
- Start point : 1123
- Moved to point: 1124
+ Start point : 1124
+ Moved to point: 1125
: 40:6: )
: ^
Buffer modified:
@@ -314,8 +314,8 @@
#+end_src diff
- Invoking : "C-m" = newline
- Start point : 1124
- Moved to point: 1128
+ Start point : 1125
+ Moved to point: 1129
: 41:4:
: ^
Buffer modified:
@@ -332,8 +332,8 @@
#+end_src diff
- Invoking : "C-m" = newline
- Start point : 1128
- Moved to point: 1129
+ Start point : 1129
+ Moved to point: 1130
: 42:4:
: ^
Buffer modified:
@@ -349,8 +349,8 @@
#+end_src diff
- Invoking : (insert "b=2*a;")
- Start point : 1129
- Moved to point: 1135
+ Start point : 1130
+ Moved to point: 1136
: 42:10: b=2*a;
: ^
Buffer modified:
@@ -366,8 +366,8 @@
#+end_src diff
- Invoking : "C-m" = newline
- Start point : 1135
- Moved to point: 1140
+ Start point : 1136
+ Moved to point: 1141
: 43:4:
: ^
Buffer modified:
@@ -382,8 +382,8 @@
#+end_src diff
- Invoking : (insert "end")
- Start point : 1140
- Moved to point: 1143
+ Start point : 1141
+ Moved to point: 1144
: 43:7: end
: ^
Buffer modified:
@@ -399,8 +399,8 @@
#+end_src diff
- Invoking : "C-m" = newline
- Start point : 1143
- Moved to point: 1140
+ Start point : 1144
+ Moved to point: 1141
: 44:0:
: ^
Buffer modified:
@@ -417,24 +417,9 @@
#+end_src diff
- Invoking : (indent-region (point-min) (point-max))
- Start point : 1140
- Moved to point: 1141
- : 44:0:
- : ^
- Buffer modified:
- #+begin_src diff
---- start_contents
-+++ end_contents
-@@ -32,7 +32,7 @@
- %}
- function ...
- [ ...
-- b ... comment for b
-+ b ... comment for b
- ] = ...
- indent_xr_fun5 ...
- ( ...
- #+end_src diff
+ Start point : 1141
+ No point movement
+ No buffer modifications
- Invoking : (re-search-backward "^fun")
Start point : 1141