branch: externals/matlab-mode
commit c6ad3759922da1579af9ab7c447968552ea16269
Author: John Ciolfi <[email protected]>
Commit: John Ciolfi <[email protected]>
matlab-ts-mode: use post-self-insert-hook to insert final newline
This is more targeted and likely more efficient.
---
matlab-ts-mode.el | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/matlab-ts-mode.el b/matlab-ts-mode.el
index e9c9e7a04f..81a2af9de5 100644
--- a/matlab-ts-mode.el
+++ b/matlab-ts-mode.el
@@ -2428,11 +2428,11 @@ THERE-END MISMATCH) or nil."
"Ensure buffer always has a newline.
The matlab tree-sitter requires a newline, see
https://github.com/acristoffers/tree-sitter-matlab/issues/34"
- (when (and (eq this-command 'self-insert-command)
- (eq major-mode 'matlab-ts-mode))
+ (when (eq major-mode 'matlab-ts-mode)
(save-excursion
(goto-char (point-max))
(when (not (= (char-before) ?\n))
+ (message "xxx adding newline")
(insert "\n")))))
;;; MLint Flycheck
@@ -2851,9 +2851,9 @@ is t, add the following to an Init File (e.g.
`user-init-file' or
;; Final newline. The matlab tree-sitter requires a final newline, see
;; https://github.com/acristoffers/tree-sitter-matlab/issues/34
;; Setting require-final-newline to 'visit-save doesn't guarantee we have
a newline when typing
- ;; (inserting text), so we also setup a post-command-hook to insert a
newline if needed.
+ ;; code into the buffer, so we also setup a post-command-hook to insert a
newline if needed.
(setq-local require-final-newline 'visit-save)
- (add-hook 'post-command-hook #'matlab-ts-mode--post-command-newline -99 t)
+ (add-hook 'post-self-insert-hook #'matlab-ts-mode--post-command-newline
-99 t)
;; give each file it's own parameter history
(setq-local matlab-shell-save-and-go-history '("()"))
@@ -2891,7 +2891,6 @@ is t, add the following to an Init File (e.g.
`user-init-file' or
;;
;; TODO add rename identifier
-
(treesit-major-mode-setup)
;; Correct forward-sexp setup created by `treesit-major-mode' so that for
parenthesis, brackets,