all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* face initialization bug on startup
@ 2007-07-29  2:40 Daiki Ueno
  0 siblings, 0 replies; only message in thread
From: Daiki Ueno @ 2007-07-29  2:40 UTC (permalink / raw)
  To: emacs-devel

Hi,

I noticed a small face initialization bug on startup.  On xterm, if a
face-spec contains some old keywords like `:bold' and `:italic', the
face is not fixed by frame-set-background-mode.

To reproduce, put these two defface in your ~/.emacs, emacs -nw and M-x
list-faces-display, you will see test-face0 and test-face1 have
different foreground colors from each other.

(defface test-face0
  '((((background light))
     (:foreground "red" :bold t))
    (((background dark))
     (:foreground "blue" :bold t)))
  "Test face0"
  :group 'faces)

(defface test-face1
  '((((background light))
     (:foreground "red" :weight bold))
    (((background dark))
     (:foreground "blue" :weight bold)))
  "Test face1"
  :group 'faces)

Here is a patch.

2007-07-29  Daiki Ueno  <ueno@unixuser.org>

        * faces.el (face-normalize-spec): New function.
        (frame-set-background-mode): Normalize face-spec before calling
        face-spec-match-p.

Index: lisp/faces.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/faces.el,v
retrieving revision 1.372
diff -c -r1.372 faces.el
*** lisp/faces.el	26 Jul 2007 05:26:22 -0000	1.372
--- lisp/faces.el	29 Jul 2007 02:35:08 -0000
***************
*** 1506,1511 ****
--- 1506,1533 ----
        (get face 'saved-face)
        (face-default-spec face)))
  
+ (defsubst face-normalize-spec (spec)
+   "Return a normalized face-spec of SPEC."
+   (let (normalized-spec)
+     (while attrs
+       (let ((attribute (car spec))
+ 	    (value (car (cdr spec))))
+ 	;; Support some old-style attribute names and values.
+ 	(case attribute
+ 	  (:bold (setq attribute :weight value (if value 'bold 'normal)))
+ 	  (:italic (setq attribute :slant value (if value 'italic 'normal)))
+ 	  ((:foreground :background)
+ 	   ;; Compatibility with 20.x.  Some bogus face specs seem to
+ 	   ;; exist containing things like `:foreground nil'.
+ 	   (if (null value) (setq value 'unspecified)))
+ 	  (t (unless (assq attribute face-x-resources)
+ 	       (setq attribute nil))))
+ 	(when attribute
+ 	  (push attribute normalized-spec)
+ 	  (push value normalized-spec)))
+       (setq spec (cdr (cdr spec))))
+     (nreverse normalized-spec)))
+ 
  \f
  ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  ;;; Frame-type independent color support.
***************
*** 1648,1654 ****
  	;; be unmodified, so we can avoid consing in the common case.
  	(dolist (face (face-list))
  	  (when (not (face-spec-match-p face
! 					(face-user-default-spec face)
  					(selected-frame)))
  	    (push face locally-modified-faces)))
  	;; Now change to the new frame parameters
--- 1670,1677 ----
  	;; be unmodified, so we can avoid consing in the common case.
  	(dolist (face (face-list))
  	  (when (not (face-spec-match-p face
! 					(face-normalize-spec
! 					 (face-user-default-spec face))
  					(selected-frame)))
  	    (push face locally-modified-faces)))
  	;; Now change to the new frame parameters


Regards,
-- 
Daiki Ueno

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2007-07-29  2:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-29  2:40 face initialization bug on startup Daiki Ueno

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.