Subject: Re: bug#63555: closed (Re: bug#63555: emacs 29 complains that it can't connect to the display)

From: Phillip Susi <[email-masked]>
Date: Mon, 22 May 2023 12:44:40 -0400

This patch works for me.

Index: b/src/dispnew.c
===================================================================
--- a/src/dispnew.c
+++ b/src/dispnew.c
@@ -6559,8 +6558,20 @@ init_display_interactive (void)
 #ifdef HAVE_PGTK
   if (!inhibit_window_system && !will_dump_p ())
     {
-      Vinitial_window_system = Qpgtk;
-      return;
+      char *display, *wayland_display;
+      display = getenv ("DISPLAY");
+      wayland_display = getenv ("WAYLAND_DISPLAY");
+
+      if (display == NULL && wayland_display == NULL)
+	{
+	  fprintf (stderr, "Neither DISPLAY nor WAYLAND_DISPLAY are set, simulating -nw\n");
+	  inhibit_window_system = 1;
+	}
+      else
+	{
+	  Vinitial_window_system = Qpgtk;
+	  return;
+	}
     }
 #endif