@@ -119,6 +119,18 @@ double quotes on the third column."
119
119
:safe #'booleanp
120
120
:package-version '(clojure-ts-mode . " 0.2.3" ))
121
121
122
+ (defcustom clojure-ts-auto-redirect t
123
+ " When non-nil, redirect all `clojure-mode' buffers to `clojure-ts-mode' ."
124
+ :safe #'booleanp
125
+ :type 'boolean
126
+ :package-version '(clojure-ts-mode . " 0.2.4" ))
127
+
128
+ (defvar clojure-ts-mode-remappings
129
+ '((clojure-mode . clojure-ts-mode)
130
+ (clojurescript-mode . clojure-ts-clojurescript-mode)
131
+ (clojurec-mode . clojure-ts-clojurec-mode))
132
+ " Alist of entries to `major-mode-remap-alist' ." )
133
+
122
134
(defvar clojure-ts--debug nil
123
135
" Enables debugging messages, shows current node in mode-line.
124
136
Only intended for use at development time." )
@@ -1080,13 +1092,24 @@ See `clojure-ts--font-lock-settings' for usage of MARKDOWN-AVAILABLE."
1080
1092
(add-to-list 'auto-mode-alist '(" \\ .cljd\\ '" . clojure-ts-clojuredart-mode))
1081
1093
(add-to-list 'auto-mode-alist '(" \\ .jank\\ '" . clojure-ts-jank-mode)))
1082
1094
1095
+ (defun clojure-ts-activate ()
1096
+ " Redirect all `clojure-mode' buffers to use `clojure-ts-mode' ."
1097
+ (interactive )
1098
+ (dolist (entry clojure-ts-mode-remappings)
1099
+ (add-to-list 'major-mode-remap-alist entry)))
1100
+
1101
+ (defun clojure-ts-deactivate ()
1102
+ " Revert the redirecting of of `clojure-mode' buffers to `clojure-ts-mode' ."
1103
+ (interactive )
1104
+ (dolist (entry clojure-ts-mode-remappings)
1105
+ (setq major-mode-remap-alist (remove entry major-mode-remap-alist))))
1106
+
1083
1107
(if (treesit-available-p)
1084
1108
; ; Redirect clojure-mode to clojure-ts-mode if clojure-mode is present
1085
1109
(if (require 'clojure-mode nil 'noerror )
1086
1110
(progn
1087
- (add-to-list 'major-mode-remap-alist '(clojure-mode . clojure-ts-mode))
1088
- (add-to-list 'major-mode-remap-alist '(clojurescript-mode . clojure-ts-clojurescript-mode))
1089
- (add-to-list 'major-mode-remap-alist '(clojurec-mode . clojure-ts-clojurec-mode))
1111
+ (when clojure-ts-auto-redirect
1112
+ (clojure-ts-activate))
1090
1113
(clojure-ts--register-novel-modes))
1091
1114
; ; When Clojure-mode is not present, setup auto-modes ourselves
1092
1115
(progn
0 commit comments