Subject: Re: bug#41719: 28.0.50; [FR] emacsclient should provide '--name' option as emacs

From: Vladimir Lomov <[email-masked]>
Date: Sat, 6 Jun 2020 22:52:21 +0800

Hello,
** Dmitry Alexandrov <[email-masked]> [2020-06-06 15:36:06 +0300]:

> Vladimir Lomov <[email-masked]> wrote:

>> I tried to use '-F' option of 'emacsclient' but I didn't get desire result,
>> WM_CLASS isn't changed, only WM_ICON_NAME.

> Works for me (Emacs 28, no toolkit).

Do you able to change WM_CLASS?

>> It is possible that I do things wrong,
>>
>>   $ emacsclient -s /run/user/1000/emacs-default -F '((name . "default") (title . "USER@HOST"))'

> FWIW, this command does not necessary create a _new_ frame.  Use ‘-c’,
> ‘--create-frame’ to force it.

My fault, I didn't added it in example but of course use it (without it
emacsclient doesn't create window).

Let me give more details what I did and what I get.

1. Run Emacs without parameters

$ emacs

$ xprop | grep 'WM_CLASS\|WM_NAME\|WM_ICON_NAME'

WM_CLASS(STRING) = "emacs", "Emacs"
WM_ICON_NAME(STRING) = "[email-masked]"
_NET_WM_ICON_NAME(UTF8_STRING) = "[email-masked]"
WM_NAME(STRING) = "[email-masked]"
_NET_WM_NAME(UTF8_STRING) = "[email-masked]"

2. Run Emacs with parameters

$ emacs --name default --title USER@HOST

$ xprop | grep 'WM_CLASS\|WM_NAME\|WM_ICON_NAME'

WM_CLASS(STRING) = "default", "Emacs"
WM_ICON_NAME(STRING) = "default"
_NET_WM_ICON_NAME(UTF8_STRING) = "USER@HOST"
WM_NAME(STRING) = "USER@HOST"
_NET_WM_NAME(UTF8_STRING) = "USER@HOST"

3. Run emacsclient (the socket is created by systemd, emacs started by
service)

$ emacsclient -s /run/user/1000/emacs-default -c

$ xprop | grep 'WM_CLASS\|WM_NAME\|WM_ICON_NAME'

WM_CLASS(STRING) = "emacs", "Emacs"
WM_ICON_NAME(STRING) = "*scratch*"
_NET_WM_ICON_NAME(UTF8_STRING) = "*scratch*"
WM_NAME(STRING) = "*scratch*"
_NET_WM_NAME(UTF8_STRING) = "*scratch*"

But this time I already have openned Emacs windown. If I close it (C-x 5 0)
and run emacsclient again I get

WM_CLASS(STRING) = "emacs", "Emacs"
WM_ICON_NAME(STRING) = "[email-masked]"
_NET_WM_ICON_NAME(UTF8_STRING) = "[email-masked]"
WM_NAME(STRING) = "[email-masked]"
_NET_WM_NAME(UTF8_STRING) = "[email-masked]"

4. Run emacsclient with -F

$ emacsclient -s /run/user/1000/emacs-default -c -F '((name . "default") (title . "USER@HOST"))

$ xprop | grep 'WM_CLASS\|WM_NAME\|WM_ICON_NAME'

WM_CLASS(STRING) = "emacs", "Emacs"
WM_ICON_NAME(STRING) = "default"
_NET_WM_ICON_NAME(UTF8_STRING) = "USER@HOST"
WM_NAME(STRING) = "USER@HOST"
_NET_WM_NAME(UTF8_STRING) = "USER@HOST"

This time I don't have openned Emacs window. If I run the same command when
Emacs already has window (created by emacsclient) then I get

WM_CLASS(STRING) = "emacs", "Emacs"
WM_ICON_NAME(STRING) = "default"
_NET_WM_ICON_NAME(UTF8_STRING) = "USER@HOST"
WM_NAME(STRING) = "USER@HOST"
_NET_WM_NAME(UTF8_STRING) = "USER@HOST"

As one may see only emacs allows to set 'instance' (WM_CLASS, first string)
with --name option.

>> Even if it is possible to change the 'instance' of Emacs window created by
>> 'emacsclient' using the '-F' option it would be nice to have more simple
>> way to achieve this.

> It would be nice to give some examples, how it can be useful.

---
WBR, Vladimir Lomov

-- 
If you marry a man who cheats on his wife, you'll be married to a man who
cheats on his wife.
		-- Ann Landers