When debugging my #emacs configuration, I find it is more useful to put (setq debug-on-error t)
at the beginning of your init.el
rather than using command line argument to start Emacs like emacs --debug-init
. The reason behind this is that --debug-init
seemingly only affect Emacs between starting Emacs and Emacs finishing loading your configuration, whereas your configuration may also affect Emacs’s behavior directly after loading. For example, you add a function to prog-mode-hook
, and inside the function, u use variable buffer-file-name
. Then Emacs may not behave well cuz scratch
buffer is lisp-interaction-mode
which is a derived mode of prog-mode
and it is directly loaded after Emacs initialization.