branch: elpa/typst-ts-mode commit 2b14377e248ac9a62bfad8d65b0274b6ac5a8a50 Author: Huan Thieu Nguyen <nguyenthieuh...@gmail.com> Commit: Huan Thieu Nguyen <nguyenthieuh...@gmail.com>
stub: comment out typst-ts-mode-return for now #42 --- typst-ts-editing.el | 117 +++++++++++++++++++++++++++------------------------- 1 file changed, 60 insertions(+), 57 deletions(-) diff --git a/typst-ts-editing.el b/typst-ts-editing.el index 8ccb82dd07..750e2efeaf 100644 --- a/typst-ts-editing.el +++ b/typst-ts-editing.el @@ -264,63 +264,66 @@ Using ARG argument will ignore the context and it will insert a heading instead. (t (typst-ts-mode-insert--heading node))))) -(defun typst-ts-mode-return (&optional arg) - "Handle RET depends on condition. -When prefix ARG is non-nil, call global return function." - (interactive "P") - (or - ;; FIXME: This kind of magic/electric behavior should probably be - ;; controllable via a custom var (and described in the docstring). - (when (and (null arg) (eolp)) - (let* (;; (cur-pos (point)) - ;; (cur-node (treesit-node-at cur-pos)) - ;; (cur-node-type (treesit-node-type cur-node)) - ;; (parent-node (treesit-node-parent cur-node)) ; could be nil - ;; (parent-node-type (treesit-node-type parent-node)) - (node (typst-ts-core-parent-util-type - (typst-ts-core-get-parent-of-node-at-bol-nonwhite) - "item" t t))) - ;; (message "%s %s" cur-node parent-node) - (cond - ;; on item node end - (node - (let* ((has-children (treesit-node-child node 1)) - (next-line-pos (line-beginning-position 2)) - (next-line-node - (typst-ts-core-get-parent-of-node-at-bol-nonwhite - next-line-pos)) - (next-line-top-node ; get container type or `item' type node - (typst-ts-core-parent-util-type - next-line-node - (regexp-opt '("code" "item")) - t))) - (if has-children - ;; example: - ;; - #[| <- return - ;; ] - (if (and next-line-top-node - ;; end of buffer situation (or next line is the end - ;; line (and no newline character)) - (not (equal - (line-number-at-pos next-line-pos) - (line-number-at-pos (point-max))))) - (call-interactively #'newline) - (typst-ts-mode-insert--item node)) - ;; no text means delete the item on current line: (item -) - (delete-region (line-beginning-position) (line-end-position)) - ;; whether the previous line is in an item - (let* ((prev-line-item-node - (typst-ts-core-parent-util-type - (let ((global-ret-function (global-key-binding (kbd "RET")))) - (if (not current-prefix-arg) - (call-interactively global-ret-function) - (if (yes-or-no-p - (format - "Execute function `%s' without/with the given prefix argument?" - global-ret-function)) - (let ((current-prefix-arg nil)) - (call-interactively global-ret-function)) - (call-interactively global-ret-function))))))) +(defun typst-ts-mode-retun (&optional _arg) + "Stub") + +;; (defun typst-ts-mode-return (&optional arg) +;; "Handle RET depends on condition. +;; When prefix ARG is non-nil, call global return function." +;; (interactive "P") +;; (or +;; ;; FIXME: This kind of magic/electric behavior should probably be +;; ;; controllable via a custom var (and described in the docstring). +;; (when (and (null arg) (eolp)) +;; (let* (;; (cur-pos (point)) +;; ;; (cur-node (treesit-node-at cur-pos)) +;; ;; (cur-node-type (treesit-node-type cur-node)) +;; ;; (parent-node (treesit-node-parent cur-node)) ; could be nil +;; ;; (parent-node-type (treesit-node-type parent-node)) +;; (node (typst-ts-core-parent-util-type +;; (typst-ts-core-get-parent-of-node-at-bol-nonwhite) +;; "item" t t))) +;; ;; (message "%s %s" cur-node parent-node) +;; (cond +;; ;; on item node end +;; (node +;; (let* ((has-children (treesit-node-child node 1)) +;; (next-line-pos (line-beginning-position 2)) +;; (next-line-node +;; (typst-ts-core-get-parent-of-node-at-bol-nonwhite +;; next-line-pos)) +;; (next-line-top-node ; get container type or `item' type node +;; (typst-ts-core-parent-util-type +;; next-line-node +;; (regexp-opt '("code" "item")) +;; t))) +;; (if has-children +;; ;; example: +;; ;; - #[| <- return +;; ;; ] +;; (if (and next-line-top-node +;; ;; end of buffer situation (or next line is the end +;; ;; line (and no newline character)) +;; (not (equal +;; (line-number-at-pos next-line-pos) +;; (line-number-at-pos (point-max))))) +;; (call-interactively #'newline) +;; (typst-ts-mode-insert--item node)) +;; ;; no text means delete the item on current line: (item -) +;; (delete-region (line-beginning-position) (line-end-position)) +;; ;; whether the previous line is in an item +;; (let* ((prev-line-item-node +;; (typst-ts-core-parent-util-type +;; (let ((global-ret-function (global-key-binding (kbd "RET")))) +;; (if (not current-prefix-arg) +;; (call-interactively global-ret-function) +;; (if (yes-or-no-p +;; (format +;; "Execute function `%s' without/with the given prefix argument?" +;; global-ret-function)) +;; (let ((current-prefix-arg nil)) +;; (call-interactively global-ret-function)) +;; (call-interactively global-ret-function)))))))))))))))) (defun typst-ts-mode-insert--item (node) "Insert an item after NODE.