intern-soft, find-face/get-face, and facep for determining faces' definedness
monnier at iro.umontreal.ca
Tue Nov 2 07:01:49 EST 2004
Miles> What's a "face object" in Emacs?
> A symbol, I should think. I was confused by the fact that `facep'
> returns a vector of length 17 whose first element is the symbol 'face.
> However, I would guess that that's a useless artifact of the
> implementation, since (facep (facep 'bold)) is nil.
I've never seen the vector used in Elisp for anything, so yes: it's just
a useless (and arguably ugly) artifact of the implementation.
Miles> [Indeed, what's a "face object" in Xemacs?]
> A C structure wrapped in Lisp housekeeping information that implements
> a face. I'm not sure why they were exposed to Lisp in the first
> place; I suspect to avoid repeated lookups in code that compares faces
> to determine if they contrast and the like. Probably a premature
I doubt the motivation was optimization. I think it had more to do with
> A face name is a symbol. A face object is a data structure.
I still don't understand why (facep 'foo) returns nil, even though
(put-text-property (point) (+ 10 (point)) 'face 'foo)
(set-face-foreground 'foo "red")
work just fine. I think `facep' should return non-nil iff the parameter can
be used at those places where faces are expected, so it should return
non-nil for symbols (assuming the symbol is indeed the name of an existing
face, of course).
Just like (progn (fset 'foobar (make-keymap)) (keymapp 'foobar)) return
t rather than nil.
More information about the XEmacs-Beta