Function: invert-face
invert-face is an interactive and byte-compiled function defined in
faces.el.gz.
Signature
(invert-face FACE &optional FRAME)
Documentation
Swap the foreground and background colors of FACE.
If FRAME is omitted or nil, it means change face on all frames. If FACE specifies neither foreground nor background color, set its foreground and background to the background and foreground of the default face. Value is FACE.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/faces.el.gz
(defun invert-face (face &optional frame)
"Swap the foreground and background colors of FACE.
If FRAME is omitted or nil, it means change face on all frames.
If FACE specifies neither foreground nor background color,
set its foreground and background to the background and foreground
of the default face. Value is FACE."
(interactive (list (read-face-name "Invert face" (face-at-point t))))
(let ((fg (face-attribute face :foreground frame))
(bg (face-attribute face :background frame)))
(if (not (and (eq fg 'unspecified) (eq bg 'unspecified)))
(set-face-attribute face frame :foreground bg :background fg)
(set-face-attribute face frame
:foreground
(face-attribute 'default :background frame)
:background
(face-attribute 'default :foreground frame))))
face)