branch: elpa/typescript-mode
commit 6eaddf6c17bf4c4d80bcd042e5edeba7b84ad503
Author: Louis-Dominique Dubeau <[email protected]>
Commit: Louis-Dominique Dubeau <[email protected]>
Drop the custom insert-and-indent code in favor of electric-indent.
The custom code cause problems when delete-selection-mode and
smartparens-mode
were used together. That was probably one example of larger compatibility
issues
with the rest of the ecosystem. Letting electric-indent do the work that the
custom code did solves the problem.
---
typescript-mode.el | 20 +++-----------------
1 file changed, 3 insertions(+), 17 deletions(-)
diff --git a/typescript-mode.el b/typescript-mode.el
index 633aac1e20..b4632ba0dd 100644
--- a/typescript-mode.el
+++ b/typescript-mode.el
@@ -743,29 +743,12 @@ the string from a plain string to a template."
(defvar typescript-mode-map
(let ((keymap (make-sparse-keymap)))
- (dolist (key '("{" "}" "(" ")" ":" ";" ","))
- (define-key keymap key #'typescript-insert-and-indent))
(dolist (key '("\"" "\'"))
(define-key keymap key #'typescript-insert-and-autoconvert-to-template))
(define-key keymap (kbd "C-c '") #'typescript-convert-to-template)
keymap)
"Keymap for `typescript-mode'.")
-(defun typescript-insert-and-indent (key)
- "Run the command bound to KEY, and indent if necessary.
-Indentation does not take place if point is in a string or
-comment."
- (interactive (list (this-command-keys)))
- (call-interactively (lookup-key (current-global-map) key))
- (let ((syntax (save-restriction (widen) (syntax-ppss))))
- (when (or (and (not (nth 8 syntax))
- typescript-auto-indent-flag)
- (and (nth 4 syntax)
- (eq (current-column)
- (1+ (current-indentation)))))
- (indent-according-to-mode))))
-(put 'typescript-insert-and-indent 'delete-selection t)
-
(defun typescript-insert-and-autoconvert-to-template (key)
"Run the command bount to KEY, and autoconvert to template if necessary."
(interactive (list (this-command-keys)))
@@ -2845,6 +2828,9 @@ Key bindings:
c-comment-start-regexp "/[*/]\\|\\s!"
comment-start-skip "\\(//+\\|/\\*+\\)\\s *")
+ (setq-local electric-indent-chars
+ (append "{}():;," electric-indent-chars))
+
(let ((c-buffer-is-cc-mode t))
;; FIXME: These are normally set by `c-basic-common-init'. Should
;; we call it instead? (Bug#6071)