1

I'd like to turn some things off normally and then re-enable them when emacs is started with --debug-init. For example, I get loads of warnings about the length of doc-strings in packages. I want to suppress these warnings normally, but I'd like to be able to see wall these warnings when I am in debug mode.

2 Answers 2

1

Most directly:

(when init-file-debug (message "--debug-init")) 

as the --debug-init argument results in (setq init-file-debug t)

Or more indirectly:

(when (eq debug-on-error 'startup) (message "--debug-init")) 

as startup is the value given when (eq init-file-debug t)

(I'd go with the first option, though.)

0

I looked at C-h describe-variable and was able to find the variable debug-on-error. This might be an even better option than just a variable which signifies that the --debug-init argument was called, as this is a non-nil whenever emacs is set to enter debugger on an error signal, and not just if a specific CLI argument is called.

This something to the effect of

(if debug-on-error (foo) (bar)) 

Should do the trick to run foo when the debug-on-error is t and run bar otherwise.

If you only want this to work when --debug-init is called look check @phils solution instead.

2
  • 1
    In my tests, --debug-init had already been removed from command-line-args by the time custom init code was executed, so that wasn't a viable method of detection. Commented Aug 15, 2023 at 14:48
  • Thanks for that catch, I've updated that portion to point to your answer! Commented Aug 15, 2023 at 14:53

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.