[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
face initialization bug on startup
From: |
Daiki Ueno |
Subject: |
face initialization bug on startup |
Date: |
Sun, 29 Jul 2007 11:40:07 +0900 |
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 <address@hidden>
* 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)))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;; 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
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- face initialization bug on startup,
Daiki Ueno <=