From xemacs-m  Mon Mar  3 15:10:18 1997
Received: from elc1.dina.kvl.dk (elc1.dina.kvl.dk [130.225.40.228])
	by xemacs.org (8.8.5/8.8.5) with SMTP id PAA21565
	for <xemacs-beta@xemacs.org>; Mon, 3 Mar 1997 15:10:11 -0600 (CST)
Received: from zuse.dina.kvl.dk (zuse.dina.kvl.dk [130.225.40.245]) by elc1.dina.kvl.dk (8.6.12/8.6.4) with ESMTP id VAA14098; Mon, 3 Mar 1997 21:59:33 +0100
Received: (abraham@localhost) by zuse.dina.kvl.dk (8.6.12/8.6.4) id WAA14457; Mon, 3 Mar 1997 22:08:23 +0100
Sender: abraham@dina.kvl.dk
To: xemacs-beta@xemacs.org
Subject: Re: Patch to x-faces.el to implement `make-face-x-resource-internal'.
References: <rjg1yc6f66.fsf@zuse.dina.kvl.dk>
Organization: The Church of Emacs
X-Face: +kRV2]2q}lixHkE{U)mY#+6]{AH=yN~S9@IFiOa@X6?GM<U{B+4e{k79.Ya{~':DblFPCg$
 @60,BfLv2@SKZ19cMWK0/C'v;tM:|6B'R}U1rp6CL&kN({9<zF/V{:JCg27yC)9oZjeqcQawzKfiNL
 t9}`vjmK["dRQC/qGFQq"%u|Q`:6{"Rz}b(dnl_"3$Jtqimi>|8MBp/
From: Per Abrahamsen <abraham@dina.kvl.dk>
Date: 03 Mar 1997 22:08:23 +0100
In-Reply-To: Per Abrahamsen's message of 03 Mar 1997 18:47:29 +0100
Message-ID: <rjvi784raw.fsf@zuse.dina.kvl.dk>
Lines: 153
X-Mailer: Gnus v5.4.17/Emacs 19.34
Mime-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit


Per Abrahamsen <abraham@dina.kvl.dk> writes:

> PS: If there is a function to create a face _without_ looking up
> attributes in the X resources database, I could use that to speed up
> things, especially for people with slow X connections.

This didn't seem to be the case.  Here is a patch that:

1) Introduce the `init-face-from-resources' variable.   Set this to
   nil to avoid looking up face attributes in the X resources when
   creating a new face.  Apparently this is a slow operation when
   running X over a modem.

2) Introduce the function `make-empty-face', which is like `make-face'
   except that it doesn't look up resources.

With this patch, the handling of X resources in custom should work
should work the same on both Emacsen.

Mon Mar  3 17:50:04 1997  Per Abrahamsen  <abraham@dina.kvl.dk>

	* prim/faces.el (init-face-from-resources): New variable.
	(init-face-from-resources): Use it.
	(init-device-faces): Use it.
	(init-frame-faces): Use it.
	(make-empty-face): New function.

*** faces.el~	Thu Jan 30 03:22:42 1997
--- faces.el	Mon Mar  3 21:50:38 1997
***************
*** 1067,1118 ****
    (font-proportional-p (face-font face) domain charset))
  
  
  (defun init-face-from-resources (face &optional locale)
    "Initialize FACE from the resource database.
  If LOCALE is specified, it should be a frame, device, or 'global, and
  the face will be resourced over that locale.  Otherwise, the face will
  be resourced over all possible locales (i.e. all frames, all devices,
  and 'global)."
!   (if (not locale)
!       (progn
! 	(init-face-from-resources face 'global)
! 	(let ((devices (device-list)))
! 	  (while devices
! 	    (init-face-from-resources face (car devices))
! 	    (setq devices (cdr devices))))
! 	(let ((frames (frame-list)))
! 	  (while frames
! 	    (init-face-from-resources face (car frames))
! 	    (setq frames (cdr frames)))))
!     (let ((devtype (cond ((devicep locale) (device-type locale))
! 			 ((framep locale) (frame-type locale))
! 			 (t nil))))
!       (cond ((or (and (not devtype) (featurep 'x)) (eq 'x devtype))
! 	     (x-init-face-from-resources face locale))
! 	    ((or (not devtype) (eq 'tty devtype))
! 	     ;; Nothing to do for TTYs?
! 	     )))))
  
  (defun init-device-faces (device)
    ;; First, add any device-local face resources.
!   (loop for face in (face-list) do
! 	(init-face-from-resources face device))
!   ;; Then do any device-specific initialization.
!   (cond ((eq 'x (device-type device))
! 	 (x-init-device-faces device))
! 	;; Nothing to do for TTYs?
! 	)
!   (init-other-random-faces device))
  
  (defun init-frame-faces (frame)
!   ;; First, add any frame-local face resources.
!   (loop for face in (face-list) do
! 	(init-face-from-resources face frame))
!   ;; Then do any frame-specific initialization.
!   (cond ((eq 'x (frame-type frame))
! 	 (x-init-frame-faces frame))
! 	;; Is there anything which should be done for TTY's?
! 	))
  
  ;; #### This is somewhat X-specific, and is called when the first
  ;; X device is created (even if there were TTY devices created
--- 1067,1134 ----
    (font-proportional-p (face-font face) domain charset))
  
  
+ (defvar init-face-from-resources t
+   "If non-nil, attempt to initialize faces from the reseource database.")
+ 
+ (defun make-empty-face (name &optional doc-string temporary)
+   "Like `make-face', but doesn't query the reseource database."
+   (let ((init-face-from-resources nil))
+     (make-face name doc-string temporary)))
+ 
  (defun init-face-from-resources (face &optional locale)
    "Initialize FACE from the resource database.
  If LOCALE is specified, it should be a frame, device, or 'global, and
  the face will be resourced over that locale.  Otherwise, the face will
  be resourced over all possible locales (i.e. all frames, all devices,
  and 'global)."
!   (cond ((null init-face-from-resources)
! 	 ;; Do nothing.
! 	 )
! 	((not locale)
! 	 ;; Global, set for all frames.
! 	 (progn
! 	   (init-face-from-resources face 'global)
! 	   (let ((devices (device-list)))
! 	     (while devices
! 	       (init-face-from-resources face (car devices))
! 	       (setq devices (cdr devices))))
! 	   (let ((frames (frame-list)))
! 	     (while frames
! 	       (init-face-from-resources face (car frames))
! 	       (setq frames (cdr frames))))))
! 	(t
! 	 ;; Specific.
! 	 (let ((devtype (cond ((devicep locale) (device-type locale))
! 			      ((framep locale) (frame-type locale))
! 			      (t nil))))
! 	   (cond ((or (and (not devtype) (featurep 'x)) (eq 'x devtype))
! 		  (x-init-face-from-resources face locale))
! 		 ((or (not devtype) (eq 'tty devtype))
! 		  ;; Nothing to do for TTYs?
! 		  ))))))
  
  (defun init-device-faces (device)
    ;; First, add any device-local face resources.
!   (when init-face-from-resources
!     (loop for face in (face-list) do
! 	  (init-face-from-resources face device))
!     ;; Then do any device-specific initialization.
!     (cond ((eq 'x (device-type device))
! 	   (x-init-device-faces device))
! 	  ;; Nothing to do for TTYs?
! 	  )
!     (init-other-random-faces device)))
  
  (defun init-frame-faces (frame)
!   (when init-face-from-resources
!     ;; First, add any frame-local face resources.
!     (loop for face in (face-list) do
! 	  (init-face-from-resources face frame))
!     ;; Then do any frame-specific initialization.
!     (cond ((eq 'x (frame-type frame))
! 	   (x-init-frame-faces frame))
! 	  ;; Is there anything which should be done for TTY's?
! 	  )))
  
  ;; #### This is somewhat X-specific, and is called when the first
  ;; X device is created (even if there were TTY devices created

