Po Lu writes: > Davide Masserut writes: > >> Correct. However, that TTY is occupied by the X window manager, >> which hides the Emacs interface. >> >> When the argument of --display doesn't exits or is empty, should we >> check if $DISPLAY is present in the environment and use its value? >> >> When PGTK is enabled, we could check $WAYLAND_DISPLAY and then >> $DISPLAY before resorting to displaying the frame in a terminal or in >> a TTY. >> >> I tested this with Gnome and i3, both started from a TTY using >> startx. I'm not sure how this behaves when using a display manager. > > Display selection is GTK's territory, and we basically give it carte > blanche to judge which displays are suitable, since we can't account > for every present and future GDK backend. > > Only subsequent to the establishment of the display connection are we > capable of taking display-specific action, such as displaying a > warning message. It turns out that Emacs 29 has new CLI option that solves exactly these problems. The attached patch replaces the usage of --display=$DISPLAY with --reuse-frame.