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: Sun, 14 May 2006 07:32:09 -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))

    I'm not sure what you expect this to do.
    The lookup to map face names to visual properties is done (repeatedly)
    during redisplay, so would your let-face binding only affect the visual
    appearance of the face in the redisplays that take place during
    `do-something' or would you want the effect to outlive the let?

I'm not sure I understand (I'm no expert on faces or displaying). Could you
elaborate on the first part of that sentence?

Are you saying that adding the face to some text wouldn't be reflected
visually until redisplay takes place, and that might not happen until after
the let is exited? Or are you saying something else? For the second part of
the sentence, IIUC, I would not expect the face to reflect the new
definition after the let is exited.

    E.g. in the code below:
       (let-face ((font-lock-string-face :background "red"))
         (put-text-property 1 5 'face 'font-lock-string-face))
    do you expect the chars 1-5 to end up with a red background?
    If so, it's going to be difficult, because the whole
    put-text-property expression doesn't currently know it's
    manipulating any kind of face.

I'm guessing that you mean that put-text-property would make chars 1-5 have
font-lock-string-face (which would be defined at that point to have a red
background), but those chars wouldn't get redisplayed until after the let is
exited. If that's the case, then I'd say that users can use let to bind the
face to a new definition, and they can use put-text-property to add that
(newly defined) face to text, but they also need to (do something to) force
redisplay inside the let, if they want to see the effect.

Again, I'm no expert on this, so I don't know how this should be implemented
(assuming I'm understanding the problem). If face definition and application
to text are separated from redisplay (manifestation of the face change) in
Emacs, then that fact will need to be taken into account. Either redisplay
would need to be done automatically (but when?) or users would need to take
care of redisplay themselves. The latter sounds fine to me (IIUC).

Would (sit-for 0) or (force-mode-line-update) accomplish that? That is,
could a user take care of the problem by simply doing this?

       (let-face ((font-lock-string-face :background "red"))
         (put-text-property 1 5 'face 'font-lock-string-face)
         ...
         (force-mode-line-update) ; Redisplay now.
         ...
       )

If I'm not understanding you well, perhaps you can elaborate a bit on the
problem and possible alternatives.





reply via email to

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