How can I get Emacs to reload all my definitions that I have updated in .emacs
without restarting Emacs?
You can set key-binding for emacs like this
;; reload emacs configuration
(defun reload-init-file ()
(interactive)
(load-file "~/.emacs"))
(global-set-key (kbd "C-c r") 'reload-init-file)
Hope this will help!
Here is a quick and easy way to quick test your config. You can also use C-x C-e
at the end of specific lisp to execute certain function individually.
C-x C-e runs the command eval-last-sexp (found in global-map), which is an interactive compiled Lisp function.
It is bound to C-x C-e.
(eval-last-sexp EVAL-LAST-SEXP-ARG-INTERNAL)
Evaluate sexp before point; print value in the echo area. Interactively, with prefix argument, print output into current buffer.
Normally, this function truncates long output according to the value of the variables ‘eval-expression-print-length’ and ‘eval-expression-print-level’. With a prefix argument of zero, however, there is no such truncation. Such a prefix argument also causes integers to be printed in several additional formats (octal, hexadecimal, and character).
If ‘eval-expression-debug-on-error’ is non-nil, which is the default, this command arranges for all errors to enter the debugger.
Beside commands like M-x eval-buffer or M-x load-file you can restart a fresh emacs from the command line:
emacs -q --load "init.el"
Usage example stackoverflow.com/questions/44959535/company-backends-in-gnu-emacs/
Although M-x eval-buffer
will work you may run into problems with toggles and other similar things. A better approach might be to "mark" or highlight whats new in your .emacs (or even scratch buffer if your just messing around) and then M-x eval-region
. Hope this helps.
You can use the command load-file (M-x load-file
, then press return twice to accept the default filename, which is the current file being edited).
You can also just move the point to the end of any sexp and press C-xC-e to execute just that sexp. Usually it's not necessary to reload the whole file if you're just changing a line or two.
M-x load-file
~/.emacs