From: Paul Moore <p.f.moore@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: 23689@debbugs.gnu.org
Subject: bug#23689: Daemon-mode on Windows - "w32-initialized" is set too early
Date: Sat, 4 Jun 2016 13:54:59 +0100 [thread overview]
Message-ID: <CACac1F9Gt4mffLSLjJ+TcyG51zeDZ4dRR5RKG91nSpEuEJzD2Q@mail.gmail.com> (raw)
In-Reply-To: <83shwtusoj.fsf@gnu.org>
On 4 June 2016 at 11:58, Eli Zaretskii <eliz@gnu.org> wrote:
> Frankly, I'm not sure what is the situation for which you want to
> test. Can you describe the original problem in more detail?
Sure. The issue arises with Spacemacs. I'll give the basic idea (as
well as I understand it, I'm not an expert by any means) but the
actual code is at
https://github.com/syl20bnr/spacemacs/blob/master/core/core-display-init.el#L28
When spacemacs starts up, it wants to set the fonts as configured by
the user. To do so, it checks that the user-selected font exists using
find-font (there's new code in the develop branch that allows the user
to set a list of fonts, and picks the first on the list that actually
exists on the system). But in daemon mode, find-font doesn't return a
useful value until the display system is initialised, so there's a
macro:
(defmacro spacemacs|do-after-display-system-init (&rest body)
"If the display-system is initialized, run `BODY', otherwise,
add it to a queue of actions to perform after the first graphical frame is
created."
`(let ((init (cond ((boundp 'ns-initialized) 'ns-initialized)
((boundp 'w32-initialized) 'w32-initialized)
((boundp 'x-initialized) 'x-initialized)
(t 't)))) ; fallback to normal loading behavior
(if (symbol-value init)
(progn
,@body)
(push (lambda () ,@body) spacemacs--after-display-system-init-list))))
The actions on spacemacs--after-display-system-init-list are executed
when the first GUI frame is displayed, via advice on
server-create-window-system-frame.
This process works fine on non-Windows systems, I guess because
ns-initialized and x-initialized are false during daemon startup. But
on Windows it fails and from my testing this appears to be because
w32-initialized is true at this point (unlike the other two). As a
result, the font selection code gets run immediately - specifically
*before* the point when find-font will give a correct answer.
To demonstrate, create a .emacs.d/init.el containing
(progn
(message "%S" w32-initialized)
(message "%S" (find-font (font-spec :name "Courier New")))
(message "%S" w32-initialized))
Set HOME to the directory containing .emacs.d and run emacs --daemon.
The result is
t
nil
t
Do the same on Unix (I used Ubuntu) using x-initialized (and a font
that exists on the Unix system in place of Courier New) and you get
nil
nil
nil
Do the same using emacs (no --daemon) and look in the *Messages*
buffer, and you see
t
<a font object>
t
in both cases.
Hopefully, that clarifies a little.
Paul
next prev parent reply other threads:[~2016-06-04 12:54 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-03 10:33 bug#23689: Daemon-mode on Windows - "w32-initialized" is set too early Paul Moore
2016-06-04 10:07 ` Eli Zaretskii
2016-06-04 10:29 ` Paul Moore
2016-06-04 10:58 ` Eli Zaretskii
2016-06-04 12:54 ` Paul Moore [this message]
2016-06-04 15:01 ` Eli Zaretskii
2016-06-04 15:17 ` Paul Moore
2016-06-08 13:57 ` Paul Moore
2016-06-14 17:10 ` Eli Zaretskii
2016-06-14 18:20 ` Paul Moore
2016-06-14 18:55 ` Eli Zaretskii
2016-06-14 19:55 ` Paul Moore
2016-06-15 2:33 ` Eli Zaretskii
2016-06-15 7:08 ` Paul Moore
2016-06-15 11:11 ` Paul Moore
2016-06-15 14:55 ` Eli Zaretskii
2016-06-15 15:26 ` Paul Moore
2016-06-15 15:47 ` Eli Zaretskii
2016-06-15 16:58 ` Paul Moore
2019-11-02 1:07 ` Stefan Kangas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CACac1F9Gt4mffLSLjJ+TcyG51zeDZ4dRR5RKG91nSpEuEJzD2Q@mail.gmail.com \
--to=p.f.moore@gmail.com \
--cc=23689@debbugs.gnu.org \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).