aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2010-10-13 23:55:18 -0400
committerChong Yidong2010-10-13 23:55:18 -0400
commit4983ddeaa82ea0d34b7dc9a6733f870da38b1c2e (patch)
treecb865f87f119b3369fd68a4d2eefc6da7b5b95ad
parenta974dcf2bba7eb9e3f4a407cc2ff1b714e6e7d2f (diff)
downloademacs-4983ddeaa82ea0d34b7dc9a6733f870da38b1c2e.tar.gz
emacs-4983ddeaa82ea0d34b7dc9a6733f870da38b1c2e.zip
Define a cursor defface; minor face optimizations.
* faces.el (face-spec-reset-face): Reset all attributes in one single call to set-face-attribute. (face-spec-match-p): Make it a defsubst. (frame-set-background-mode): New arg KEEP-FACE-SPECS. (x-create-frame-with-faces, tty-create-frame-with-faces) (tty-set-up-initial-frame-faces): Don't recompute face specs in frame-set-background-mode, since they are recomputed immediately afterwards in face-set-after-frame-default. (face-set-after-frame-default): Minor optimization. (cursor): Provide non-trivial defface spec. * custom.el (custom-theme-recalc-face): Simplify.
-rw-r--r--lisp/ChangeLog15
-rw-r--r--lisp/custom.el7
-rw-r--r--lisp/faces.el109
3 files changed, 76 insertions, 55 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 0d6b007f3b3..73a82346679 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,18 @@
12010-10-14 Chong Yidong <cyd@stupidchicken.com>
2
3 * faces.el (face-spec-reset-face): Reset all attributes in one
4 single call to set-face-attribute.
5 (face-spec-match-p): Make it a defsubst.
6 (frame-set-background-mode): New arg KEEP-FACE-SPECS.
7 (x-create-frame-with-faces, tty-create-frame-with-faces)
8 (tty-set-up-initial-frame-faces): Don't recompute face specs in
9 frame-set-background-mode, since they are recomputed immediately
10 afterwards in face-set-after-frame-default.
11 (face-set-after-frame-default): Minor optimization.
12 (cursor): Provide non-trivial defface spec.
13
14 * custom.el (custom-theme-recalc-face): Simplify.
15
12010-10-14 Jay Belanger <jay.p.belanger@gmail.com> 162010-10-14 Jay Belanger <jay.p.belanger@gmail.com>
2 17
3 * calc/calc-alg.el (math-var): Renamed from `var'. 18 * calc/calc-alg.el (math-var): Renamed from `var'.
diff --git a/lisp/custom.el b/lisp/custom.el
index 2cb4fb2e1be..c5ebe64da3c 100644
--- a/lisp/custom.el
+++ b/lisp/custom.el
@@ -1261,8 +1261,7 @@ See `custom-enabled-themes' for a list of enabled themes."
1261 ;; If the face spec specified by this theme is in the 1261 ;; If the face spec specified by this theme is in the
1262 ;; saved-face property, reset that property. 1262 ;; saved-face property, reset that property.
1263 (when (equal (nth 3 s) (get symbol 'saved-face)) 1263 (when (equal (nth 3 s) (get symbol 'saved-face))
1264 (put symbol 'saved-face 1264 (put symbol 'saved-face (and val (cadr (car val)))))
1265 (and val (cadr (car val)))))
1266 (custom-theme-recalc-face symbol))))) 1265 (custom-theme-recalc-face symbol)))))
1267 (setq custom-enabled-themes 1266 (setq custom-enabled-themes
1268 (delq theme custom-enabled-themes))))) 1267 (delq theme custom-enabled-themes)))))
@@ -1293,7 +1292,9 @@ This function returns nil if no custom theme specifies a value for VARIABLE."
1293 "Set FACE according to currently enabled custom themes." 1292 "Set FACE according to currently enabled custom themes."
1294 (if (get face 'face-alias) 1293 (if (get face 'face-alias)
1295 (setq face (get face 'face-alias))) 1294 (setq face (get face 'face-alias)))
1296 (face-spec-set face (get face 'face-override-spec))) 1295 ;; Reset the faces for each frame.
1296 (dolist (frame (frame-list))
1297 (face-spec-recalc face frame)))
1297 1298
1298 1299
1299;;; XEmacs compability functions 1300;;; XEmacs compability functions
diff --git a/lisp/faces.el b/lisp/faces.el
index 338b55632f9..23dc51e33ed 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -1507,12 +1507,11 @@ If SPEC is nil, return nil."
1507 1507
1508(defun face-spec-reset-face (face &optional frame) 1508(defun face-spec-reset-face (face &optional frame)
1509 "Reset all attributes of FACE on FRAME to unspecified." 1509 "Reset all attributes of FACE on FRAME to unspecified."
1510 (let ((attrs face-attribute-name-alist)) 1510 (let (reset-args)
1511 (while attrs 1511 (dolist (attr-and-name face-attribute-name-alist)
1512 (let ((attr-and-name (car attrs))) 1512 (push 'unspecified reset-args)
1513 (set-face-attribute face frame (car attr-and-name) 'unspecified)) 1513 (push (car attr-and-name) reset-args))
1514 (setq attrs (cdr attrs))))) 1514 (apply 'set-face-attribute face frame reset-args)))
1515
1516 1515
1517(defun face-spec-set (face spec &optional for-defface) 1516(defun face-spec-set (face spec &optional for-defface)
1518 "Set FACE's face spec, which controls its appearance, to SPEC. 1517 "Set FACE's face spec, which controls its appearance, to SPEC.
@@ -1578,8 +1577,8 @@ is used. If nil or omitted, use the selected frame."
1578 (setq frame (selected-frame))) 1577 (setq frame (selected-frame)))
1579 (let ((list face-attribute-name-alist) 1578 (let ((list face-attribute-name-alist)
1580 (match t)) 1579 (match t))
1581 (while (and match (not (null list))) 1580 (while (and match list)
1582 (let* ((attr (car (car list))) 1581 (let* ((attr (caar list))
1583 (specified-value 1582 (specified-value
1584 (if (plist-member attrs attr) 1583 (if (plist-member attrs attr)
1585 (plist-get attrs attr) 1584 (plist-get attrs attr)
@@ -1589,7 +1588,7 @@ is used. If nil or omitted, use the selected frame."
1589 (setq list (cdr list)))) 1588 (setq list (cdr list))))
1590 match)) 1589 match))
1591 1590
1592(defun face-spec-match-p (face spec &optional frame) 1591(defsubst face-spec-match-p (face spec &optional frame)
1593 "Return t if FACE, on FRAME, matches what SPEC says it should look like." 1592 "Return t if FACE, on FRAME, matches what SPEC says it should look like."
1594 (face-attr-match-p face (face-spec-choose spec frame) frame)) 1593 (face-attr-match-p face (face-spec-choose spec frame) frame))
1595 1594
@@ -1837,10 +1836,13 @@ variable with `setq'; this won't have the expected effect."
1837 1836
1838(defvar inhibit-frame-set-background-mode nil) 1837(defvar inhibit-frame-set-background-mode nil)
1839 1838
1840(defun frame-set-background-mode (frame) 1839(defun frame-set-background-mode (frame &optional keep-face-specs)
1841 "Set up display-dependent faces on FRAME. 1840 "Set up display-dependent faces on FRAME.
1842Display-dependent faces are those which have different definitions 1841Display-dependent faces are those which have different definitions
1843according to the `background-mode' and `display-type' frame parameters." 1842according to the `background-mode' and `display-type' frame parameters.
1843
1844If optional arg KEEP-FACE-SPECS is non-nil, don't recalculate
1845face specs for the new background mode."
1844 (unless inhibit-frame-set-background-mode 1846 (unless inhibit-frame-set-background-mode
1845 (let* ((bg-resource 1847 (let* ((bg-resource
1846 (and (window-system frame) 1848 (and (window-system frame)
@@ -1888,29 +1890,29 @@ according to the `background-mode' and `display-type' frame parameters."
1888 (let ((locally-modified-faces nil) 1890 (let ((locally-modified-faces nil)
1889 ;; Prevent face-spec-recalc from calling this function 1891 ;; Prevent face-spec-recalc from calling this function
1890 ;; again, resulting in a loop (bug#911). 1892 ;; again, resulting in a loop (bug#911).
1891 (inhibit-frame-set-background-mode t)) 1893 (inhibit-frame-set-background-mode t)
1892 ;; Before modifying the frame parameters, collect a list of 1894 (params (list (cons 'background-mode bg-mode)
1893 ;; faces that don't match what their face-spec says they 1895 (cons 'display-type display-type))))
1894 ;; should look like. We then avoid changing these faces 1896 (if keep-face-specs
1895 ;; below. These are the faces whose attributes were 1897 (modify-frame-parameters frame params)
1896 ;; modified on FRAME. We use a negative list on the 1898 ;; If we are recomputing face specs, first collect a list
1897 ;; assumption that most faces will be unmodified, so we can 1899 ;; of faces that don't match their face-specs. These are
1898 ;; avoid consing in the common case. 1900 ;; the faces modified on FRAME, and we avoid changing them
1899 (dolist (face (face-list)) 1901 ;; below. Use a negative list to avoid consing (we assume
1900 (and (not (get face 'face-override-spec)) 1902 ;; most faces are unmodified).
1901 (not (face-spec-match-p face 1903 (dolist (face (face-list))
1902 (face-user-default-spec face) 1904 (and (not (get face 'face-override-spec))
1903 (selected-frame))) 1905 (not (face-spec-match-p face
1904 (push face locally-modified-faces))) 1906 (face-user-default-spec face)
1905 ;; Now change to the new frame parameters 1907 (selected-frame)))
1906 (modify-frame-parameters frame 1908 (push face locally-modified-faces)))
1907 (list (cons 'background-mode bg-mode) 1909 ;; Now change to the new frame parameters
1908 (cons 'display-type display-type))) 1910 (modify-frame-parameters frame params)
1909 ;; For all named faces, choose face specs matching the new frame 1911 ;; For all unmodified named faces, choose face specs
1910 ;; parameters, unless they have been locally modified. 1912 ;; matching the new frame parameters.
1911 (dolist (face (face-list)) 1913 (dolist (face (face-list))
1912 (unless (memq face locally-modified-faces) 1914 (unless (memq face locally-modified-faces)
1913 (face-spec-recalc face frame)))))))) 1915 (face-spec-recalc face frame)))))))))
1914 1916
1915 1917
1916;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1918;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1990,7 +1992,7 @@ the X resource ``reverseVideo'' is present, handle that."
1990 (progn 1992 (progn
1991 (x-setup-function-keys frame) 1993 (x-setup-function-keys frame)
1992 (x-handle-reverse-video frame parameters) 1994 (x-handle-reverse-video frame parameters)
1993 (frame-set-background-mode frame) 1995 (frame-set-background-mode frame t)
1994 (face-set-after-frame-default frame parameters) 1996 (face-set-after-frame-default frame parameters)
1995 (if (null visibility-spec) 1997 (if (null visibility-spec)
1996 (make-frame-visible frame) 1998 (make-frame-visible frame)
@@ -2006,20 +2008,21 @@ Calculate the face definitions using the face specs, custom theme
2006settings, X resources, and `face-new-frame-defaults'. 2008settings, X resources, and `face-new-frame-defaults'.
2007Finally, apply any relevant face attributes found amongst the 2009Finally, apply any relevant face attributes found amongst the
2008frame parameters in PARAMETERS." 2010frame parameters in PARAMETERS."
2009 (dolist (face (nreverse (face-list))) ;Why reverse? --Stef 2011 (let ((window-system-p (memq (window-system frame) '(x w32))))
2010 (condition-case () 2012 (dolist (face (nreverse (face-list))) ;Why reverse? --Stef
2011 (progn 2013 (condition-case ()
2012 ;; Initialize faces from face spec and custom theme. 2014 (progn
2013 (face-spec-recalc face frame) 2015 ;; Initialize faces from face spec and custom theme.
2014 ;; X resouces for the default face are applied during 2016 (face-spec-recalc face frame)
2015 ;; x-create-frame. 2017 ;; X resouces for the default face are applied during
2016 (and (not (eq face 'default)) 2018 ;; `x-create-frame'.
2017 (memq (window-system frame) '(x w32)) 2019 (and (not (eq face 'default)) window-system-p
2018 (make-face-x-resource-internal face frame)) 2020 (make-face-x-resource-internal face frame))
2019 ;; Apply attributes specified by face-new-frame-defaults 2021 ;; Apply attributes specified by face-new-frame-defaults
2020 (internal-merge-in-global-face face frame)) 2022 (internal-merge-in-global-face face frame))
2021 ;; Don't let invalid specs prevent frame creation. 2023 ;; Don't let invalid specs prevent frame creation.
2022 (error nil))) 2024 (error nil))))
2025
2023 ;; Apply attributes specified by frame parameters. 2026 ;; Apply attributes specified by frame parameters.
2024 (let ((face-params '((foreground-color default :foreground) 2027 (let ((face-params '((foreground-color default :foreground)
2025 (background-color default :background) 2028 (background-color default :background)
@@ -2066,7 +2069,7 @@ If PARAMETERS contains a `reverse' parameter, handle that."
2066 (set-terminal-parameter frame 'terminal-initted t) 2069 (set-terminal-parameter frame 'terminal-initted t)
2067 (set-locale-environment nil frame) 2070 (set-locale-environment nil frame)
2068 (tty-run-terminal-initialization frame)) 2071 (tty-run-terminal-initialization frame))
2069 (frame-set-background-mode frame) 2072 (frame-set-background-mode frame t)
2070 (face-set-after-frame-default frame parameters) 2073 (face-set-after-frame-default frame parameters)
2071 (setq success t)) 2074 (setq success t))
2072 (unless success 2075 (unless success
@@ -2122,7 +2125,7 @@ terminal type to a different value."
2122 2125
2123(defun tty-set-up-initial-frame-faces () 2126(defun tty-set-up-initial-frame-faces ()
2124 (let ((frame (selected-frame))) 2127 (let ((frame (selected-frame)))
2125 (frame-set-background-mode frame) 2128 (frame-set-background-mode frame t)
2126 (face-set-after-frame-default frame))) 2129 (face-set-after-frame-default frame)))
2127 2130
2128 2131
@@ -2448,7 +2451,9 @@ used to display the prompt text."
2448 :group 'frames 2451 :group 'frames
2449 :group 'basic-faces) 2452 :group 'basic-faces)
2450 2453
2451(defface cursor '((t nil)) 2454(defface cursor
2455 '((((background light)) :background "black")
2456 (((background dark)) :background "white"))
2452 "Basic face for the cursor color under X. 2457 "Basic face for the cursor color under X.
2453Note: Other faces cannot inherit from the cursor face." 2458Note: Other faces cannot inherit from the cursor face."
2454 :version "21.1" 2459 :version "21.1"