]> code.delx.au - gnu-emacs/blobdiff - lisp/faces.el
Merged in changes from CVS trunk.
[gnu-emacs] / lisp / faces.el
index 7bcaf7b6f019f89b8757f10023c4df781abc46f0..a9189d5f8f6865df74c804916b2ff2ad8cf566bc 100644 (file)
@@ -240,27 +240,24 @@ If FRAME is omitted or nil, use the selected frame."
 
 
 (defun face-differs-from-default-p (face &optional frame)
-  "Non-nil if FACE displays differently from the default face.
+  "Return non-nil if FACE displays differently from the default face.
 If the optional argument FRAME is given, report on face FACE in that frame.
 If FRAME is t, report on the defaults for face FACE (for new frames).
-If FRAME is omitted or nil, use the selected frame.
-A face is considered to be ``the same'' as the default face if it is
-actually specified in the same way (equal attributes) or if it is
-fully-unspecified, and thus inherits the attributes of any face it
-is displayed on top of."
-  (cond ((eq frame t) (setq frame nil))
-       ((null frame) (setq frame (selected-frame))))
-  (let* ((v1 (internal-lisp-face-p face frame))
-        (n (if v1 (length v1) 0))
-        (v2 (internal-lisp-face-p 'default frame))
-        (i 1))
-    (unless v1
-      (error "Not a face: %S" face))
-    (while (and (< i n)
-               (or (eq 'unspecified (aref v1 i))
-                   (equal (aref v1 i) (aref v2 i))))
-      (setq i (1+ i)))
-    (< i n)))
+If FRAME is omitted or nil, use the selected frame."
+  (let ((attrs
+        '(:family :width :height :weight :slant :foreground
+          :foreground :background :underline :overline
+          :strike-through :box :inverse-video))
+       (differs nil))
+    (while (and attrs (not differs))
+      (let* ((attr (pop attrs))
+            (attr-val (face-attribute face attr frame t)))
+       (when (and
+              (not (eq attr-val 'unspecified))
+              (display-supports-face-attributes-p (list attr attr-val)
+                                                  frame))
+         (setq differs attr))))
+    differs))
 
 
 (defun face-nontrivial-p (face &optional frame)
@@ -1337,21 +1334,29 @@ If SPEC is nil, return nil."
   (unless frame
     (setq frame (selected-frame)))
   (let ((tail spec)
-       result all)
+       result defaults)
     (while tail
       (let* ((entry (pop tail))
             (display (car entry))
-            (attrs (cdr entry)))
-       (when (face-spec-set-match-display display frame)
-         (setq result (if (null (cdr attrs)) ;; was (listp (car attrs))
-                          ;; Old-style entry, the attribute list is the
-                          ;; first element.
-                          (car attrs)
-                        attrs))
-         (if (eq display t)
-             (setq all result result nil)
+            (attrs (cdr entry))
+            thisval)
+       ;; Get the attributes as actually specified by this alternative.
+       (setq thisval
+             (if (null (cdr attrs)) ;; was (listp (car attrs))
+                 ;; Old-style entry, the attribute list is the
+                 ;; first element.
+                 (car attrs)
+               attrs))
+
+       ;; If the condition is `default', that sets the default
+       ;; for following conditions.
+       (if (eq display 'default)
+           (setq defaults thisval)
+         ;; Otherwise, if it matches, use it.
+         (when (face-spec-set-match-display display frame)
+           (setq result thisval)
            (setq tail nil)))))
-    (if all (append result all) result)))
+    (if defaults (append result defaults) result)))
 
 
 (defun face-spec-reset-face (face &optional frame)
@@ -1489,33 +1494,6 @@ If omitted or nil, that stands for the selected frame's display."
      (t
       (> (tty-color-gray-shades display) 2)))))
 
-(defun display-supports-face-attributes-p (attributes &optional display)
-  "Return non-nil if all the face attributes in ATTRIBUTES are supported.
-The optional argument DISPLAY can be a display name, a frame, or
-nil (meaning the selected frame's display)
-
-The definition of `supported' is somewhat heuristic, but basically means
-that a face containing all the attributes in ATTRIBUTES, when merged
-with the default face for display, can be represented in a way that's
-
- (1) different in appearance than the default face, and
- (2) `close in spirit' to what the attributes specify, if not exact.
-
-Point (2) implies that a `:weight black' attribute will be satisfied by
-any display that can display bold, and a `:foreground \"yellow\"' as long
-as it can display a yellowish color, but `:slant italic' will _not_ be
-satisfied by the tty display code's automatic substitution of a `dim'
-face for italic."
-  (let ((frame
-        (if (framep display)
-            display
-          (car (frames-on-display-list display)))))
-    ;; For now, we assume that non-tty displays can support everything.
-    ;; Later, we should add the ability to query about specific fonts,
-    ;; colors, etc.
-    (or (memq (framep frame) '(x w32 mac))
-       (tty-supports-face-attributes-p attributes frame))))
-
 \f
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Background mode.
@@ -1764,12 +1742,10 @@ Parameters not specified by PARAMETERS are taken from
 `default-frame-alist'.  If either PARAMETERS or `default-frame-alist'
 contains a `reverse' parameter, handle that.  Value is the new frame
 created."
-  (let ((old-frame (selected-frame))
-       (frame (make-terminal-frame parameters))
+  (let ((frame (make-terminal-frame parameters))
        success)
     (unwind-protect
-       (progn
-         (select-frame frame)
+       (with-selected-frame frame
          (tty-handle-reverse-video frame (frame-parameters frame))
          (frame-set-background-mode frame)
          (face-set-after-frame-default frame)
@@ -1790,7 +1766,6 @@ created."
          (modify-frame-parameters frame '((interprogram-paste-function . nil)))
          (setq success t))
       (unless success
-       (select-frame old-frame)
        (delete-frame frame)))
     frame))
 
@@ -1812,7 +1787,7 @@ created."
 
 ;; Update a frame's faces when we change its default font.
 
-(defalias 'frame-update-faces 'ignore)
+(defalias 'frame-update-faces 'ignore "")
 (make-obsolete 'frame-update-faces "no longer necessary." "21.1")
 
 ;; Update the colors of FACE, after FRAME's own colors have been
@@ -1849,7 +1824,7 @@ created."
   :group 'basic-faces)
 
 (defface mode-line-inactive
-  '((t
+  '((default
      :inherit mode-line)
     (((type x w32 mac) (background light) (class color))
      :weight light
@@ -1869,7 +1844,7 @@ created."
 (put 'modeline-inactive 'face-alias 'mode-line-inactive)
 
 (defface header-line
-  '((t
+  '((default
      :inherit mode-line)
     (((type tty))
      ;; This used to be `:inverse-video t', but that doesn't look very
@@ -1905,7 +1880,7 @@ created."
 
 
 (defface tool-bar
-  '((t
+  '((default
      :box (:line-width 1 :style released-button)
      :foreground "black")
     (((type x w32 mac) (class color))
@@ -1987,11 +1962,13 @@ created."
 
 
 (defface cursor '()
-  "Basic face for the cursor color under X."
+  "Basic face for the cursor color under X.
+Note: Other faces cannot inherit from the cursor face."
   :version "21.1"
   :group 'cursor
   :group 'basic-faces)
 
+(put 'cursor 'face-no-inherit t)
 
 (defface mouse '()
   "Basic face for the mouse color under X."
@@ -2082,7 +2059,11 @@ created."
   :group 'font-lock                    ; like `show-trailing-whitespace'
   :group 'basic-faces)
 
-
+(defface escape-glyph '((((background dark)) :foreground "cyan")
+                       (((type pc)) :foreground "magenta")
+                       (t :foreground "blue"))
+  "Face for characters displayed as ^-sequences or \-sequences."
+  :group 'basic-faces)
 \f
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;; Manipulating font names.