changeset 2764:17c322204ce3

(face-initialize): New function. All initialization code moved into it. Call at end of file, if using X frames already. (x-create-frame-with-faces): Don't use faces if not initialized.
author Richard M. Stallman <rms@gnu.org>
date Thu, 13 May 1993 03:24:09 +0000
parents a93e407bf41c
children 0eb1a195f56e
files lisp/faces.el
diffstat 1 files changed, 41 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/faces.el	Thu May 13 03:23:40 1993 +0000
+++ b/lisp/faces.el	Thu May 13 03:24:09 1993 +0000
@@ -604,8 +604,7 @@
 ;;; Make the builtin faces; the C code knows these as faces 0, 1, and 2,
 ;;; respectively, so they must be the first three faces made.
 
-(if (internal-find-face 'default)
-    nil
+(defun face-initialize ()
   (make-face 'default)
   (make-face 'modeline)
   (make-face 'highlight)
@@ -617,7 +616,15 @@
   (make-face 'italic)
   (make-face 'bold-italic)
   (make-face 'primary-selection)
-  (make-face 'secondary-selection))
+  (make-face 'secondary-selection)
+
+  ;; Set up the faces of all existing X Window frames.
+  (let ((frames (frame-list)))
+    (while frames
+      (if (eq (framep (car frames)) 'x)
+	  (x-initialize-frame-faces (car frames)))
+      (setq frames (cdr frames)))))
+
 
 ;;; This really belongs in setting a frame's own font.
 ;;;     ;;
@@ -714,41 +721,40 @@
 ;; Like x-create-frame but also set up the faces.
 
 (defun x-create-frame-with-faces (&optional parameters)
-  (let* ((frame (x-create-frame parameters))
-	 (faces (copy-alist global-face-data))
-	 (rest faces)
-	 default modeline)
-    (set-frame-face-alist frame faces)
+  (if (null global-face-data)
+      (x-create-frame parameters)
+    (let* ((frame (x-create-frame parameters))
+	   (faces (copy-alist global-face-data))
+	   (rest faces)
+	   default modeline)
+      (set-frame-face-alist frame faces)
 
-    ;; Copy the vectors that represent the faces.
-    ;; Also fill them in from X resources.
-    (while rest
-      (setcdr (car rest) (copy-sequence (cdr (car rest))))
-      (make-face-x-resource-internal (cdr (car rest)) frame t)
-      (setq rest (cdr rest)))
-
-    (setq default (internal-get-face 'default frame)
-	  modeline (internal-get-face 'modeline frame))
-	
-    (x-initialize-frame-faces frame)
+      ;; Copy the vectors that represent the faces.
+      ;; Also fill them in from X resources.
+      (while rest
+	(setcdr (car rest) (copy-sequence (cdr (car rest))))
+	(make-face-x-resource-internal (cdr (car rest)) frame t)
+	(setq rest (cdr rest)))
 
-;;;    ;; Make sure the modeline face is fully qualified.
-;;;    (if (and (not (face-font modeline frame)) (face-font default frame))
-;;;	(set-face-font modeline (face-font default frame) frame))
-;;;    (if (and (not (face-background modeline frame))
-;;;	     (face-background default frame))
-;;;	(set-face-background modeline (face-background default frame) frame))
-;;;    (if (and (not (face-foreground modeline frame))
-;;;	     (face-foreground default frame))
-;;;	(set-face-foreground modeline (face-foreground default frame) frame))
-    frame))
+      (setq default (internal-get-face 'default frame)
+	    modeline (internal-get-face 'modeline frame))
+
+      (x-initialize-frame-faces frame)
 
-;; Set up the faces of all existing frames.
-(let ((frames (frame-list)))
-  (while frames
-    (if (eq (framep (car frames)) 'x)
-	(x-initialize-frame-faces (car frames)))
-    (setq frames (cdr frames))))
+  ;;;    ;; Make sure the modeline face is fully qualified.
+  ;;;    (if (and (not (face-font modeline frame)) (face-font default frame))
+  ;;;	(set-face-font modeline (face-font default frame) frame))
+  ;;;    (if (and (not (face-background modeline frame))
+  ;;;	     (face-background default frame))
+  ;;;	(set-face-background modeline (face-background default frame) frame))
+  ;;;    (if (and (not (face-foreground modeline frame))
+  ;;;	     (face-foreground default frame))
+  ;;;	(set-face-foreground modeline (face-foreground default frame) frame))
+      frame)))
+
+;; If we are already using x-window frames, initialize faces for them.
+(if (eq (framep (selected-frame)) 'x)
+    (face-initialize))
 
 (provide 'faces)