Subject: bug#32921: emacsclient obeys Xresources even when launched with -nw

From: Po Lu <[email-masked]>
Date: Thu, 19 May 2022 21:09:51 +0800

Eli Zaretskii <[email-masked]> writes:

> We already do that, see the information and the backtrace posted by
> Lars a while ago.

Hmm... then why does this code still exist at all?
x-create-frame-with-faces should take care of setting the `reverse'
parameter entirely.

Could you please explain what you meant by "startup timer" here?

> So the difference is between (a) taking notice of the reverseVideo
> resource at startup timer as opposed to (b) at frame creation time, is
              ^^^^^^^^^^^^^
> that right?  If so, I think this might affect the use case whereby
> someone changes the X resources after Emacs has already started, or
> something?

Though I doubt this really matters, since X resources cannot change
after Emacs starts.

> The code in x-win.el does something beyond that: it caters for people
> who have X resources specified on their user-private files, and want
> those settings to be in effect on all displays.

But then why only a single resource, and not all of them?  Especially
an obscure one like reverseVideo?

BTW, I think I found out why this situation is.  Before Emacs 19.29,
reverseVideo and selectionTimeout were both set up in x-win.el assuming
that there would only ever be a single display, just like the other
frame parameters in Fx_create_frame.

When support for multiple displays was added in 19.29, the changes to
make X resources affecting frame parameters specific to each display
were made to the C code in Fx_create_frame, but not to the two
parameters set in Lisp.  Whether or not that was done intentionally is
anyone's guess, but I think it was a bug, or an oversight.

> (And besides, what is the chance that someone will want different
> values of reverseVideo on different displays?  I think the chances for
> that are nil.)

Many other programs accept a resource named reverseVideo (it and -rv are
a very standard knobs for X programs), so I can imagine someone placing:

  *.reverseVideo: on

in the X resources for an X server with dark window decorations, and
vice versa.  Emacs should create frames with the colors specified on
each server it is connected to.

> Because we will otherwise break a long-standing behavior.

[...]

> People who want Emacs to behave like you describe can simply remove
> this setting from their ~/.Xdefaults.

That wouldn't be useful, since Emacs doesn't even load ~/.Xdefaults if
the X server it connected to already has some resources loaded.  Doing
that is the job of the session script(s) that started the X server.

> Not necessarily, because frame-parameters applied by
> gui_default_parameter could override those we took from ~/.Xdefaults.

I meant the parameters applied by gui_default_parameter when the
parameter is not present in `default-frame-alist' or the ALIST argument.

Thanks.