Search code examples
emacsclojureelispemacs24

How can I evaluate something in Emacs init.el file?


Every time I open .clj file, I have to run

M-x cider-jack-in

to enable Clojure auto-completion in code file.

Can I make Emacs automatically run the command when it starts?


Solution

  • Try this:

    (require 'cider)
    (defun maybe-cider-jack-in ()
      (unless (ignore-errors
                (nrepl-current-connection-buffer))
        (cider-jack-in)))
    
    (add-hook 'clojure-mode-hook 'maybe-cider-jack-in)