0

I try to find the documentation for the function face-attributes-as-vector or any other function which gives my access to the face definition.

Emacs contains just the following information:

face-attributes-as-vector is a built-in function in ‘C source code’.

(face-attributes-as-vector PLIST)

Return a vector of face attributes corresponding to PLIST.

[back]

How to know which vector element contains which face attribute?

2 Answers 2

1

Here we are:

/* Indices of face attributes in Lisp face vectors.  Slot zero is the
   symbol `face'.  */


enum lface_attribute_index
{
  LFACE_FAMILY_INDEX = 1,
  LFACE_FOUNDRY_INDEX,
  LFACE_SWIDTH_INDEX,
  LFACE_HEIGHT_INDEX,
  LFACE_WEIGHT_INDEX,
  LFACE_SLANT_INDEX,
  LFACE_UNDERLINE_INDEX,
  LFACE_INVERSE_INDEX,
  LFACE_FOREGROUND_INDEX,
  LFACE_BACKGROUND_INDEX,
  LFACE_STIPPLE_INDEX,
  LFACE_OVERLINE_INDEX,
  LFACE_STRIKE_THROUGH_INDEX,
  LFACE_BOX_INDEX,
  LFACE_FONT_INDEX,
  LFACE_INHERIT_INDEX,
  LFACE_FONTSET_INDEX,
  LFACE_DISTANT_FOREGROUND_INDEX,
  LFACE_VECTOR_SIZE
};
0

Sorry. I got it myself. face-attributes-as-vector is not so useful. There is better way to get the colors.

This lists the attributes of a face:

(mapcar 'car face-attribute-name-alist)
  • :family
  • :foundry
  • :width
  • :height
  • :weight
  • :slant
  • :underline
  • :overline
  • :strike-through
  • :box
  • :inverse-video
  • :foreground
  • :background
  • :stipple
  • :inherit

And internal-get-lisp-face-attribute extracts the information from a face.

(internal-get-lisp-face-attribute 'font-lock-comment-face :foreground) => "Firebrick"

This returns all foreground colors:

(seq-filter (function
             (lambda (x)
               (stringp (cadr x))))
            (mapcar (function
                     (lambda (face)
                       (cons face
                             (let ((fg (internal-get-lisp-face-attribute face :foreground)))
                               (list fg (color-values fg))))))
                    (face-list)))

On my system:

((speedbar-separator-face "white" (65535 65535 65535))
 (speedbar-selected-face "red" (65535 0 0))
 (speedbar-tag-face "brown" (42405 10794 10794))
 (speedbar-directory-face "blue4" (0 0 35723))
 (speedbar-file-face "cyan4" (0 35723 35723))
 (speedbar-button-face "green4" (0 35723 0))
 (diff-context "#333333" (13056 13056 13056))
 (sh-quoted-exec "magenta" (65535 0 65535))
 (sh-heredoc "tan1" (65535 42405 20303))
 (yaml-tab-face "red" (65535 0 0))
 (tooltip "black" (0 0 0))
 (isearch "lightskyblue1" (45232 58082 65535))
 (font-lock-constant-face "dark cyan" (0 35723 35723))
 (font-lock-type-face "ForestGreen" (8738 35723 8738))
 (font-lock-variable-name-face "sienna" (41120 21074 11565))
 (font-lock-function-name-face "Blue1" (0 0 65535))
 (font-lock-builtin-face "dark slate blue" (18504 15677 35723))
 (font-lock-keyword-face "Purple" (41120 8224 61680))
 (font-lock-string-face "VioletRed4" (35723 8738 21074))
 (font-lock-comment-face "Firebrick" (45746 8738 8738))
 (show-paren-mismatch "white" (65535 65535 65535))
 (tty-menu-disabled-face "lightgray" (54227 54227 54227))
 (tty-menu-enabled-face "yellow" (65535 65535 0))
 (success "ForestGreen" (8738 35723 8738))
 (warning "DarkOrange" (65535 35980 0))
 (error "Red1" (65535 0 0))
 (tool-bar "black" (0 0 0))
 (minibuffer-prompt "medium blue" (0 0 52685))
 (window-divider-last-pixel "gray40" (26214 26214 26214))
 (window-divider-first-pixel "gray80" (52428 52428 52428))
 (window-divider "gray60" (39321 39321 39321))
 (header-line "grey20" (13107 13107 13107))
 (mode-line-inactive "grey20" (13107 13107 13107))
 (mode-line "black" (0 0 0))
 (escape-glyph "brown" (42405 10794 10794))
 (region "gtk_selection_fg_color" (11822 13364 13878))
 (link-visited "magenta4" (35723 0 35723))
 (link "RoyalBlue3" (14906 24415 52685))
 (shadow "grey50" (32639 32639 32639))
 (default "black" (0 0 0)))

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.