emacs-devel
[Top][All Lists]
Advanced

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

RE: bind faces?


From: Drew Adams
Subject: RE: bind faces?
Date: Sat, 13 May 2006 12:40:17 -0700

    > Is there some way to get the effect of "binding" a face to a
    > list of face properties or the properties of another face?
    > That is, do something akin to this:
    >
    >  (let ((some-face another-face-or-a-list-of-face-properties))
    >    (do-something))
    >
    > Wouldn't it be useful to be able to do that? We have `let'
    > for variables and `flet' (via cl.el) for functions, but
    > nothing for faces, IIUC. (Obviously, a user could work with
    > face variables, but those are not always available and
    > their use is generally discouraged.)

    See face-default-spec, face-spec-set, and the other functions in
    faces.el.

Yes, thanks. They can help with saving a face's attributes (spec), setting
the attributes to those of another face (or a constructed spec), and then
restoring the face's original attributes.

But, IIUC, you would still need to do unwind-protect, save the current spec,
set to another spec, and restore current spec. It's not clear to me how they
would provide the convenience of a `let'. One could write one's own macro to
do that (via unwind-protect), but why not have Emacs provide that?

I'm also not clear on how to use those functions to make a face
"unnoticeable", but that's because I'm not sure which face spec to use to do
that. Would it be just this, or is there some general way to nullify all
pertinent face properties?

 ((t (:foreground nil) (:background nil)))

I've been using this, which does the job (but it doesn't take into account
other face properties, such as underline):

 (set-face-foreground 'the-face nil)
 (set-face-background 'the-face nil)





reply via email to

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