From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Juanma Barranquero Newsgroups: gmane.emacs.devel Subject: Nonexistent vs. empty resources Date: Fri, 18 Sep 2009 15:21:20 +0200 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1253282033 1352 80.91.229.12 (18 Sep 2009 13:53:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 18 Sep 2009 13:53:53 +0000 (UTC) To: Emacs developers Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Sep 18 15:53:46 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1ModuD-0001xB-Eo for ged-emacs-devel@m.gmane.org; Fri, 18 Sep 2009 15:53:45 +0200 Original-Received: from localhost ([127.0.0.1]:49560 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ModuD-0007zu-31 for ged-emacs-devel@m.gmane.org; Fri, 18 Sep 2009 09:53:45 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1ModPI-0006o3-Jk for emacs-devel@gnu.org; Fri, 18 Sep 2009 09:21:49 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1ModPB-0006jm-RP for emacs-devel@gnu.org; Fri, 18 Sep 2009 09:21:45 -0400 Original-Received: from [199.232.76.173] (port=60243 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ModPB-0006jR-Do for emacs-devel@gnu.org; Fri, 18 Sep 2009 09:21:41 -0400 Original-Received: from mail-fx0-f216.google.com ([209.85.220.216]:44546) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1ModPA-0007Km-Vk for emacs-devel@gnu.org; Fri, 18 Sep 2009 09:21:41 -0400 Original-Received: by fxm12 with SMTP id 12so755999fxm.42 for ; Fri, 18 Sep 2009 06:21:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:from:date:message-id :subject:to:content-type; bh=pJo7canK8GzhXOTTi5KfKvOELemp8/5SQgTa43aBBxc=; b=FoCu1RpZoBgYqC6cLsFiOGzk30UiYHygsu1xE0T84OIlLx/Y/2nPxH4gVhvnLkZgly 0dLYbkQun9W/Bz7a4shx8L2fB2eLK74Is0Gra0KeekhCYyO1k5+3SIXTUyogZEm6VeZp PYEYKqLt69Wh3Rg1GQh0Ix8d0q/xPruEhsRjM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=vU6lkJJH+3a82/CYKXJmoKHruBWRlhbQi8zR0f0Wzad8ElVijUHObXKLZGgE3Za908 VPvaowoDFvLy2LaBQbc0s3KFFfBc55mkJfVNWAkTh7dnuDnzs4I4iLqrmG2RB2n3euK2 bX4fZO9pz9V16gJuQeG6t2YDy+io9ZIDqDKpU= Original-Received: by 10.239.163.205 with SMTP id q13mr113862hbd.132.1253280100153; Fri, 18 Sep 2009 06:21:40 -0700 (PDT) X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 2) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:115463 Archived-At: Currently, at least on Windows, with no Emacs.Font registry setting, emacs -q defaults to uniscribe:-outline-Courier New-normal-normal-normal-mono-13-*-*-*-c-*-iso8859-1 while having an empy Emacs.Font resource, or doing "emacs -q -xrm Emacs.Font:", results in some other font, in my case uniscribe:-outline-FreeIdgSerif-normal-normal-normal-serif-16-*-*-*-p-*-iso8859-1 Now, the reason is quite clear. In frame.c:xrdb_get_resource() there is this code: if (value != (char *) 0) return build_string (value); else 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. Juanma --- 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); else return Qnil;