From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Chong Yidong Newsgroups: gmane.emacs.devel Subject: Face initialization Date: Sun, 06 Jul 2008 01:57:48 -0400 Message-ID: <87skunbllv.fsf@stupidchicken.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1215323885 7031 80.91.229.12 (6 Jul 2008 05:58:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sun, 6 Jul 2008 05:58:05 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jul 06 07:58:51 2008 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 1KFNGs-0001CD-GH for ged-emacs-devel@m.gmane.org; Sun, 06 Jul 2008 07:58:50 +0200 Original-Received: from localhost ([127.0.0.1]:46582 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KFNG1-0002T1-8P for ged-emacs-devel@m.gmane.org; Sun, 06 Jul 2008 01:57:57 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KFNFv-0002Sr-P8 for emacs-devel@gnu.org; Sun, 06 Jul 2008 01:57:51 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KFNFu-0002SP-As for emacs-devel@gnu.org; Sun, 06 Jul 2008 01:57:50 -0400 Original-Received: from [199.232.76.173] (port=54551 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KFNFu-0002S9-5m for emacs-devel@gnu.org; Sun, 06 Jul 2008 01:57:50 -0400 Original-Received: from c-24-63-201-57.hsd1.ma.comcast.net ([24.63.201.57]:20894 helo=furry) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KFNFt-0002rZ-Jm for emacs-devel@gnu.org; Sun, 06 Jul 2008 01:57:49 -0400 Original-Received: by furry (Postfix, from userid 1000) id D534CC054; Sun, 6 Jul 2008 01:57:48 -0400 (EDT) X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) 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:100380 Archived-At: After staring at face-set-after-frame-default for a while, I think it can be simplified somewhat. If we only set frame parameters based on the parameter list explicitly passed to `make-frame', it shouldn't be necessary to mess around with the default face in the beginning of the function. Also, the call to make-face-x-resource-internal seems to be unnecessary. I think this also fixes some of the problems with faces in new frames that we've been seeing. Could someone test this patch out and see if I've missed anything? *** trunk/lisp/faces.el.~1.417.~ 2008-07-06 01:05:46.000000000 -0400 --- trunk/lisp/faces.el 2008-07-06 01:46:31.000000000 -0400 *************** *** 1993,1999 **** (x-setup-function-keys frame) (x-handle-reverse-video frame parameters) (frame-set-background-mode frame) ! (face-set-after-frame-default frame) ;; Make sure the tool-bar is ready to be enabled. The ;; `tool-bar-lines' frame parameter will not take effect ;; without this call. --- 1993,1999 ---- (x-setup-function-keys frame) (x-handle-reverse-video frame parameters) (frame-set-background-mode frame) ! (face-set-after-frame-default frame parameters) ;; Make sure the tool-bar is ready to be enabled. The ;; `tool-bar-lines' frame parameter will not take effect ;; without this call. *************** *** 2006,2031 **** (delete-frame frame))) frame)) ! (defun face-set-after-frame-default (frame) "Set frame-local faces of FRAME from face specs and resources. Initialize colors of certain faces from frame parameters." - (if (face-attribute 'default :font t) - (set-face-attribute 'default frame :font - (face-attribute 'default :font t)) - (set-face-attribute 'default frame :family - (face-attribute 'default :family t)) - (set-face-attribute 'default frame :height - (face-attribute 'default :height t)) - (set-face-attribute 'default frame :slant - (face-attribute 'default :slant t)) - (set-face-attribute 'default frame :weight - (face-attribute 'default :weight t)) - (set-face-attribute 'default frame :width - (face-attribute 'default :width t))) ;; Find attributes that should be initialized from frame parameters. (let ((face-params '((foreground-color default :foreground) (background-color default :background) ! (font-parameter default :font) (border-color border :background) (cursor-color cursor :background) (scroll-bar-foreground scroll-bar :foreground) --- 2006,2018 ---- (delete-frame frame))) frame)) ! (defun face-set-after-frame-default (frame parameters) "Set frame-local faces of FRAME from face specs and resources. Initialize colors of certain faces from frame parameters." ;; Find attributes that should be initialized from frame parameters. (let ((face-params '((foreground-color default :foreground) (background-color default :background) ! (font default :font) (border-color border :background) (cursor-color cursor :background) (scroll-bar-foreground scroll-bar :foreground) *************** *** 2033,2071 **** (mouse-color mouse :background))) apply-params) (dolist (param face-params) ! (let* ((value (frame-parameter frame (nth 0 param))) (face (nth 1 param)) (attr (nth 2 param)) ! (default-value (face-attribute face attr t))) ;; Compile a list of face attributes to set, but don't set ;; them yet. The call to make-face-x-resource-internal, ;; below, can change frame parameters, and the final set of ;; frame parameters should be the ones acquired at this step. ! (if (eq default-value 'unspecified) ! ;; The face spec does not specify a new-frame value for ! ;; this attribute. Check if the existing frame parameter ! ;; specifies it. ! (if value ! (push (list face frame attr value) apply-params)) ! ;; The face spec specifies a value for this attribute, to be ! ;; applied to the face on all new frames. ! (push (list face frame attr default-value) apply-params)))) ! ;; Initialize faces from face specs and X resources. The ! ;; condition-case prevents invalid specs from causing frame ;; creation to fail. (dolist (face (face-list)) - ;; This loop used to exclude the `default' face for an unknown reason. - ;; It lead to odd behaviors where face-spec settings on the `default' - ;; face weren't obeyed for new frame. (condition-case () (progn (face-spec-recalc face frame) - (if (memq (window-system frame) '(x w32 mac)) - (make-face-x-resource-internal face frame)) (internal-merge-in-global-face face frame)) (error nil))) ! ;; Apply the attributes specified by frame parameters. This ! ;; rewrites parameters changed by make-face-x-resource-internal (dolist (param apply-params) (apply 'set-face-attribute param)))) --- 2020,2046 ---- (mouse-color mouse :background))) apply-params) (dolist (param face-params) ! (let* ((param-name (nth 0 param)) (face (nth 1 param)) (attr (nth 2 param)) ! (value (cdr (or (assq param-name parameters) ! (assq param-name default-frame-alist))))) ;; Compile a list of face attributes to set, but don't set ;; them yet. The call to make-face-x-resource-internal, ;; below, can change frame parameters, and the final set of ;; frame parameters should be the ones acquired at this step. ! (if value ! (push (list face frame attr value) apply-params)))) ! ;; Initialize faces from face specs and face-new-frame-defaults. ! ;; The condition-case prevents invalid specs from causing frame ;; creation to fail. (dolist (face (face-list)) (condition-case () (progn (face-spec-recalc face frame) (internal-merge-in-global-face face frame)) (error nil))) ! ;; Apply the attributes specified by frame parameters. (dolist (param apply-params) (apply 'set-face-attribute param)))) *************** *** 2104,2110 **** (set-locale-environment nil frame) (tty-run-terminal-initialization frame)) (frame-set-background-mode frame) ! (face-set-after-frame-default frame) (setq success t)) (unless success (delete-frame frame))) --- 2079,2085 ---- (set-locale-environment nil frame) (tty-run-terminal-initialization frame)) (frame-set-background-mode frame) ! (face-set-after-frame-default frame parameters) (setq success t)) (unless success (delete-frame frame))) *************** *** 2160,2166 **** (defun tty-set-up-initial-frame-faces () (let ((frame (selected-frame))) (frame-set-background-mode frame) ! (face-set-after-frame-default frame))) --- 2135,2141 ---- (defun tty-set-up-initial-frame-faces () (let ((frame (selected-frame))) (frame-set-background-mode frame) ! (face-set-after-frame-default frame nil)))