Function: ansi-color--face-vec-face

ansi-color--face-vec-face is a byte-compiled function defined in ansi-color.el.gz.

Signature

(ansi-color--face-vec-face FACE-VEC)

Documentation

Return the face corresponding to FACE-VEC.

FACE-VEC is a list containing information about the ANSI sequence code. It is usually stored as the car of the variable ansi-color-context-region.

Source Code

;; Defined in /usr/src/emacs/lisp/ansi-color.el.gz
(defun ansi-color--face-vec-face (face-vec)
  "Return the face corresponding to FACE-VEC.
FACE-VEC is a list containing information about the ANSI sequence
code.  It is usually stored as the car of the variable
`ansi-color-context-region'."
  (let* ((basic-faces (car face-vec))
         (colors (cdr face-vec))
         (bright (and ansi-color-bold-is-bright (aref basic-faces 1)))
         (faces nil))

    (when-let ((fg (car colors)))
      (push
       `(:foreground
         ,(or (ansi-color--code-as-hex fg)
              (face-foreground
               (aref (if (or bright (>= fg 8))
                         ansi-color-bright-colors-vector
                       ansi-color-normal-colors-vector)
                     (mod fg 8))
               nil 'default)))
       faces))
    (when-let ((bg (cadr colors)))
      (push
       `(:background
         ,(or (ansi-color--code-as-hex bg)
              (face-background
               (aref (if (or bright (>= bg 8))
                         ansi-color-bright-colors-vector
                       ansi-color-normal-colors-vector)
                     (mod bg 8))
               nil 'default)))
       faces))

    (let ((i 8))
      (while (> i 0)
        (setq i (1- i))
        (when (aref basic-faces i)
          (push (aref ansi-color-basic-faces-vector i) faces))))
    ;; Avoid some long-lived conses in the common case.
    (if (cdr faces)
        faces
      (car faces))))