unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: "Drew Adams" <drew.adams@oracle.com>
Subject: RE: bind faces?
Date: Sun, 14 May 2006 07:32:09 -0700	[thread overview]
Message-ID: <DNEMKBNJBGPAOPIJOOICGEANDGAA.drew.adams@oracle.com> (raw)
In-Reply-To: <87mzdkrbte.fsf-monnier+emacs@gnu.org>

    > 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	other threads:[~2006-05-14 14:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-13 17:54 bind faces? Drew Adams
2006-05-13 18:07 ` Chong Yidong
2006-05-13 19:40   ` Drew Adams
2006-05-14  2:39     ` Richard Stallman
2006-05-14  0:52 ` Miles Bader
2006-05-14  1:02   ` Drew Adams
2006-05-14  2:16     ` Miles Bader
2006-05-14  3:13       ` Drew Adams
2006-05-14  4:10         ` David Kastrup
2006-05-14  2:33     ` Miles Bader
2006-05-14 13:17 ` Stefan Monnier
2006-05-14 14:32   ` Drew Adams [this message]
2006-05-14 14:46     ` Miles Bader
2006-05-14 16:13       ` Drew Adams
2006-05-14 17:49         ` Stefan Monnier
2006-05-14 18:43           ` Drew Adams

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DNEMKBNJBGPAOPIJOOICGEANDGAA.drew.adams@oracle.com \
    --to=drew.adams@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).