Activate debugger of errors during Emacs initialization. This allows to get backtrace without passing --debug-init.
--- a/.emacs-my Sat Jan 30 20:27:52 2021 +0200
+++ b/.emacs-my Sat Jan 30 22:41:51 2021 +0200
@@ -139,22 +139,6 @@
;; Prevent Emacs from loading 'default.el', which is loaded after '.emacs'.
(setq inhibit-default-init nil) ; t/nil
-(defun my-debug (mode)
- "With prefix enable enter to debuger and show backtrace when
-problems occur, with double prefix enable debugging on event and
-signal, else disable breaking to debugger."
- (interactive "P")
- (let ( (lvl1 (not (not mode))) (lvl2 (equal mode '(16))) )
- (setq debug-on-error lvl1)
- ;; Get trace when press C-g.
- (setq debug-on-quit lvl1)
- (setq debug-on-event lvl2)
- (setq debug-on-signal lvl2)
- (cond
- (lvl2 (message "Debugging on quit/event/signal..."))
- (lvl1 (message "Debugging on quit..."))
- (t (message "Debugging disabled...")))))
-
(defun my-eval-buffer ()
"Evaluate entire buffer with re-assigning values to `defvar' / `defcustom'.
Useful during package development."
@@ -177,8 +161,6 @@
(insert-file-contents (locate-file library load-path '("" ".el")))
(my-eval-buffer)))
-(my-debug nil)
-
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "user info")
--- a/init.el Sat Jan 30 20:27:52 2021 +0200
+++ b/init.el Sat Jan 30 22:41:51 2021 +0200
@@ -7,6 +7,36 @@
;; For load order see README.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(message "turn on debugger during loading")
+
+(defun my-debug (mode)
+ "With any prefix enables entering into a debuger and shows the
+backtrace when problems occur. Also activates entering into
+debugger on C-g.
+
+With double prefix (or any number) additonally enable debugging
+on events and signals.
+
+Without prefix (or `nil' argument) disables entering into the
+debugger."
+ (interactive "P")
+ (let ( (lvl1 (not (not mode)))
+ (lvl2 (or (equal mode '(16)) (numberp mode))) )
+ (setq debug-on-error lvl1)
+ ;; Get trace when press C-g.
+ (setq debug-on-quit lvl1)
+ (setq debug-on-event lvl2)
+ (setq debug-on-signal lvl2)
+ (cond
+ (lvl2 (message "Debugging on quit/event/signal..."))
+ (lvl1 (message "Debugging on quit..."))
+ (t (message "Debugging disabled...")))))
+
+;; Instead of launching Emacs with "--debug-init" I enable entering into
+;; debugger on error & on C-g.
+(my-debug t)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(message "load-path")
(load "~/.emacs.d/.emacs-defs")
@@ -32,3 +62,8 @@
(when my-profiler-enabled
(profiler-report)
(profiler-stop))
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(message "turn off debugger after loading")
+
+(my-debug nil)