9

I'd like to make changes to ~/.emacs.d/init.el that change my key bindings for clojure/cider mode and re-evaluate these changes without having to quit/restart emacs. This would make it easy to iteratively test new keybindings.

I mention clojure/cider specifically, but I haven't gotten this to work with modes other than emacs-lisp mode (i.e. org mode).

1

1 Answer 1

20

To reevaluate the entire init file type M-x eval-buffer in a buffer visiting it, or M-: (load-file user-init-file) to reload without visiting it.

However, if your intention is to iteratively add new keybindings or code to your running Emacs session I recommend not to evaluate the entire buffer but instead use C-M-x (aka eval-defun) to evaluate only the current function or top-level definition or M-x eval-region to evaluate selected code.

1
  • 1
    That is good advice. If you are in the habit of regularly reloading your entire init file, you should take care to ensure that it is idempotent, or you may get all kinds of unexpected results. Apr 20, 2016 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.