aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorMiles Bader2004-06-04 02:50:50 +0000
committerMiles Bader2004-06-04 02:50:50 +0000
commit7e07a66d8514df69a4061e6c6fa6dfd8650c12fc (patch)
tree39ae05583f2cc50ebd679ee5c1cc189d410a41c7 /lisp
parent421c91e527cb39fc60480394f3c069914feb3d34 (diff)
downloademacs-7e07a66d8514df69a4061e6c6fa6dfd8650c12fc.tar.gz
emacs-7e07a66d8514df69a4061e6c6fa6dfd8650c12fc.zip
Revision: miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-369
Rewrite face-differs-from-default-p
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/faces.el54
2 files changed, 41 insertions, 19 deletions
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)