Skip to content

Commit ef9fbcb

Browse files
committed
matlab-ts-mode: add a few todo items
1 parent a15e91b commit ef9fbcb

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

matlab-ts-mode.el

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -829,6 +829,14 @@ For optional _NODE, PARENT, and _BOL see `treesit-simple-indent-rules'."
829829
))))))
830830
matlab-ts-mode--function-indent-level)
831831

832+
;; TODO - keep or rm matlab-ts-mode--do-functions-have-end (it's not currently used)
833+
(defun matlab-ts-mode--do-functions-have-end ()
834+
"Are functions terminated with an end keyword?"
835+
;; matlab-ts-mode--function-indent-level is setup when we enter matlab-ts-mode
836+
(cl-assert (not (eq matlab-ts-mode--function-indent-level 'unset)))
837+
;; A 0 indicates functions are not terminated by an end keyword
838+
(not (= matlab-ts-mode--function-indent-level 0)))
839+
832840
(defun matlab-ts-mode--prev-real-line (_n _p bol &rest _)
833841
"Return point of first non-whitespace looking backward.
834842
BOL, beginning-of-line point, is where to start from."
@@ -1112,6 +1120,86 @@ expression."
11121120

11131121
;;; Thing settings for movement, etc.
11141122

1123+
1124+
;; TODO should we use following for M-a, M-e?
1125+
;; This needs tune up, but could workout better than using matlab-ts-mode--thing-settings
1126+
;;
1127+
;; (defvar matlab-ts-mode--statements-ht
1128+
;; #s(hash-table
1129+
;; test equal
1130+
;; data ("arguments_statement" t
1131+
;; "assignment" t
1132+
;; "lambda" t
1133+
;; "class_definition" t
1134+
;; "enumeration" t
1135+
;; "events" t
1136+
;; "for_statement" t
1137+
;; "function_definition" t
1138+
;; "if_statement" t
1139+
;; "methods" t
1140+
;; "property" t
1141+
;; "properties" t
1142+
;; "spmd_statement" t
1143+
;; "switch_statement" t
1144+
;; "try_statement" t
1145+
;; "while_statement" t))
1146+
;; "MATLAB command statements.")
1147+
;;
1148+
;; (cl-defun matlab-ts-mode-beginning-of-statement (&optional goto-end)
1149+
;; "Move to the beginning of a command statement.
1150+
;; If optional GOTO-END is \\='end, move to end of the current statement.
1151+
;;
1152+
;; We define a command statement to be a complete syntatic unit that has
1153+
;; a start and end. For example, if point is in an assigment statement
1154+
;; var = ...
1155+
;; 1;
1156+
;; move point to the \"v\" when GOTO-END is nil, otherwise move to the
1157+
;; \";\". If point is in an if statement, move to the start or end of
1158+
;; that. Likewise for other command statements.
1159+
;;
1160+
;; The point is moved to the start or end of the innermost statement that
1161+
;; the point is on. No movement is performed if point is not in a
1162+
;; statement. This can occur when there are syntax errors or the buffer
1163+
;; has no content.
1164+
;;
1165+
;; Returns nil if not in a statement, otherwise the `point' which
1166+
;; will be a new point if the starting point was not at the start
1167+
;; or end of the command statement."
1168+
;; (interactive)
1169+
;;
1170+
;; (cl-assert (or (not goto-end) (eq goto-end 'end)))
1171+
;;
1172+
;; (let ((node (treesit-node-at (point))))
1173+
;;
1174+
;; (when (and (> (point) 1)
1175+
;; (equal (treesit-node-type node) "\n")
1176+
;; (re-search-backward "[^ \t\n\r]" nil t))
1177+
;; (setq node (treesit-node-at (point))))
1178+
;;
1179+
;; (while (and node
1180+
;; (let ((type (treesit-node-type node)))
1181+
;; (when (equal type "ERROR")
1182+
;; ;; No movement if we have a syntax error
1183+
;; (message "Not in statement due to syntax error.")
1184+
;; (cl-return nil))
1185+
;; (not (gethash type matlab-ts-mode--statements-ht))))
1186+
;; (setq node (treesit-node-parent node)))
1187+
;;
1188+
;; (when (not node)
1189+
;; (message "Not in a statement.")
1190+
;; (cl-return))
1191+
;;
1192+
;; (when node
1193+
;; (goto-char (if (eq goto-end 'end)
1194+
;; (treesit-node-end node)
1195+
;; (treesit-node-start node))))))
1196+
;;
1197+
;; (defun matlab-ts-mode-end-of-statement ()
1198+
;; "Move to the end of a command statement.
1199+
;; This is the opposite of `matlab-ts-mode-beginning-of-statement'."
1200+
;; (interactive)
1201+
;; (matlab-ts-mode-beginning-of-statement 'end))
1202+
11151203
(defvar matlab-ts-mode--thing-settings
11161204
`((matlab
11171205
(defun ,(rx bos "function_definition" eos))

0 commit comments

Comments
 (0)