aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1997-07-21 05:16:37 +0000
committerRichard M. Stallman1997-07-21 05:16:37 +0000
commit87b6ab4c4afdb3c264acff6c24970bc7edfd7bdb (patch)
tree202bf63eeb4415526f5f83b36acbeb0d58b4ec70
parent59fed028fe15e8c4998ede9cc8e09d8c414f7e8f (diff)
downloademacs-87b6ab4c4afdb3c264acff6c24970bc7edfd7bdb.tar.gz
emacs-87b6ab4c4afdb3c264acff6c24970bc7edfd7bdb.zip
(internal-facep): Length is now 10.
(make-face, x-create-frame-with-faces): Make a face 10 elements long. (internal-set-face-1): Don't call set-face-attribute-internal if NAME is nil. (set-face-font): Set the auto-flag to t or nil. (face-spec-set): Clear out the font at the start, if it was set automatically before. (face-font-explicit): New function. (set-face-font-auto): New function. (set-face-font-explicit): New function. (copy-face): Copy the face-font-external flag. (internal-try-face-font): Use set-face-font-auto.
-rw-r--r--lisp/faces.el49
1 files changed, 41 insertions, 8 deletions
diff --git a/lisp/faces.el b/lisp/faces.el
index 09a8082bc3f..60690b648ed 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -31,11 +31,13 @@
31 (put 'face-name 'byte-optimizer nil) 31 (put 'face-name 'byte-optimizer nil)
32 (put 'face-id 'byte-optimizer nil) 32 (put 'face-id 'byte-optimizer nil)
33 (put 'face-font 'byte-optimizer nil) 33 (put 'face-font 'byte-optimizer nil)
34 (put 'face-font-explicit 'byte-optimizer nil)
34 (put 'face-foreground 'byte-optimizer nil) 35 (put 'face-foreground 'byte-optimizer nil)
35 (put 'face-background 'byte-optimizer nil) 36 (put 'face-background 'byte-optimizer nil)
36 (put 'face-stipple 'byte-optimizer nil) 37 (put 'face-stipple 'byte-optimizer nil)
37 (put 'face-underline-p 'byte-optimizer nil) 38 (put 'face-underline-p 'byte-optimizer nil)
38 (put 'set-face-font 'byte-optimizer nil) 39 (put 'set-face-font 'byte-optimizer nil)
40 (put 'set-face-font-auto 'byte-optimizer nil)
39 (put 'set-face-foreground 'byte-optimizer nil) 41 (put 'set-face-foreground 'byte-optimizer nil)
40 (put 'set-face-background 'byte-optimizer nil) 42 (put 'set-face-background 'byte-optimizer nil)
41 (put 'set-face-stipple 'byte-optimizer nil) 43 (put 'set-face-stipple 'byte-optimizer nil)
@@ -48,7 +50,7 @@
48 50
49;;; Type checkers. 51;;; Type checkers.
50(defsubst internal-facep (x) 52(defsubst internal-facep (x)
51 (and (vectorp x) (= (length x) 9) (eq (aref x 0) 'face))) 53 (and (vectorp x) (= (length x) 10) (eq (aref x 0) 'face)))
52 54
53(defun facep (x) 55(defun facep (x)
54 "Return t if X is a face name or an internal face vector." 56 "Return t if X is a face name or an internal face vector."
@@ -78,6 +80,10 @@ If FRAME is t, report on the defaults for face FACE (for new frames).
78If FRAME is omitted or nil, use the selected frame." 80If FRAME is omitted or nil, use the selected frame."
79 (aref (internal-get-face face frame) 3)) 81 (aref (internal-get-face face frame) 3))
80 82
83(defun face-font-explicit (face &optional frame)
84 "Return non-nil if this face's font was explicitly specified."
85 (aref (internal-get-face face frame) 9))
86
81(defun face-foreground (face &optional frame) 87(defun face-foreground (face &optional frame)
82 "Return the foreground color name of face FACE, or nil if unspecified. 88 "Return the foreground color name of face FACE, or nil if unspecified.
83If the optional argument FRAME is given, report on face FACE in that frame. 89If the optional argument FRAME is given, report on face FACE in that frame.
@@ -153,8 +159,29 @@ in that frame; otherwise change each frame."
153 (if (stringp font) 159 (if (stringp font)
154 (setq font (or (query-fontset font) 160 (setq font (or (query-fontset font)
155 (x-resolve-font-name font 'default frame)))) 161 (x-resolve-font-name font 'default frame))))
162 (internal-set-face-1 face 'font font 3 frame)
163 ;; Record that this face's font was set explicitly, not automatically,
164 ;; unless we are setting it to nil.
165 (internal-set-face-1 face nil (not (null font)) 9 frame))
166
167(defun set-face-font-auto (face font &optional frame)
168 "Change the font of face FACE to FONT (a string), for an automatic change.
169An automatic change means that we don't change the \"explicit\" flag;
170if the font was derived from the frame font before, it is now.
171If the optional FRAME argument is provided, change only
172in that frame; otherwise change each frame."
173 (interactive (internal-face-interactive "font"))
174 (if (stringp font)
175 (setq font (or (query-fontset font)
176 (x-resolve-font-name font 'default frame))))
156 (internal-set-face-1 face 'font font 3 frame)) 177 (internal-set-face-1 face 'font font 3 frame))
157 178
179(defun set-face-font-explicit (face flag &optional frame)
180 "Set the explicit-font flag of face FACE to FLAG.
181If the optional FRAME argument is provided, change only
182in that frame; otherwise change each frame."
183 (internal-set-face-1 face 'font flag 9 frame))
184
158(defun set-face-foreground (face color &optional frame) 185(defun set-face-foreground (face color &optional frame)
159 "Change the foreground color of face FACE to COLOR (a string). 186 "Change the foreground color of face FACE to COLOR (a string).
160If the optional FRAME argument is provided, change only 187If the optional FRAME argument is provided, change only
@@ -403,9 +430,9 @@ If NAME is already a face, it is simply returned."
403 (if (eq name 'inverse-video) 430 (if (eq name 'inverse-video)
404 (or (eq value (aref internal-face index)) 431 (or (eq value (aref internal-face index))
405 (invert-face face frame)) 432 (invert-face face frame))
406 (if (fboundp 'set-face-attribute-internal) 433 (and name (fboundp 'set-face-attribute-internal)
407 (set-face-attribute-internal (face-id face) 434 (set-face-attribute-internal (face-id face)
408 name value frame)))) 435 name value frame))))
409 (aset internal-face index value))))) 436 (aset internal-face index value)))))
410 437
411 438
@@ -470,7 +497,7 @@ and always make a face whose attributes are all nil.
470If the face already exists, it is unmodified." 497If the face already exists, it is unmodified."
471 (interactive "SMake face: ") 498 (interactive "SMake face: ")
472 (or (internal-find-face name) 499 (or (internal-find-face name)
473 (let ((face (make-vector 9 nil))) 500 (let ((face (make-vector 10 nil)))
474 (aset face 0 'face) 501 (aset face 0 'face)
475 (aset face 1 name) 502 (aset face 1 name)
476 (let* ((frames (frame-list)) 503 (let* ((frames (frame-list))
@@ -611,6 +638,8 @@ to NEW-FACE on frame NEW-FRAME."
611 (set-face-font new-face (face-font old-face frame) new-frame) 638 (set-face-font new-face (face-font old-face frame) new-frame)
612 (error 639 (error
613 (set-face-font new-face nil new-frame))) 640 (set-face-font new-face nil new-frame)))
641 (set-face-font-explicit new-face (face-font-explicit old-face frame)
642 new-frame)
614 (set-face-foreground new-face (face-foreground old-face frame) new-frame) 643 (set-face-foreground new-face (face-foreground old-face frame) new-frame)
615 (set-face-background new-face (face-background old-face frame) new-frame) 644 (set-face-background new-face (face-background old-face frame) new-frame)
616 (set-face-stipple new-face 645 (set-face-stipple new-face
@@ -700,7 +729,7 @@ set its foreground and background to the default background and foreground."
700(defun internal-try-face-font (face font &optional frame) 729(defun internal-try-face-font (face font &optional frame)
701 "Like set-face-font, but returns nil on failure instead of an error." 730 "Like set-face-font, but returns nil on failure instead of an error."
702 (condition-case () 731 (condition-case ()
703 (set-face-font face font frame) 732 (set-face-font-auto face font frame)
704 (error nil))) 733 (error nil)))
705 734
706;; Manipulating font names. 735;; Manipulating font names.
@@ -1126,6 +1155,10 @@ See `defface' for information about SPEC."
1126 (display (nth 0 entry)) 1155 (display (nth 0 entry))
1127 (attrs (nth 1 entry))) 1156 (attrs (nth 1 entry)))
1128 (setq tail (cdr tail)) 1157 (setq tail (cdr tail))
1158 ;; If the font was set automatically, clear it out
1159 ;; to allow it to be set it again.
1160 (unless (face-font-explicit face frame)
1161 (set-face-font face nil frame))
1129 (modify-face face nil nil nil nil nil nil frame) 1162 (modify-face face nil nil nil nil nil nil frame)
1130 (when (face-spec-set-match-display display frame) 1163 (when (face-spec-set-match-display display frame)
1131 (face-spec-set-1 face frame attrs ':foreground 'set-face-foreground) 1164 (face-spec-set-1 face frame attrs ':foreground 'set-face-foreground)
@@ -1219,7 +1252,7 @@ If FRAME is nil, the current FRAME is used."
1219 (vector 'face 1252 (vector 'face
1220 (face-name (cdr elt)) 1253 (face-name (cdr elt))
1221 (face-id (cdr elt)) 1254 (face-id (cdr elt))
1222 nil nil nil nil nil nil))) 1255 nil nil nil nil nil nil nil)))
1223 global-face-data)) 1256 global-face-data))
1224 (set-frame-face-alist frame faces) 1257 (set-frame-face-alist frame faces)
1225 1258
@@ -1274,7 +1307,7 @@ If FRAME is nil, the current FRAME is used."
1274 (get face 'face-defface-spec))) 1307 (get face 'face-defface-spec)))
1275 (global (cdr (assq face global-face-data))) 1308 (global (cdr (assq face global-face-data)))
1276 (local (cdr (car rest)))) 1309 (local (cdr (car rest))))
1277 (when spec 1310 (when spec
1278 (face-spec-set face spec frame)) 1311 (face-spec-set face spec frame))
1279 (face-fill-in face global frame) 1312 (face-fill-in face global frame)
1280 (make-face-x-resource-internal local frame)) 1313 (make-face-x-resource-internal local frame))