startup.el: Don't override init.el custom of debug-ignored-errors

* lisp/startup.el (startup--load-user-init-file): Undo commit 4302bc9b0f.
Mimic the code we use for `debug-on-error` instead.
This commit is contained in:
Stefan Monnier 2023-06-26 11:25:14 -04:00
parent 748b1f1f48
commit 3a50773ab0

View file

@ -1025,13 +1025,21 @@ init-file, or to a default value if loading is not possible."
(debug-on-error-should-be-set nil)
(debug-on-error-initial
(if (eq init-file-debug t)
'startup
'startup--witness ;Dummy but recognizable non-nil value.
init-file-debug))
(d-i-e-from-init-file nil)
(d-i-e-initial
;; Use (startup--witness) instead of nil, so we can detect when the
;; init files set `debug-ignored-errors' to nil.
(if init-file-debug '(startup--witness) debug-ignored-errors))
;; The init file might contain byte-code with embedded NULs,
;; which can cause problems when read back, so disable nul
;; byte detection. (Bug#52554)
(inhibit-null-byte-detection t))
(let ((debug-on-error debug-on-error-initial))
(let ((debug-on-error debug-on-error-initial)
;; If they specified --debug-init, enter the debugger
;; on any error whatsoever.
(debug-ignored-errors d-i-e-initial))
(condition-case-unless-debug error
(when init-file-user
(let ((init-file-name (funcall filename-function)))
@ -1041,17 +1049,11 @@ init-file, or to a default value if loading is not possible."
;; `user-init-file'.
(setq user-init-file t)
(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)
"el")
(file-name-sans-extension init-file-name)
init-file-name)
'noerror 'nomessage)))
(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)))
@ -1059,11 +1061,7 @@ 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)))
(let ((debug-ignored-errors
(if (and init-file-debug (not noninteractive))
nil
debug-ignored-errors)))
(load alt-file 'noerror 'nomessage))))
(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
@ -1102,11 +1100,7 @@ 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)
(debug-ignored-errors
(if (and init-file-debug (not noninteractive))
nil
debug-ignored-errors)))
(let ((inhibit-startup-screen nil))
(load "default" 'noerror 'nomessage))))
(error
(display-warning
@ -1126,10 +1120,14 @@ the `--debug-init' option to view a complete error backtrace."
;; If we can tell that the init file altered debug-on-error,
;; arrange to preserve the value that it set up.
(or (eq debug-ignored-errors d-i-e-initial)
(setq d-i-e-from-init-file (list debug-ignored-errors)))
(or (eq debug-on-error debug-on-error-initial)
(setq debug-on-error-should-be-set t
debug-on-error-from-init-file debug-on-error)))
(when d-i-e-from-init-file
(setq debug-ignored-errors (car d-i-e-from-init-file)))
(when debug-on-error-should-be-set
(setq debug-on-error debug-on-error-from-init-file))))