unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 64163@debbugs.gnu.org, iota@whxvd.name
Subject: bug#64163: 29.0.92; Syntactic errors in early init when --debug-init is on
Date: Tue, 20 Jun 2023 13:07:46 -0400	[thread overview]
Message-ID: <jwv352myt84.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <83pm5q5dc3.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 20 Jun 2023 19:05:16 +0300")

>> IOW `--debug-init` should be the one that sets `debug-ignored-errors` to
>> nil
>
> So you are saying it should be condition on init-file-debug being
> non-nil?

Yup.

> Incidentally, do you happen to know the difference between that
> variable having the value t and 'startup'?

I'm not familiar with this code, no.

AFAICT, `startup` is a special value for `debug-on-error-initial` rather
than for `init-file-debug`.

I expect this is intended to be a value to which noone would set
`debug-on-error`, tho it would make sense to use a more verbose/unlikely
value, both to better detect user settings of `debug-on-error` and to
help document the code.

Maybe something like the patch below (I also renamed the local
variables so they don't look like global variables).


        Stefan


diff --git a/lisp/startup.el b/lisp/startup.el
index 835ad785af1..5b842055c58 100644
--- a/lisp/startup.el
+++ b/lisp/startup.el
@@ -1021,17 +1021,17 @@ startup--load-user-init-file
 
 This function sets `user-init-file' to the name of the loaded
 init-file, or to a default value if loading is not possible."
-  (let ((debug-on-error-from-init-file nil)
-        (debug-on-error-should-be-set nil)
-        (debug-on-error-initial
-         (if (eq init-file-debug t)
-             'startup
-           init-file-debug))
+  (let ((d-o-e-from-init-file nil)
+        (d-o-e-initial
+         (if init-file-debug 'startup--witness debug-on-error))
+        (d-i-e-from-init-file nil)
+        (d-i-e-initial
+         (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 d-o-e-initial))
       (condition-case-unless-debug error
           (when init-file-user
             (let ((init-file-name (funcall filename-function)))
@@ -1112,12 +1112,15 @@ startup--load-user-init-file
 
       ;; If we can tell that the init file altered debug-on-error,
       ;; arrange to preserve the value that it set up.
-      (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 debug-on-error-should-be-set
-      (setq debug-on-error debug-on-error-from-init-file))))
+      (or (eq debug-on-error d-o-e-initial)
+          (setq d-o-e-from-init-file (list debug-on-error)))
+      (or (eq debug-ignored-errors d-i-e-initial)
+          (setq d-i-e-from-init-file (list debug-ignored-errors))))
+
+    (when d-o-e-from-init-file
+      (setq debug-on-error (car d-o-e-from-init-file)))
+    (when d-i-e-from-init-file
+      (setq debug-ignored-errors (car d-i-e-from-init-file)))))
 
 (defvar lisp-directory nil
   "Directory where Emacs's own *.el and *.elc Lisp files are installed.")






  reply	other threads:[~2023-06-20 17:07 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-19 10:27 bug#64163: 29.0.92; Syntactic errors in early init when --debug-init is on Sebastian Miele
2023-06-20 13:27 ` Eli Zaretskii
2023-06-20 14:24   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2023-06-20 16:05     ` Eli Zaretskii
2023-06-20 17:07       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2023-06-21 13:29         ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwv352myt84.fsf-monnier+emacs@gnu.org \
    --to=bug-gnu-emacs@gnu.org \
    --cc=64163@debbugs.gnu.org \
    --cc=eliz@gnu.org \
    --cc=iota@whxvd.name \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).