From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Paul Moore Newsgroups: gmane.emacs.bugs Subject: bug#23689: Daemon-mode on Windows - "w32-initialized" is set too early Date: Sat, 4 Jun 2016 13:54:59 +0100 Message-ID: References: <8337otw9m0.fsf@gnu.org> <83shwtusoj.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1465045094 7692 80.91.229.3 (4 Jun 2016 12:58:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 4 Jun 2016 12:58:14 +0000 (UTC) Cc: 23689@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Jun 04 14:58:02 2016 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1b9B7o-0000ex-Bh for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 Jun 2016 14:56:24 +0200 Original-Received: from localhost ([::1]:60872 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9B7i-0002T1-JH for geb-bug-gnu-emacs@m.gmane.org; Sat, 04 Jun 2016 08:56:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:59945) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9B7W-0002LB-Iw for bug-gnu-emacs@gnu.org; Sat, 04 Jun 2016 08:56:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b9B7S-0007pk-GO for bug-gnu-emacs@gnu.org; Sat, 04 Jun 2016 08:56:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:41506) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b9B7S-0007pg-CY for bug-gnu-emacs@gnu.org; Sat, 04 Jun 2016 08:56:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1b9B7S-00042b-7N for bug-gnu-emacs@gnu.org; Sat, 04 Jun 2016 08:56:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Paul Moore Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 04 Jun 2016 12:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 23689 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 23689-submit@debbugs.gnu.org id=B23689.146504490715462 (code B ref 23689); Sat, 04 Jun 2016 12:56:02 +0000 Original-Received: (at 23689) by debbugs.gnu.org; 4 Jun 2016 12:55:07 +0000 Original-Received: from localhost ([127.0.0.1]:53843 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b9B6Z-00041K-BU for submit@debbugs.gnu.org; Sat, 04 Jun 2016 08:55:07 -0400 Original-Received: from mail-wm0-f51.google.com ([74.125.82.51]:36529) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b9B6X-00040q-Kt for 23689@debbugs.gnu.org; Sat, 04 Jun 2016 08:55:06 -0400 Original-Received: by mail-wm0-f51.google.com with SMTP id n184so31005895wmn.1 for <23689@debbugs.gnu.org>; Sat, 04 Jun 2016 05:55:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=97JieatuonxkaAIl89EgpJmlKEj5NszZvkXftuvSBHg=; b=N2L+RX17Mscxfz+bN4s9/7/ZE8spJ57E321eNkuV08O0u2otZGJwipT8FVFkVRSR6v x0YKoonFGdKjmVfVUvvXekXccor5pufmGfsSNPcb+uNNtfw+Dc3U6EA+D6fKyNEPkURv ESvvXPYFHFetZUNiRC4uY7PSatGaz5VXVmAGSO1BdD2T+ID1Yc4+Ex4v2ilzxizQmQTn k/zJvwzj/UoJ1aYch0ds2UOM84DV3vl3vMNeG1cTaNB2bqiyfdgzClaPIHLiFqICts7a ZsuMHMly17XHx5atqOzL6hId1THYynPJnWdec5SQr3p4hBMBIJlHSp8izzSybKBPTfN8 zRuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=97JieatuonxkaAIl89EgpJmlKEj5NszZvkXftuvSBHg=; b=UFbS/tJ/zs+VlfS0pA73y08dkIUfCkpc9wvXnqR/cXYQNnSob7wgtOwP8pv3SqaTka cy1R6kLvh8Sc0RkRf5YvYlsk96qObWxewDC0aaIe8nyoufrphcYQbS5aeRAmdzSLgvlK /GqwEPM8pkcnZggPPISxuUu03m35bS6N3kZKgNyyhDuFYCW0YHoBq3HW/1mUhaaqTHeN Dzft0yYWBQXlGXO4KqneZswGDVT9y/wV4ck+jNvekPT8dpvEQegiMKpjvfEfXGUeKoNs glKvuQKh7qenprJ3MqeUIqibEoqJyfQQBZp5hSZyFRLJ2uGP1oQj1/hUs34ZziKsazuU srKQ== X-Gm-Message-State: ALyK8tIvAFAS/aMW5uH/VyvPpn8qUWmGA7yWCxM6wKykYLbgQymIhzNcYEKZrBrAebRyXooYLYj8Ko3QmQpELg== X-Received: by 10.28.158.8 with SMTP id h8mr4096437wme.1.1465044899917; Sat, 04 Jun 2016 05:54:59 -0700 (PDT) Original-Received: by 10.194.108.136 with HTTP; Sat, 4 Jun 2016 05:54:59 -0700 (PDT) In-Reply-To: <83shwtusoj.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:119049 Archived-At: On 4 June 2016 at 11:58, Eli Zaretskii 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 t in both cases. Hopefully, that clarifies a little. Paul