summaryrefslogtreecommitdiff
path: root/lisp/faces.el
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>2000-10-23 05:32:59 +0000
committerMiles Bader <miles@gnu.org>2000-10-23 05:32:59 +0000
commitb0f89caf6c73a19a31d9482b8bd971f7c3916881 (patch)
tree6aefac578fa68878730bce0d352e85f9fbe427a7 /lisp/faces.el
parentd624910b1291bae5198bf67ef864c51306d25b1b (diff)
downloademacs-b0f89caf6c73a19a31d9482b8bd971f7c3916881.tar.gz
(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.
Diffstat (limited to 'lisp/faces.el')
-rw-r--r--lisp/faces.el33
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."
(defun face-spec-choose (spec &optional frame)
- "Choose the proper attributes for FRAME, out of SPEC."
+ "Choose the proper attributes for FRAME, out of SPEC.
+If SPEC is nil, return nil."
(unless frame
(setq frame (selected-frame)))
(let ((tail spec)
@@ -1178,7 +1179,8 @@ If FRAME is nil, the current FRAME is used."
(defun face-spec-set (face spec &optional frame)
"Set FACE's attributes according to the first matching entry in SPEC.
FRAME is the frame whose frame-local face is set. FRAME nil means
-do it on all frames. See `defface' for information about SPEC."
+do it on all frames. See `defface' for information about SPEC.
+If SPEC is nil, do nothing."
(let ((attrs (face-spec-choose spec frame)))
(when attrs
(face-spec-reset-face face frame))
@@ -1219,6 +1221,16 @@ is used. If nil or omitted, use the selected frame."
"Return t if FACE, on FRAME, matches what SPEC says it should look like."
(face-attr-match-p face (face-spec-choose spec frame) frame))
+(defun face-user-default-spec (face)
+ "Return the user's customized face-spec for FACE, or the default if none.
+If there is neither a user setting or a default for FACE, return nil."
+ (or (get face 'saved-face)
+ (get face 'face-defface-spec)))
+
+(defun face-default-spec (face)
+ "Return the default face-spec for FACE, ignoring any user customization.
+If there is no default for FACE, return nil."
+ (get face 'face-defface-spec))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1351,11 +1363,7 @@ according to the `background-mode' and `display-type' frame parameters."
;; For all named faces, choose face specs matching the new frame
;; parameters.
(dolist (face (face-list))
- (let ((spec (or (get face 'saved-face)
- (get face 'face-defface-spec))))
- (when spec
- (face-spec-set face spec frame)))))))
-
+ (face-spec-set face (face-user-default-spec face) frame)))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -1440,13 +1448,10 @@ Value is the new frame created."
"Set frame-local faces of FRAME from face specs and resources.
Initialize colors of certain faces from frame parameters."
(dolist (face (face-list))
- (let ((spec (or (get face 'saved-face)
- (get face 'face-defface-spec))))
- (when spec
- (face-spec-set face spec frame))
- (internal-merge-in-global-face face frame)
- (when (memq window-system '(x w32 mac))
- (make-face-x-resource-internal face frame))))
+ (face-spec-set face (face-user-default-spec face) frame)
+ (internal-merge-in-global-face face frame)
+ (when (memq window-system '(x w32 mac))
+ (make-face-x-resource-internal face frame)))
;; Initialize attributes from frame parameters.
(let ((params '((foreground-color default :foreground)