[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Trying to define face dynamically
From: |
Óscar Fuentes |
Subject: |
Re: Trying to define face dynamically |
Date: |
Fri, 18 Oct 2019 02:15:47 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Óscar Fuentes <ofv@wanadoo.es> writes:
> Eli Zaretskii <eliz@gnu.org> writes:
>
>>> (mapcar (lambda (face)
>>> (face-remap-add-relative
>>> face `(:filtered (:window has-keyboard-focus nil)
>>> :background ,(color-darken-name
>>> (face-attribute face :background)
>>> 10.0))))
>>> '(default fringe))
>>>
>>> But this has not the desired effect: faces remain the same and every now
>>> and then Emacs throws an error "wrong-type-argument stringp nil" from
>>> functions such as font-info.
>>>
>>> What I'm doing wrong?
>>
>> You didn't say what color-darken-name does, but I think the problem is
>> that ':background "foo"' is not a face spec. Did you try something
>> like '(background-color . ,(color-darken-name ...))' or maybe
>> '(:background ,(color-darken-name ...))' instead?
>
> Thanks. Changing to either of your suggestions eliminates the error, but
> the face is not altered.
Eli's suggestion was right. The face change didn't apply because
specific actions are required by the minor mode to be effective.
For the record, this is the complete call:
(mapcar (lambda (face)
(face-remap-add-relative
face
`(:filtered
(:window has-keyboard-focus nil)
(:background
,(color-darken-name
(face-attribute 'default :background)
3.0)))))
'(default fringe))
This darkens the "default" and "fringe" background colors by 3% when the
window has no keyboard focus. Neat. Now, if we only had a hook for
detecting enabling/disabling of themes for invocating the code above
automatically...
I'll submit a bug report about that.