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)
This commit is contained in:
Eli Zaretskii 2023-06-21 16:27:42 +03:00
parent f16064f6bc
commit 4302bc9b0f

View file

@ -1041,11 +1041,17 @@ init-file, or to a default value if loading is not possible."
;; `user-init-file'. ;; `user-init-file'.
(setq user-init-file t) (setq user-init-file t)
(when init-file-name (when init-file-name
;; 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) (load (if (equal (file-name-extension init-file-name)
"el") "el")
(file-name-sans-extension init-file-name) (file-name-sans-extension init-file-name)
init-file-name) init-file-name)
'noerror 'nomessage)) 'noerror 'nomessage)))
(when (and (eq user-init-file t) alternate-filename-function) (when (and (eq user-init-file t) alternate-filename-function)
(let ((alt-file (funcall 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)) (setq init-file-name alt-file))
(and (equal (file-name-extension alt-file) "el") (and (equal (file-name-extension alt-file) "el")
(setq alt-file (file-name-sans-extension alt-file))) (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 ;; If we did not find the user's init file, set
;; user-init-file conclusively. Don't let it be ;; 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)) (not inhibit-default-init))
;; Prevent default.el from changing the value of ;; Prevent default.el from changing the value of
;; `inhibit-startup-screen'. ;; `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)))) (load "default" 'noerror 'nomessage))))
(error (error
(display-warning (display-warning