Function: copy-face

copy-face is a byte-compiled function defined in faces.el.gz.

Signature

(copy-face OLD-FACE NEW-FACE &optional FRAME NEW-FRAME)

Documentation

Define a face named NEW-FACE, which is a copy of OLD-FACE.

This function does not copy face customization data, so NEW-FACE will not be made customizable. Most Lisp code should not call this function; use defface with :inherit instead.

If NEW-FACE already exists as a face, modify it to be like OLD-FACE. If NEW-FACE doesn't already exist, create it.

If the optional argument FRAME is a frame, change NEW-FACE on FRAME only. If FRAME is t, copy the frame-independent default specification for OLD-FACE to NEW-FACE. If FRAME is nil, copy the defaults as well as the faces on each existing frame.

If the optional fourth argument NEW-FRAME is given, copy the information from face OLD-FACE on frame FRAME to NEW-FACE on frame NEW-FRAME. In this case, FRAME must not be nil.

Probably introduced at or before Emacs version 19.20.

Source Code

;; Defined in /usr/src/emacs/lisp/faces.el.gz
(defun copy-face (old-face new-face &optional frame new-frame)
  "Define a face named NEW-FACE, which is a copy of OLD-FACE.
This function does not copy face customization data, so NEW-FACE
will not be made customizable.  Most Lisp code should not call
this function; use `defface' with :inherit instead.

If NEW-FACE already exists as a face, modify it to be like
OLD-FACE.  If NEW-FACE doesn't already exist, create it.

If the optional argument FRAME is a frame, change NEW-FACE on
FRAME only.  If FRAME is t, copy the frame-independent default
specification for OLD-FACE to NEW-FACE.  If FRAME is nil, copy
the defaults as well as the faces on each existing frame.

If the optional fourth argument NEW-FRAME is given, copy the
information from face OLD-FACE on frame FRAME to NEW-FACE on
frame NEW-FRAME.  In this case, FRAME must not be nil."
  (let ((inhibit-quit t))
    (if (null frame)
	(progn
	  (when new-frame
	    (error "Copying face %s from all frames to one frame"
		   old-face))
	  (make-empty-face new-face)
	  (dolist (frame (frame-list))
	    (copy-face old-face new-face frame))
	  (copy-face old-face new-face t))
      (make-empty-face new-face)
      (internal-copy-lisp-face old-face new-face frame new-frame))
    new-face))