Function: face-valid-attribute-values

face-valid-attribute-values is a byte-compiled function defined in faces.el.gz.

Signature

(face-valid-attribute-values ATTRIBUTE &optional FRAME)

Documentation

Return valid values for face attribute ATTRIBUTE.

The optional argument FRAME is used to determine available fonts and colors. If it is nil or not specified, the selected frame is used. Value is an alist of (NAME . VALUE) if ATTRIBUTE expects a value out of a set of discrete values. Value is integerp if ATTRIBUTE expects an integer value.

Source Code

;; Defined in /usr/src/emacs/lisp/faces.el.gz
(defun face-valid-attribute-values (attribute &optional frame)
  "Return valid values for face attribute ATTRIBUTE.
The optional argument FRAME is used to determine available fonts
and colors.  If it is nil or not specified, the selected frame is used.
Value is an alist of (NAME . VALUE) if ATTRIBUTE expects a value out
of a set of discrete values.  Value is `integerp' if ATTRIBUTE expects
an integer value."
  (let ((valid
         (pcase attribute
           (:family
            (if (window-system frame)
                (mapcar (lambda (x) (cons x x))
                        (font-family-list))
	      ;; Only one font on TTYs.
	      (list (cons "default" "default"))))
           (:foundry
	    (list nil))
	   (:width
            (mapcar (lambda (x) (cons (symbol-name (aref x 1)) (aref x 1)))
		    font-width-table))
           (:weight
            (mapcar (lambda (x) (cons (symbol-name (aref x 1)) (aref x 1)))
		    font-weight-table))
	   (:slant
            (mapcar (lambda (x) (cons (symbol-name (aref x 1)) (aref x 1)))
		    font-slant-table))
	   ((or :inverse-video :extend)
            (mapcar (lambda (x) (cons (symbol-name x) x))
		    (internal-lisp-face-attribute-values attribute)))
           ((or :underline :overline :strike-through :box)
            (if (window-system frame)
                (nconc (mapcar (lambda (x) (cons (symbol-name x) x))
                               (internal-lisp-face-attribute-values attribute))
                       (mapcar (lambda (c) (cons c c))
                               (defined-colors frame)))
              (mapcar (lambda (x) (cons (symbol-name x) x))
		      (internal-lisp-face-attribute-values attribute))))
           ((or :foreground :background)
            (mapcar (lambda (c) (cons c c))
                    (defined-colors frame)))
           (:height
            'integerp)
           (:stipple
            (and (memq (window-system frame) '(x ns pgtk haiku)) ; No stipple on w32
                 (mapcar (lambda (item)
                           (cons item item))
                         (apply #'nconc
                                (mapcar (lambda (dir)
                                          (and (file-readable-p dir)
                                               (file-directory-p dir)
                                               (directory-files dir 'full)))
                                        x-bitmap-file-path)))))
           (:inherit
            (cons '("none" . nil)
                  (mapcar (lambda (c) (cons (symbol-name c) c))
                          (face-list))))
           (_
            (error "Internal error")))))
    (if (and (listp valid) (not (memq attribute '(:inherit))))
	(nconc (list (cons "unspecified" 'unspecified)) valid)
      valid)))