[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Detecting display/frame capability in an Emacs daemon

From: michael
Subject: Detecting display/frame capability in an Emacs daemon
Date: Fri, 15 Feb 2013 17:33:17 -0500

I have a cloud based Emacs initialization file that I use on three
machines: 2 GNU/Linux X based and 1 Cygwin (with w32 GUI).  In the
script I set the default font and the font for a couple of faces.  Since
not all of the machines have the same set of fonts, my initialization
uses `x-list-fonts' to see if a particular font is available.  If a font
is not available it falls back on to the next font on my preferred list.
For example, I prefer DejaVu Mono, but if it's not available I'll try
Liberation Mono, and then Lucida Console.

If I start Emacs with just "emacs" my frame pops up with the best
preferred font.  If, however, I start up with "emacs --daemon", no frame
appears (as expected until I request one with "emacsclient").  Since no
initial frame is displayed, the GUI has not been initialized and I get
an error message in my *Messages* buffer when I try to inspect available
fonts.  That makes sense.

My goal was to then find a hook to attach to that was after the GUI had
been initialized so that I could probe the fonts.  I tried
'after-make-frame-functions' and checking (display-graphic-p) before I
look for fonts, and while I don't get an error indicating that the GUI
is not yet initialized, the x-list-fonts function always returns nil and
thus I get the default Emacs fonts rather than one I had chosen.  Once
the frame appears, I can run the same function and my fonts now appear. 

So, my question is: Is this a bug?  Is there a prescribed way of doing
this in an Emacs daemon?  (Setting the font is not a problem, it's the
checking for the existence of the font that causes trouble.)  Is this a
missing feature/enhancement?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]