[Top][All Lists]

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

Nonexistent vs. empty resources

From: Juanma Barranquero
Subject: Nonexistent vs. empty resources
Date: Fri, 18 Sep 2009 15:21:20 +0200

Currently, at least on Windows, with no Emacs.Font registry setting,
emacs -q defaults to


while having an empy Emacs.Font resource, or doing "emacs -q -xrm
Emacs.Font:", results in some other font, in my case


Now, the reason is quite clear. In frame.c:xrdb_get_resource() there
is this code:

  if (value != (char *) 0)
    return build_string (value);
    return Qnil;

so in this case, an empty string "" is being returned. And most
font-dealing code does not expect an empty-string face spec.

The question is: where to fix it?  There are at least three places:

 1) x_get_string_resource: it could be argued that an empty setting is
no setting at all; that means deciding whether

      emacs -q -xrm Emacs.Myresource:

    would override a registry setting, or just be ignored. Note that,
for many resources, this overriding makes sense:

      emacs -q -xrm Emacs.Background: -xrm Emacs.Foreground:

    can be useful sometimes.

 2) xrdb_get_resource: similar, though at this point, the overriding
would work (because the search has finalized, empty string or not).

 3) On the functions that don't quite do the right thing with an empty
font spec. Fixing it here is messy, because it's not just making sure
x_default_font_parameter opens the right default font, but also
tweaking x_default_parameter, and perhaps other places.

I'd opt for 2). The fix is easy and IMHO the behavior matches expectations.


--- a/src/frame.c
+++ b/src/frame.c
@@ -3854,7 +3854,7 @@ xrdb_get_resource (rdb, attribute, class,
component, subclass)

   value = x_get_string_resource (rdb, name_key, class_key);

-  if (value != (char *) 0)
+  if (value != (char *) 0 && *value)
     return build_string (value);
     return Qnil;

reply via email to

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