Subject: bug#65509: [PATCH] Use correct env var when opening frames with freedesktop menu entries

From: Davide Masserut <[email-masked]>
Date: Sun, 03 Sep 2023 15:42:44 +0200

Po Lu <[email-masked]> writes:

> Stefan Kangas <[email-masked]> writes:
>
>> Not sure it's worth doing, but one option is to do both.  Users 
>> that
>> miss one would see the other.
>
> I won't object to such a change, though I cannot claim to 
> understand the
> rationale behind it.  (Who would see the message printed to 
> stderr, but
> not the dialog displayed, during connection setup?)

X DEs don't set the $WAYLAND_DISPLAY environment variable, so 
querying for it returns an empty string.

If I run this in X:

emacsclient --alternate-editor= --display=$WAYLAND_DISPLAY 
.emacs.el

the following occurs.

When the --display argument is an empty string, Emacs first tries 
to reuse an exiting frame and, if doesn't find one, it falls back 
to open it in the same terminal.  The problem arises when an 
instance is launched through the DE facilities: Emacs can't use a 
terminal as a fallback and therefore it opens in the background 
without showing the frame.

If we decide that handling such case is not worth the trouble, an 
error in system log should warn the user to use the X backend.