comparison lisp/faces.el @ 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 f4fc0c4c76f9
children a7b260d27c2c
comparison
equal deleted inserted replaced
2763:a93e407bf41c 2764:17c322204ce3
602 (error "No %s version of %S" face ofont))))) 602 (error "No %s version of %S" face ofont)))))
603 603
604 ;;; Make the builtin faces; the C code knows these as faces 0, 1, and 2, 604 ;;; Make the builtin faces; the C code knows these as faces 0, 1, and 2,
605 ;;; respectively, so they must be the first three faces made. 605 ;;; respectively, so they must be the first three faces made.
606 606
607 (if (internal-find-face 'default) 607 (defun face-initialize ()
608 nil
609 (make-face 'default) 608 (make-face 'default)
610 (make-face 'modeline) 609 (make-face 'modeline)
611 (make-face 'highlight) 610 (make-face 'highlight)
612 ;; 611 ;;
613 ;; These aren't really special in any way, but they're nice to have around. 612 ;; These aren't really special in any way, but they're nice to have around.
615 ;; 614 ;;
616 (make-face 'bold) 615 (make-face 'bold)
617 (make-face 'italic) 616 (make-face 'italic)
618 (make-face 'bold-italic) 617 (make-face 'bold-italic)
619 (make-face 'primary-selection) 618 (make-face 'primary-selection)
620 (make-face 'secondary-selection)) 619 (make-face 'secondary-selection)
620
621 ;; Set up the faces of all existing X Window frames.
622 (let ((frames (frame-list)))
623 (while frames
624 (if (eq (framep (car frames)) 'x)
625 (x-initialize-frame-faces (car frames)))
626 (setq frames (cdr frames)))))
627
621 628
622 ;;; This really belongs in setting a frame's own font. 629 ;;; This really belongs in setting a frame's own font.
623 ;;; ;; 630 ;;; ;;
624 ;;; ;; No font specified in the resource database; try to cope. 631 ;;; ;; No font specified in the resource database; try to cope.
625 ;;; ;; 632 ;;; ;;
712 (sit-for 1)) 719 (sit-for 1))
713 720
714 ;; Like x-create-frame but also set up the faces. 721 ;; Like x-create-frame but also set up the faces.
715 722
716 (defun x-create-frame-with-faces (&optional parameters) 723 (defun x-create-frame-with-faces (&optional parameters)
717 (let* ((frame (x-create-frame parameters)) 724 (if (null global-face-data)
718 (faces (copy-alist global-face-data)) 725 (x-create-frame parameters)
719 (rest faces) 726 (let* ((frame (x-create-frame parameters))
720 default modeline) 727 (faces (copy-alist global-face-data))
721 (set-frame-face-alist frame faces) 728 (rest faces)
722 729 default modeline)
723 ;; Copy the vectors that represent the faces. 730 (set-frame-face-alist frame faces)
724 ;; Also fill them in from X resources. 731
725 (while rest 732 ;; Copy the vectors that represent the faces.
726 (setcdr (car rest) (copy-sequence (cdr (car rest)))) 733 ;; Also fill them in from X resources.
727 (make-face-x-resource-internal (cdr (car rest)) frame t) 734 (while rest
728 (setq rest (cdr rest))) 735 (setcdr (car rest) (copy-sequence (cdr (car rest))))
729 736 (make-face-x-resource-internal (cdr (car rest)) frame t)
730 (setq default (internal-get-face 'default frame) 737 (setq rest (cdr rest)))
731 modeline (internal-get-face 'modeline frame)) 738
732 739 (setq default (internal-get-face 'default frame)
733 (x-initialize-frame-faces frame) 740 modeline (internal-get-face 'modeline frame))
734 741
735 ;;; ;; Make sure the modeline face is fully qualified. 742 (x-initialize-frame-faces frame)
736 ;;; (if (and (not (face-font modeline frame)) (face-font default frame)) 743
737 ;;; (set-face-font modeline (face-font default frame) frame)) 744 ;;; ;; Make sure the modeline face is fully qualified.
738 ;;; (if (and (not (face-background modeline frame)) 745 ;;; (if (and (not (face-font modeline frame)) (face-font default frame))
739 ;;; (face-background default frame)) 746 ;;; (set-face-font modeline (face-font default frame) frame))
740 ;;; (set-face-background modeline (face-background default frame) frame)) 747 ;;; (if (and (not (face-background modeline frame))
741 ;;; (if (and (not (face-foreground modeline frame)) 748 ;;; (face-background default frame))
742 ;;; (face-foreground default frame)) 749 ;;; (set-face-background modeline (face-background default frame) frame))
743 ;;; (set-face-foreground modeline (face-foreground default frame) frame)) 750 ;;; (if (and (not (face-foreground modeline frame))
744 frame)) 751 ;;; (face-foreground default frame))
745 752 ;;; (set-face-foreground modeline (face-foreground default frame) frame))
746 ;; Set up the faces of all existing frames. 753 frame)))
747 (let ((frames (frame-list))) 754
748 (while frames 755 ;; If we are already using x-window frames, initialize faces for them.
749 (if (eq (framep (car frames)) 'x) 756 (if (eq (framep (selected-frame)) 'x)
750 (x-initialize-frame-faces (car frames))) 757 (face-initialize))
751 (setq frames (cdr frames))))
752 758
753 (provide 'faces) 759 (provide 'faces)
754 760
755 ;;; faces.el ends here 761 ;;; faces.el ends here