Subject: Re: bug#67628: Emacs 29.1: (x-open-connection (getenv "DISPLAY")) gets "Display :0.0 does not exist" error

From: Herman <[email-masked]>
Date: Tue, 5 Dec 2023 00:44:05 +0200

On Mon, 04 Dec 2023 22:11:43 +0200
Eli Zaretskii <[email-masked]> wrote:

> > Date: Mon, 4 Dec 2023 19:31:38 +0200
> > From: Herman <[email-masked]>
> > 
> > 'x-create-frame' succeeds, but 'x-open-connection' fails with same
> > display argument.
> > 
> > This error "Display :0.0 does not exist" happens only, when
> > variable 'debug-on-error' is non-nil. When 'debug-on-error' is nil,
> > the error is not present. I.e. it works on the principle - you get
> > what you are looking for.  
> 
> It could be that the code catches the error and proceeds, but your
> setting debug-on-error non-nil prevents that.
> 
> Why do you need to set debug-on-error in that case?

At first I also thought that it is actually normal to catch an error when debug is enabled. I had debug turned on to look for other errors.

One argument could be that in version 28.2 debug did not catch such an error when debug is enabled. Version 29.1 behaves differently.

Another argument is that in the Elisp manual, in the Multiple terminals chapter, it is written that: "Normally, Emacs Lisp programs need not call 'x-open-connection' function, as 'make-frame-on-display' calls it automatically. The only reason for calling it is to check whether communication can be established with a given X display." 
If in 29.1 now 
$ emacs --daemon -Q
$ emacsclient -e "(setq debug-on-error t)"
then 
$ emacsclient -e "(make-frame-on-display (getenv \"DISPLAY\"))"
does not give an error, i.e. the display is found

but if
$ emacs --daemon -Q
$ emacsclient -e "(setq debug-on-error t)"
then
$ emacsclient -e "(x-open-connection (getenv \"DISPLAY\"))"
gives an error, i.e. the display does not exist.