0

In the elisp manual, it says the default face must specify all face attributes. However, running

#+BEGIN_SRC emacs-lisp :results pp
  (face-all-attributes 'default)
#+END_SRC

#+RESULTS:
#+begin_example
((:family . unspecified)
 (:foundry . unspecified)
 (:width . unspecified)
 (:height . unspecified)
 (:weight . unspecified)
 (:slant . unspecified)
 (:underline . unspecified)
 (:overline . unspecified)
 (:strike-through . unspecified)
 (:box . unspecified)
 (:inverse-video . unspecified)
 (:foreground . unspecified)
 (:background . unspecified)
 (:stipple . unspecified)
 (:inherit . unspecified))
#+end_example

If we using the face-attribute function, however, we get

#+BEGIN_SRC emacs-lisp 
  (face-attribute 'default :family)
#+END_SRC

#+RESULTS:
: Ubuntu Mono

Is this a bug?

1 Answer 1

1

Ah, this one is a little confusing. face-all-attributes takes an optional second argument specifying the frame to query. If the frame is nil then it gives you the default attributes for the face. From `C-h f face-all-attributes:

Signature
(face-all-attributes FACE &optional FRAME)

Documentation
Return an alist stating the attributes of FACE.

Each element of the result has the form (ATTR-NAME . ATTR-VALUE).
If FRAME is omitted or nil the value describes the default attributes,
but if you specify FRAME, the value describes the attributes
of FACE on FRAME.

A demo:

(face-all-attributes 'default (selected-frame))
((:family . "DejaVu Sans Mono") (:foundry . "PfEd") (:width . normal) (:height . 120) (:weight . normal) (:slant . normal) (:underline) (:overline) (:strike-through) (:box) (:inverse-video) (:foreground . "black") ...)

face-attribute also takes an optional argument to specify the frame, but it treats nil differently:

Signature
(face-attribute FACE ATTRIBUTE &optional FRAME INHERIT)

Documentation
Return the value of FACE's ATTRIBUTE on FRAME.

If the optional argument FRAME is given, report on face FACE in that frame.
If FRAME is t, report on the defaults for face FACE (for new frames).
If FRAME is omitted or nil, use the selected frame.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.