From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Daiki Ueno Newsgroups: gmane.emacs.devel Subject: face initialization bug on startup Date: Sun, 29 Jul 2007 11:40:07 +0900 Message-ID: <7fa1fc80-3bbe-4d93-b7f5-766074e2cb5c@well-done.deisui.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Trace: sea.gmane.org 1185676827 28541 80.91.229.12 (29 Jul 2007 02:40:27 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Sun, 29 Jul 2007 02:40:27 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 29 04:40:21 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IEyhf-0007lf-FB for ged-emacs-devel@m.gmane.org; Sun, 29 Jul 2007 04:40:19 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IEyhe-0008Fl-6y for ged-emacs-devel@m.gmane.org; Sat, 28 Jul 2007 22:40:18 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IEyhb-0008Fg-BP for emacs-devel@gnu.org; Sat, 28 Jul 2007 22:40:15 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IEyhZ-0008FU-Qf for emacs-devel@gnu.org; Sat, 28 Jul 2007 22:40:15 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IEyhZ-0008FR-Oz for emacs-devel@gnu.org; Sat, 28 Jul 2007 22:40:13 -0400 Original-Received: from g96069.scn-net.ne.jp ([210.231.96.69] helo=localhost) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IEyhZ-00015w-0P for emacs-devel@gnu.org; Sat, 28 Jul 2007 22:40:13 -0400 Original-Received: from localhost ([127.0.0.1] helo=well-done.deisui.org) by localhost with esmtp (Exim 4.67) (envelope-from ) id 1IEyhU-0004b0-2R for emacs-devel@gnu.org; Sun, 29 Jul 2007 11:40:08 +0900 X-Attribution: DU Mail-Copies-To: poster X-detected-kernel: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:75769 Archived-At: 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 * 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