Subject: Re: bug#1058: 23.0.60; emacs --daemon should not return until socket is ready

From: Dan Nicolaescu <[email-masked]>
Date: Tue, 7 Oct 2008 08:31:47 -0700 (PDT)

Stefan Monnier <[email-masked]> writes:

  > > Errors in ~/.emacs show up in the *Messages* buffer (as they do when
  > > starting up normally). 

There are multiple issues being discussed here.

1. 
  > But is the *Messages* buffer automatically displayed (as is done when
  > starting up normally)?  

Not yet, but it just takes one extra `if' to do it:

--- server.el.~1.168.~     2008-09-24 17:34:59.000000000 -0700
+++ server.el              2008-10-07 08:09:16.000000000 -0700
@@ -606,7 +606,9 @@ Server mode runs a process that accepts 
     (process-put proc 'terminal (frame-terminal frame))
 
     ;; Display *scratch* by default.
-    (switch-to-buffer (get-buffer-create "*scratch*") 'norecord)
+    (switch-to-buffer
+     (get-buffer-create 
+      (if init-file-had-error "*Messages*" "*scratch*")) 'norecord)
 
     ;; Reply with our pid.
     (server-send-string proc (concat "-emacs-pid "

2. During the normal interactive startup the splash screen nowadays
covers the *Messages* buffer too fast, so the user can miss the error.
I should file a bug about this...

  >  This is the main reason why I think that .emacs messages should go
  > to stdout.

3. There's no code in emacs now that can do that for interactive
sessions, and when I looked at this it did not look that it can be a
small change acceptable during the feature freeze.  The `noninteractive'
code has it's claws in too many places.

  > Especially since the error might even be something that breaks the
  > server, so you can't connect later on to take a look at the
  > *Messages* buffer.

5. Making the output go to stdout does not avoid this problem at all, it
reduces the possibility somewhat, but it does not avoid it.

6. But my original code to start the server early minimizes the window
of opportunity for problems in starting the server, the more .emacs,
default.el, site-start.el code you run, the more potential for problems
in starting the server later.  Yes, starting the server early was
entirely intentional.

7. This bug report is about something else: 
emacs --daemon && emacsclient -c 
not working.  Romain's patch looks good, it does not add features, it's
just a bug fix, so I don't see any reason it cannot go in right now.