emacs-devel
[Top][All Lists]
Advanced

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

Re: face-attribute returns wrong foreground color for inheriting face.


From: David Kastrup
Subject: Re: face-attribute returns wrong foreground color for inheriting face.
Date: 28 Oct 2001 20:00:34 +0100

>>>>> "Miles" == Miles Bader <address@hidden> writes:

    Miles> In any case, any argument should be made about the way the
    Miles> display works, not about `face-attribute', which should
    Miles> just mirror what the display code does.

Quite so.  Would you say that the following code snippet does more or
less what you do now?  I call all floating point values relative sizes
for my purposes...

The (or (null (cdr fallbacks)) (cdr fallbacks)) is simply supposed to
deliver t when the fallbacks run out (in order to let the last face's
:inherit still work).

(defun preview-inherited-face-attribute (face attribute &optional fallbacks)
  (let ((value (face-attribute face attribute)))
    (when fallbacks
      (setq fallbacks
            (append
             (let ((ancestors (face-attribute face :inherit)))
               (cond ((facep ancestors) (list ancestors))
                     ((consp ancestors) ancestors)))
             (cond ((facep fallbacks) (list fallbacks))
                   ((consp fallbacks) fallbacks)))))
    (cond ((null fallbacks) value)
          ((floatp value)
           (let ((avalue
                  (preview-inherited-face-attribute
                   (car fallbacks) attribute (or (null (cdr
                                                        fallbacks))
                                                 (cdr fallbacks)))))
             (cond ((integerp avalue)
                    (round (* avalue value)))
                   ((floatp avalue)
                    (* value avalue))
                   (t value))))
          ((eq value 'unspecified)
           (preview-inherited-face-attribute
            (car fallbacks) attribute (or (null (cdr fallbacks))
                                          (cdr fallbacks))))
          (t value))))


-- 
David Kastrup, Kriemhildstr. 15, 44793 Bochum
Email: address@hidden



reply via email to

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