5

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).

16

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
    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. – Harald Hanche-Olsen Apr 20 '16 at 15:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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