From 4302bc9b0f120491d1a5d20c3af250d01b40bf47 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Wed, 21 Jun 2023 16:27:42 +0300 Subject: [PATCH] Allow --debug-init to debug all errors in init files * lisp/startup.el (startup--load-user-init-file): Ignore the value of 'debug-ignored-errors' when loading init files if we were invoked interactively with --debug-init. (Bug#64163) --- lisp/startup.el | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/lisp/startup.el b/lisp/startup.el index 835ad785af1..484c8f57a9f 100644 --- a/lisp/startup.el +++ b/lisp/startup.el @@ -1041,11 +1041,17 @@ init-file, or to a default value if loading is not possible." ;; `user-init-file'. (setq user-init-file t) (when init-file-name - (load (if (equal (file-name-extension init-file-name) - "el") - (file-name-sans-extension init-file-name) - init-file-name) - 'noerror 'nomessage)) + ;; If they specified --debug-init, enter the debugger + ;; on any error whatsoever. + (let ((debug-ignored-errors + (if (and init-file-debug (not noninteractive)) + nil + debug-ignored-errors))) + (load (if (equal (file-name-extension init-file-name) + "el") + (file-name-sans-extension init-file-name) + init-file-name) + 'noerror 'nomessage))) (when (and (eq user-init-file t) alternate-filename-function) (let ((alt-file (funcall alternate-filename-function))) @@ -1053,7 +1059,11 @@ init-file, or to a default value if loading is not possible." (setq init-file-name alt-file)) (and (equal (file-name-extension alt-file) "el") (setq alt-file (file-name-sans-extension alt-file))) - (load alt-file 'noerror 'nomessage))) + (let ((debug-ignored-errors + (if (and init-file-debug (not noninteractive)) + nil + debug-ignored-errors))) + (load alt-file 'noerror 'nomessage)))) ;; If we did not find the user's init file, set ;; user-init-file conclusively. Don't let it be @@ -1092,7 +1102,11 @@ init-file, or to a default value if loading is not possible." (not inhibit-default-init)) ;; Prevent default.el from changing the value of ;; `inhibit-startup-screen'. - (let ((inhibit-startup-screen nil)) + (let ((inhibit-startup-screen nil) + (debug-ignored-errors + (if (and init-file-debug (not noninteractive)) + nil + debug-ignored-errors))) (load "default" 'noerror 'nomessage)))) (error (display-warning -- 2.39.2