File tree 1 file changed +27
-0
lines changed
1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -329,6 +329,33 @@ instead of to `clojure-mode-map'."
329
329
(clojure-font-lock-setup)
330
330
(add-hook 'paredit-mode-hook #'clojure-paredit-setup ))
331
331
332
+ (defcustom clojure-do-warnings t
333
+ " If non-nil, `clojure-mode' will warn of possible user errors."
334
+ :type 'boolean
335
+ :package-version '(clojure-mode " 5.3" ))
336
+
337
+ (defun clojure--check-wrong-major-mode ()
338
+ " Check if the current major-mode matches the file extension.
339
+ If it doesn't, issue a warning if `clojure-do-warnings' is
340
+ non-nil."
341
+ (when (and clojure-do-warnings
342
+ (stringp (buffer-file-name )))
343
+ (let ((problem
344
+ (cond ((and (string-match " \\ .cljs\\ '" (buffer-file-name ))
345
+ (not (eq major-mode 'clojurescript-mode )))
346
+ 'clojurescript-mode )
347
+ ((and (string-match " \\ .clj[cx]\\ '" (buffer-file-name ))
348
+ (not (eq major-mode 'clojurec-mode )))
349
+ 'clojurec-mode ))))
350
+ (when problem
351
+ (message " [WARNING] Something in your configuration activated `%s' instead of `%s' in this buffer.%s%s "
352
+ major-mode
353
+ problem
354
+ " \n This is could cause problems."
355
+ " \n (See `clojure-do-warnings' to disable this message.)" )))))
356
+
357
+ (add-hook 'clojure-mode-hook #'clojure--check-wrong-major-mode )
358
+
332
359
(defsubst clojure-in-docstring-p ()
333
360
" Check whether point is in a docstring."
334
361
(eq (get-text-property (point ) 'face ) 'font-lock-doc-face ))
You can’t perform that action at this time.
0 commit comments