aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/NEWS4
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/faces.el54
-rw-r--r--lispref/display.texi6
4 files changed, 47 insertions, 23 deletions
diff --git a/etc/NEWS b/etc/NEWS
index 07f0f09739a..cc5eff864ad 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -3032,6 +3032,10 @@ A new predicate `supports' has also been added to the `defface' face
3032specification language, which can be used to do this test for faces 3032specification language, which can be used to do this test for faces
3033defined with defface. 3033defined with defface.
3034 3034
3035** The function face-differs-from-default-p now truly checks whether the
3036given face displays differently from the default face or not (previously
3037it did only a very cursory check).
3038
3035+++ 3039+++
3036** face-attribute, face-foreground, face-background, and face-stipple now 3040** face-attribute, face-foreground, face-background, and face-stipple now
3037accept a new optional argument, INHERIT, which controls how face 3041accept a new optional argument, INHERIT, which controls how face
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index c4f861626fd..70c3d9d8942 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,5 +1,11 @@
12004-06-04 Miles Bader <miles@gnu.org> 12004-06-04 Miles Bader <miles@gnu.org>
2 2
3 * faces.el (face-differs-from-default-p): Use a different
4 implementation, so we can really check whether FACE displays
5 differently or not.
6
72004-06-04 Miles Bader <miles@gnu.org>
8
3 * faces.el (display-supports-face-attributes-p): Implement a 9 * faces.el (display-supports-face-attributes-p): Implement a
4 `different from default' check for non-tty displays. 10 `different from default' check for non-tty displays.
5 11
diff --git a/lisp/faces.el b/lisp/faces.el
index 03e2ee699e7..cdc56075711 100644
--- a/lisp/faces.el
+++ b/lisp/faces.el
@@ -240,27 +240,43 @@ If FRAME is omitted or nil, use the selected frame."
240 240
241 241
242(defun face-differs-from-default-p (face &optional frame) 242(defun face-differs-from-default-p (face &optional frame)
243 "Non-nil if FACE displays differently from the default face. 243 "Return non-nil if FACE displays differently from the default face.
244If the optional argument FRAME is given, report on face FACE in that frame. 244If the optional argument FRAME is given, report on face FACE in that frame.
245If FRAME is t, report on the defaults for face FACE (for new frames). 245If FRAME is t, report on the defaults for face FACE (for new frames).
246If FRAME is omitted or nil, use the selected frame. 246If FRAME is omitted or nil, use the selected frame."
247A face is considered to be ``the same'' as the default face if it is 247 (if (not (equal (face-font face frame) (face-font 'default frame)))
248actually specified in the same way (equal attributes) or if it is 248 ;; The font is different from the default face's font, so clearly it
249fully-unspecified, and thus inherits the attributes of any face it 249 ;; differs. This only really works on window-systems; on ttys, the
250is displayed on top of." 250 ;; "font" is a constant, with attributes layered on top of it.
251 (cond ((eq frame t) (setq frame nil)) 251 :font
252 ((null frame) (setq frame (selected-frame)))) 252 ;; General face attribute check. On graphical displays
253 (let* ((v1 (internal-lisp-face-p face frame)) 253 ;; `display-supports-face-attributes-p' just checks whether each
254 (n (if v1 (length v1) 0)) 254 ;; attribute is different that the default face, so we just check to
255 (v2 (internal-lisp-face-p 'default frame)) 255 ;; make sure each attribute of the merged face is not `unspecified';
256 (i 1)) 256 ;; we already checked the font above, so font-related attributes are
257 (unless v1 257 ;; omitted for that reason. On a tty,
258 (error "Not a face: %S" face)) 258 ;; display-supports-face-attributes-p actually does do further
259 (while (and (< i n) 259 ;; checks, and correctly deals with the display's capabilities, so
260 (or (eq 'unspecified (aref v1 i)) 260 ;; we use it to check all attributes.
261 (equal (aref v1 i) (aref v2 i)))) 261 (let ((attrs
262 (setq i (1+ i))) 262 (if (memq (framep (or frame (selected-frame))) '(x w32 mac))
263 (< i n))) 263 ;; Omit font-related attributes on a window-system
264 '(:foreground :foreground :background :underline :overline
265 :strike-through :box :inverse-video :stipple)
266 ;; On a tty, check all attributes
267 '(:family :width :height :weight :slant :foreground
268 :foreground :background :underline :overline
269 :strike-through :box :inverse-video :stipple)))
270 (differs nil))
271 (while (and attrs (not differs))
272 (let* ((attr (pop attrs))
273 (attr-val (face-attribute face attr frame t)))
274 (when (and
275 (not (eq attr-val 'unspecified))
276 (display-supports-face-attributes-p (list attr attr-val)
277 frame))
278 (setq differs attr))))
279 differs)))
264 280
265 281
266(defun face-nontrivial-p (face &optional frame) 282(defun face-nontrivial-p (face &optional frame)
diff --git a/lispref/display.texi b/lispref/display.texi
index ddf8cdb4723..addf66dd7a6 100644
--- a/lispref/display.texi
+++ b/lispref/display.texi
@@ -2288,10 +2288,8 @@ same attributes for display.
2288@end defun 2288@end defun
2289 2289
2290@defun face-differs-from-default-p face &optional frame 2290@defun face-differs-from-default-p face &optional frame
2291This returns @code{t} if the face @var{face} displays differently from 2291This returns non-@code{nil} if the face @var{face} displays
2292the default face. A face is considered to be ``the same'' as the 2292differently from the default face.
2293default face if each attribute is either the same as that of the default
2294face, or unspecified (meaning to inherit from the default).
2295@end defun 2293@end defun
2296 2294
2297@node Auto Faces 2295@node Auto Faces