Subject: Re: bug#911: 23.0.60; custom-set-faces causes "New Frame" to fail (max-specpdl-size)

From: martin rudalics <[email-masked]>
Date: Tue, 16 Sep 2008 16:54:47 +0200

>> Sorry.  Please append the code below at the end of your .emacs and send
 >> me the contents of the *face-spec-set-2* buffer after the bug occurred.
 >
 > Please see attached for contents of this buffer.

My bad.  When I tried this here it got me a buffer with a couple of
lines.  Yours is 600K :-( apologies to you and everyone on this list.

Please try again with the following (it should print only calls for the
default face and distinguish them according to where they are called in
`face-spec-recalc').  But please don't post it on the list this time if
it gets too large.

martin

;;;; Code starts here
(require 'cl)
(require 'faces)

(defvar face-counter 0)

(defun face-spec-recalc (face frame)
   "Reset the face attributes of FACE on FRAME according to its specs.
This applies the defface/custom spec first, then the custom theme specs,
then the override spec."
   (face-spec-reset-face face frame)
   (setq face-counter (1+ face-counter))
   (let ((face-sym (or (get face 'face-alias) face)))
     (or (get face 'customized-face)
	(get face 'saved-face)
	(progn
	  (when (eq face 'default)
	    (with-current-buffer (get-buffer-create "*face-spec-set-2*")
	      (insert
	       (format "%s-1 face %s frame %s spec %s\n" face-counter face frame spec))))
	  (face-spec-set-2 face frame (face-default-spec face))))
     (let ((theme-faces (reverse (get face-sym 'theme-face))))
       (dolist (spec theme-faces)
	(when (eq face 'default)
	  (with-current-buffer (get-buffer-create "*face-spec-set-2*")
	    (insert
	     (format "%s-2 face %s frame %s spec %s\n" face-counter face frame spec))))
	(face-spec-set-2 face frame (cadr spec))))
     (when (eq face 'default)
       (with-current-buffer (get-buffer-create "*face-spec-set-2*")
	(insert
	 (format "%s-3 face %s frame %s spec %s\n" face-counter face frame spec))))
     (face-spec-set-2 face frame (get face-sym 'face-override-spec))))
;;;; Code ends here