diff options
author | Artur Malabarba <bruce.connor.am@gmail.com> | 2016-02-14 14:47:15 +0000 |
---|---|---|
committer | Artur Malabarba <bruce.connor.am@gmail.com> | 2016-02-14 16:14:27 +0000 |
commit | 93e80f057f768788213e4a9192ea39cb620c2450 (patch) | |
tree | 640febffe5c11a1a8cec75e90cdbbd9c60cf9bd5 /cider-mode.el | |
parent | 26485a0ad647455773ad508e97c06d8e86ecf2f4 (diff) |
[Fix #1562] Actually disable cider-mode when it gets disabled
Previously we just always enabled it.
Diffstat (limited to 'cider-mode.el')
-rw-r--r-- | cider-mode.el | 39 |
1 files changed, 24 insertions, 15 deletions
diff --git a/cider-mode.el b/cider-mode.el index e3a553de..481b2d8a 100644 --- a/cider-mode.el +++ b/cider-mode.el @@ -453,10 +453,7 @@ namespace itself." (cider--compile-font-lock-keywords symbols (cider-resolve-ns-symbols (cider-resolve-core-ns)))) (font-lock-add-keywords nil cider--dynamic-font-lock-keywords 'end)) - (if (fboundp 'font-lock-flush) - (font-lock-flush) - (with-no-warnings - (font-lock-fontify-buffer))))) + (cider--font-lock-flush))) ;;; Detecting local variables @@ -593,17 +590,29 @@ property." nil cider-mode-line cider-mode-map - (cider-eldoc-setup) - (make-local-variable 'completion-at-point-functions) - (add-to-list 'completion-at-point-functions - #'cider-complete-at-point) - (font-lock-add-keywords nil cider--static-font-lock-keywords) - (cider-refresh-dynamic-font-lock) - (setq-local font-lock-fontify-region-function - (cider--wrap-fontify-locals font-lock-fontify-region-function)) - (when cider-dynamic-indentation - (setq-local clojure-get-indent-function #'cider--get-symbol-indent)) - (setq next-error-function #'cider-jump-to-compilation-error)) + (if cider-mode + (progn + (cider-eldoc-setup) + (make-local-variable 'completion-at-point-functions) + (add-to-list 'completion-at-point-functions + #'cider-complete-at-point) + (font-lock-add-keywords nil cider--static-font-lock-keywords) + (cider-refresh-dynamic-font-lock) + ;; `font-lock-mode' might get enabled after `cider-mode'. + (add-hook 'font-lock-mode-hook #'cider-refresh-dynamic-font-lock nil 'local) + (setq-local font-lock-fontify-region-function + (cider--wrap-fontify-locals font-lock-fontify-region-function)) + (when cider-dynamic-indentation + (setq-local clojure-get-indent-function #'cider--get-symbol-indent)) + (setq next-error-function #'cider-jump-to-compilation-error)) + (mapc #'kill-local-variable '(completion-at-point-functions + next-error-function + font-lock-fontify-region-function + clojure-get-indent-function)) + (remove-hook 'font-lock-mode-hook #'cider-refresh-dynamic-font-lock 'local) + (font-lock-remove-keywords nil cider--dynamic-font-lock-keywords) + (font-lock-remove-keywords nil cider--static-font-lock-keywords) + (cider--font-lock-flush))) (defun cider-set-buffer-ns (ns) "Set this buffer's namespace to NS and refresh font-locking." |