(add-hook 'cider-mode-hook '(lambda () (add-hook 'after-save-hook '(lambda () (if (and (boundp 'cider-mode) cider-mode) (cider-namespace-refresh) ))))) (defun cider-namespace-refresh () (interactive) (cider-interactive-eval "(require 'clojure.tools.namespace.repl) (clojure.tools.namespace.repl/refresh)")) (define-key clojure-mode-map (kbd "C-c C-r") 'cider-namespace-refresh)
Additionally, you can now run the refresh command manually, by hitting C-c C-r.
Update: I changed the after-save-hook to only trigger if we are in a buffer that has cider-mode enabled. Otherwise every save command in Emacs would have triggered the refresh!
Great tip! Is there a way to limit this to clj files, not ClojureScript (cljs) files?
ReplyDelete