diff options
| author | Miles Bader | 2000-10-23 05:32:59 +0000 |
|---|---|---|
| committer | Miles Bader | 2000-10-23 05:32:59 +0000 |
| commit | 96c2938fc90e85ea62c6c4fd9e108e1449dff591 (patch) | |
| tree | 228274aebfafaaf1063d51560c2a859970bca869 | |
| parent | 984905989e6b003a54655502cc85dde21f9e2fed (diff) | |
| download | emacs-96c2938fc90e85ea62c6c4fd9e108e1449dff591.tar.gz emacs-96c2938fc90e85ea62c6c4fd9e108e1449dff591.zip | |
(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.
| -rw-r--r-- | lisp/faces.el | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/lisp/faces.el b/lisp/faces.el index 28ebba796c4..ba0bfc70321 100644 --- a/lisp/faces.el +++ b/lisp/faces.el | |||
| @@ -1151,7 +1151,8 @@ If FRAME is nil, the current FRAME is used." | |||
| 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) |
| @@ -1178,7 +1179,8 @@ If FRAME is nil, the current FRAME is used." | |||
| 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)) |
| @@ -1219,6 +1221,16 @@ is used. If nil or omitted, use the selected 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 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| @@ -1351,11 +1363,7 @@ according to the `background-mode' and `display-type' frame parameters." | |||
| 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 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| @@ -1440,13 +1448,10 @@ Value is the new frame created." | |||
| 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) |