Skip to content

Commit 220c7a1

Browse files
committed
1 parent 1cb0bc4 commit 220c7a1

27 files changed

+103
-58
lines changed

matlab-ts-mode.el

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -889,6 +889,19 @@ expression."
889889
nil
890890
0))
891891

892+
(defun matlab-ts-mode--indent-continuation-level (_node parent _bol &rest _)
893+
"Compute the continuation level for node with PARENT.
894+
This is `matlab-ts-mode--indent-level' or 0 when in a
895+
cell or matrix row."
896+
(let ((row-node (let ((n parent))
897+
(while (and n
898+
(not (string= (treesit-node-type n) "row")))
899+
(setq n (treesit-node-parent n)))
900+
n)))
901+
(if row-node
902+
0
903+
matlab-ts-mode--indent-level)))
904+
892905
(defvar matlab-ts-mode--indent-rules
893906
`((matlab
894907

@@ -1095,12 +1108,14 @@ expression."
10951108
;; a (1,1) ... asdf
10961109
;; TAB> double
10971110
;; end
1098-
;; See: test-matlab-ts-mode-indent-files/indent_line_continuation.m
1111+
;; See: tests/test-matlab-ts-mode-indent-files/indent_line_continuation.m
1112+
;; See: tests/test-matlab-ts-mode-indent-files/indent_line_continuation_row.m
10991113
((lambda (node parent bol)
11001114
(let ((prev-sibling (treesit-node-prev-sibling node)))
11011115
(and prev-sibling
11021116
(string= (treesit-node-type prev-sibling) "line_continuation"))))
1103-
parent ,matlab-ts-mode--indent-level)
1117+
;; parent ,matlab-ts-mode--indent-level)
1118+
parent ,#'matlab-ts-mode--indent-continuation-level)
11041119

11051120
;; I-Rule: handle syntax errors by not indenting
11061121
;; See: tests/test-matlab-ts-mode-indent-files/indent_nested_error.m
@@ -1751,18 +1766,27 @@ is t, add the following to an Init File (e.g. `user-init-file' or
17511766
;; (inserting text), so we also setup a post-command-hook to insert a newline if needed.
17521767
(setq-local require-final-newline 'visit-save)
17531768
(add-hook 'post-command-hook #'matlab-ts-mode--post-command-newline -99 t)
1754-
1769+
17551770
;; TODO the MATLAB menu items from matlab.el, e.g. debugging, etc.
17561771
;; - will need to update matlab-shell.el to either use matlab.el or matlab-ts-mode.el
17571772
;;
17581773
;; TODO update matlab-ts-mode--builtins.el. I generated using R2025a installation, though I
17591774
;; think it was missing a few toolboxes.
1760-
;;
1775+
;;
17611776
;; TODO double check t-utils.el help, extract the help and put in treesit how to
17621777
;;
17631778
;; TODO double check indent rules to see if they can be simplified
17641779
;; TODO update --indent-rules to have See: test file comments.
1765-
1780+
;;
1781+
;; TODO indent
1782+
;; mat = [1, 2; ...
1783+
;; 3, 4];
1784+
;; TODO indent
1785+
;; function a=foo
1786+
;; a = ...
1787+
;; TAB>
1788+
;; ^ <== should be here
1789+
;; end
17661790
(treesit-major-mode-setup)
17671791

17681792
;; Correct forward-sexp setup created by `treesit-major-mode' so that in comments we do normal

tests/t-utils.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ baseline check fails."
299299
(when (not error-msg)
300300
(if (not expected)
301301
(setq error-msg (list
302-
(format "Baseline for %s does not exists." lang-file)
302+
(format "Baseline for %s does not exist." lang-file)
303303
(format "Got: %s" got-file)
304304
(format "If got looks good, rename it to: %s" expected-file)))
305305
(setq error-msg (list
@@ -719,7 +719,7 @@ a character for each face setup by font-lock. CODE_TO_FACE is an alist
719719
where each elment is (CHAR . FACE). TEST-NAME is used when displaying
720720
messages.
721721
722-
If NAME_expected.txt does not exists or doesn't match the results we
722+
If NAME_expected.txt does not exist or doesn't match the results we
723723
got, a NAME_expected.txt~ will be generated. After reviewing
724724
NAME_expected.txt~, you should rename it to NAME_expected.txt or fix
725725
your code and rerun the test.

tests/test-matlab-ts-mode-font-lock-files/font_lock_continuation.skip.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/test-matlab-ts-mode-font-lock-files/font_lock_continuation_fcn.skip.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/test-matlab-ts-mode-font-lock-files/font_lock_continuation_fcn_g2.skip.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/test-matlab-ts-mode-font-lock-files/font_lock_continuation_multiArgFcn.skip.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/test-matlab-ts-mode-font-lock-files/font_lock_error_missing_continuation.skip.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/test-matlab-ts-mode-font-lock-files/font_lock_error_missing_continuation_expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ c ccc ccccccccc ccc
22
c ccccccc cccccccccccc cccccc cccccc cc ccccccc ccccc
33
c cccccccccccc ccccc cc cccccc ccccc ccc ccc ccc ccccc ccc cccccc
44
kkkkkkkk ffffffffffffffffffffffffffffffffffffb
5-
vv
5+
ww
66
b
77
BBBBbBBBBBBBbddbbD
88
kkk

tests/test-matlab-ts-mode-font-lock-files/font_lock_fcn_arguments.skip.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/test-matlab-ts-mode-imenu-files/imenu_f0.skip.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)