comparison lisp/faces.el @ 32758:a0ca98ed466a

(face-user-default-spec, face-default-spec): New functions. (face-spec-choose, face-spec-set): Document nil-SPEC behavior. (frame-set-background-mode, face-set-after-frame-default): Use `face-user-default-spec'. Simplify code slightly.
author Miles Bader <miles@gnu.org>
date Mon, 23 Oct 2000 05:32:59 +0000
parents ccfb1ed059ca
children 975cc2648ee4
comparison
equal deleted inserted replaced
32757:83e81820c89f 32758:a0ca98ed466a
1149 req options))))) 1149 req options)))))
1150 match)) 1150 match))
1151 1151
1152 1152
1153 (defun face-spec-choose (spec &optional frame) 1153 (defun face-spec-choose (spec &optional frame)
1154 "Choose the proper attributes for FRAME, out of SPEC." 1154 "Choose the proper attributes for FRAME, out of SPEC.
1155 If SPEC is nil, return nil."
1155 (unless frame 1156 (unless frame
1156 (setq frame (selected-frame))) 1157 (setq frame (selected-frame)))
1157 (let ((tail spec) 1158 (let ((tail spec)
1158 result) 1159 result)
1159 (while tail 1160 (while tail
1176 1177
1177 1178
1178 (defun face-spec-set (face spec &optional frame) 1179 (defun face-spec-set (face spec &optional frame)
1179 "Set FACE's attributes according to the first matching entry in SPEC. 1180 "Set FACE's attributes according to the first matching entry in SPEC.
1180 FRAME is the frame whose frame-local face is set. FRAME nil means 1181 FRAME is the frame whose frame-local face is set. FRAME nil means
1181 do it on all frames. See `defface' for information about SPEC." 1182 do it on all frames. See `defface' for information about SPEC.
1183 If SPEC is nil, do nothing."
1182 (let ((attrs (face-spec-choose spec frame))) 1184 (let ((attrs (face-spec-choose spec frame)))
1183 (when attrs 1185 (when attrs
1184 (face-spec-reset-face face frame)) 1186 (face-spec-reset-face face frame))
1185 (while attrs 1187 (while attrs
1186 (let ((attribute (car attrs)) 1188 (let ((attribute (car attrs))
1217 1219
1218 (defun face-spec-match-p (face spec &optional frame) 1220 (defun face-spec-match-p (face spec &optional frame)
1219 "Return t if FACE, on FRAME, matches what SPEC says it should look like." 1221 "Return t if FACE, on FRAME, matches what SPEC says it should look like."
1220 (face-attr-match-p face (face-spec-choose spec frame) frame)) 1222 (face-attr-match-p face (face-spec-choose spec frame) frame))
1221 1223
1224 (defun face-user-default-spec (face)
1225 "Return the user's customized face-spec for FACE, or the default if none.
1226 If there is neither a user setting or a default for FACE, return nil."
1227 (or (get face 'saved-face)
1228 (get face 'face-defface-spec)))
1229
1230 (defun face-default-spec (face)
1231 "Return the default face-spec for FACE, ignoring any user customization.
1232 If there is no default for FACE, return nil."
1233 (get face 'face-defface-spec))
1222 1234
1223 1235
1224 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1236 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1225 ;;; Frame-type independent color support. 1237 ;;; Frame-type independent color support.
1226 ;;; We keep the old x-* names as aliases for back-compatibility. 1238 ;;; We keep the old x-* names as aliases for back-compatibility.
1349 (list (cons 'background-mode bg-mode) 1361 (list (cons 'background-mode bg-mode)
1350 (cons 'display-type display-type))) 1362 (cons 'display-type display-type)))
1351 ;; For all named faces, choose face specs matching the new frame 1363 ;; For all named faces, choose face specs matching the new frame
1352 ;; parameters. 1364 ;; parameters.
1353 (dolist (face (face-list)) 1365 (dolist (face (face-list))
1354 (let ((spec (or (get face 'saved-face) 1366 (face-spec-set face (face-user-default-spec face) frame)))))
1355 (get face 'face-defface-spec))))
1356 (when spec
1357 (face-spec-set face spec frame)))))))
1358
1359 1367
1360 1368
1361 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1369 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1362 ;;; Frame creation. 1370 ;;; Frame creation.
1363 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 1371 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
1438 1446
1439 (defun face-set-after-frame-default (frame) 1447 (defun face-set-after-frame-default (frame)
1440 "Set frame-local faces of FRAME from face specs and resources. 1448 "Set frame-local faces of FRAME from face specs and resources.
1441 Initialize colors of certain faces from frame parameters." 1449 Initialize colors of certain faces from frame parameters."
1442 (dolist (face (face-list)) 1450 (dolist (face (face-list))
1443 (let ((spec (or (get face 'saved-face) 1451 (face-spec-set face (face-user-default-spec face) frame)
1444 (get face 'face-defface-spec)))) 1452 (internal-merge-in-global-face face frame)
1445 (when spec 1453 (when (memq window-system '(x w32 mac))
1446 (face-spec-set face spec frame)) 1454 (make-face-x-resource-internal face frame)))
1447 (internal-merge-in-global-face face frame)
1448 (when (memq window-system '(x w32 mac))
1449 (make-face-x-resource-internal face frame))))
1450 1455
1451 ;; Initialize attributes from frame parameters. 1456 ;; Initialize attributes from frame parameters.
1452 (let ((params '((foreground-color default :foreground) 1457 (let ((params '((foreground-color default :foreground)
1453 (background-color default :background) 1458 (background-color default :background)
1454 (border-color border :background) 1459 (border-color border :background)