bug-gnu-emacs
[Top][All Lists]
Advanced

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

cannot set face attributes to symbols from X resources


From: Vivek Dasmohapatra
Subject: cannot set face attributes to symbols from X resources
Date: Wed, 16 Jun 2004 13:05:31 +0100

This bug report will be sent to the Free Software Foundation,
not to your local site managers!
Please write in English, because the Emacs maintainers do not have
translators to read other languages for them.

Your bug report will be posted to the bug-gnu-emacs@gnu.org mailing list,
and to the gnu.emacs.bug news group.

In GNU Emacs 21.2.1 (i386-debian-linux-gnu, X toolkit, Xaw3d scroll bars)
 of 2003-12-03 on salmon, modified by Debian
configured using `configure  i386-debian-linux-gnu --prefix=/usr 
--sharedstatedir=/var/lib --libexecdir=/usr/lib --localstatedir=/var/lib 
--infodir=/usr/share/info --mandir=/usr/share/man --with-pop=yes --with-x=yes 
--with-x-toolkit=athena --without-gif'
Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: nil
  locale-coding-system: nil
  default-enable-multibyte-characters: t

Please describe exactly what actions triggered the bug
and the precise symptoms of the bug:

The :inherit, :overline, :underline and :strike-through attributes 
can be set to symbols - in :inherit's case, it must be set to a symbol
or a list of symbols (which happen to be faces themselves).

`set-face-attributes-from-resources' achieves this by calling 
`internal-set-lisp-face-attribute-from-resource' with a symbol,
attribute, value and possibly a frame. The value is passed as a 
string, which for most attributes is fine.

`internal-set-lisp-face-attribute-from-resource' then does some 
sanity checking on the value, based on the value of attribute, 
and calls `internal-set-lisp-face-attribute' with the same arguments
it was called with. However, if the attribute in question needs a 
symbol (eg setting :inherit to 'italic) then this breaks, as neither
function calls intern to coerce the value to the correct type.

For example: 

echo "Emacs.fringe.attributeInherit: highlight" | xrdb -merge
emacs -q --no-site-file

results in the following messages:
############################################################################
(emacs -q --no-site-file)
Loading disp-table...done
Face fringe, frame #<frame emacs@arachne.cam.zeus.com 0x84adaa0\ >: invalid 
attribute :inherit highlight from X resource [2 times]
############################################################################

I suspect the correct solution is for one or both of the internal-set-*
functions to intern the string and fetch a symbol, however for the time 
being I am using this quick hack in my .emacs (or rather the user who
reported the bug is, it's not actually an issue for me):

############################################################################
(defun set-face-attribute-from-resource (face attribute resource class frame)
  "Set FACE's ATTRIBUTE from X resource RESOURCE, class CLASS on FRAME.
Value is the attribute value specified by the resource, or nil
if not present.  This function displays a message if the resource
specifies an invalid attribute."
  (let* ((face-name (face-name face))
   (value (internal-face-x-get-resource (concat face-name resource)
                                        class frame)))
    (when value
      (if (and (string-match "^'" value)
               (or (eq attribute :inherit       ) 
                   (eq attribute :underline     ) 
                   (eq attribute :overline      ) 
                   (eq attribute :strike-through)))
          (progn
            (setq value (intern (substring value 1)))
            (condition-case ()
                (internal-set-lisp-face-attribute
                 face attribute value frame)
              (error
               (message "Face %s, frame %s: attribute %s %S from XRDB"
                        face-name frame attribute value))))
        (setq value (downcase value))
        (condition-case ()
            (internal-set-lisp-face-attribute-from-resource
             face attribute value frame)
          (error
           (message "Face %s, frame %s: bad attribute %s %s from X resource"
                    face-name frame attribute value)))))
    value))

############################################################################

This allows the following syntax to work:

echo "Emacs.fringe.attributeInherit: 'highlight" | xrdb -merge

It should be noted that this does not provide a mechanism for the user 
to set :inherit to a list of faces, but :underline et al can be set to 
t or nil and :inherit can be set to a single face.

This bug may have been fixed in cvs, I haven't checked there.




reply via email to

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