Subject: Re: bug#76772: 29.4; Emacsclient doesn't display warnings emitted during daemon startup

From: Eli Zaretskii <[email-masked]>
Date: Sun, 09 Mar 2025 12:35:51 +0200

> From: Artiom Balan <[email-masked]>
> Date: Sat, 8 Mar 2025 10:53:38 +0200
> Cc: Stefan Kangas <[email-masked]>, [email-masked]
> 
> > If we want the first client connection to show the important messages
> > from the startup phase of the daemon, then warnings is not the only
> > thing, and not even the most important thing, that needs to be shown.
> 
> Good point. To generalize, is the only difference between running a regular emacs instance and running an
> emacs daemon the fact that the user doesn't see some things? Like, the behavior is the same, but some
> things are "shown" in the daemon, which the user can't see. If so, how can we know which are all of these
> things? You added errors and echo-area messages. Are there any others?

When some code in Emacs shows a message, we don't usually make sure
the message is displayed.  We call the usual functions like 'message'
or pop-to-buffer, and if the selected frame is not shown on display,
we leave it at that.

So in general, the daemon doesn't show anything, with the exception of
critical problems that prevent it from starting (those are written to
stderr of the controlling terminal at the moment of daemon startup).

> Would the ideal solution be to show in the first emacsclient everything that the regular instance would have
> shown? Or maybe a hack that displays the warnings (and errors?) in the first emacsclient would suffice? 

I think we should have some way of deferring messages until some frame
is visible on display.

> BTW, how can i get emacs to show errors after startup? I tried to add a `(error "message")` to my init.el, and
> starting emacs would show it as a warning: 
> "Warning (initialization): An error occurred while loading ..."

Signaling an error during startup prevents Emacs from starting, so the
user will not see any messages at all, which is not useful.
Therefore, Emacs handles errors during startup in a special way.  If
you want Emacs to enter a debugger due to problem in startup and/or
init files, use the --debug-init command-line option to start Emacs.