Emacs can be started with the -debug-init command-line option. But how can I enable the command line option from within my .emacs file?


1 Answer 1


The main effect of --debug-init is to set debug-on-error to t during the evaluation of the init file. You can do this manually: put

(setq debug-on-error t)

at the beginning of your .emacs, and

(setq debug-on-error nil)

at the end.

This is not strictly identical to always running Emacs with --debug-init. It only catches errors raised while loading your init file, not errors from the system init files. Also you'll still get the “An error occurred while loading …” warning after you exit the debugger. But you do get the debugger invocation with the backtrace if your init file causes an error, and that's the important thing.

Your Answer

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

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