(header-line): Suppress inverse-video on ttys.
[bpt/emacs.git] / lisp / faces.el
index 7b03819..2ee70a3 100644 (file)
@@ -4,6 +4,7 @@
 ;;   Free Software Foundation, Inc.
 
 ;; Maintainer: FSF
+;; Keywords: internal
 
 ;; This file is part of GNU Emacs.
 
@@ -195,13 +196,10 @@ should not be used anymore."
 If the optional argument FRAME is given, this gets the face NAME for
 that frame; otherwise, it uses the selected frame.
 If FRAME is the symbol t, then the global, non-frame face is returned.
-If NAME is already a face, it is simply returned.
-
-This function is defined for compatibility with Emacs 20.2.  It
-should not be used anymore."
+If NAME is already a face, it is simply returned."
   (or (facep name)
       (check-face name)))
-(make-obsolete 'internal-get-face "See `facep' and `check-face'." "21.1")
+(make-obsolete 'internal-get-face "see `facep' and `check-face'." "21.1")
 
 \f
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -879,7 +877,7 @@ Otherwise, return a single face."
                 (format "%s (default %s): " prompt
                         (if faces (mapconcat 'symbol-name faces ", ")
                           string-describing-default))
-              prompt)
+              (format "%s: " prompt))
             obarray 'custom-facep t))
           ;; Canonicalize the output.
           (output
@@ -894,8 +892,6 @@ Otherwise, return a single face."
        (car output)))))
 
 
-
-
 (defun face-valid-attribute-values (attribute &optional frame)
   "Return valid values for face attribute ATTRIBUTE.
 The optional argument FRAME is used to determine available fonts
@@ -1206,7 +1202,7 @@ The sample text is a string that comes from the variable
 
 (defun describe-face (face &optional frame)
   "Display the properties of face FACE on FRAME.
-Interactevely, FACE defaults to the faces of the character after point
+Interactively, FACE defaults to the faces of the character after point
 and FRAME defaults to the selected frame.
 
 If the optional argument FRAME is given, report on face FACE in that frame.
@@ -1246,7 +1242,7 @@ If FRAME is omitted or nil, use the selected frame."
              (princ (concat " (" customize-label ")\n"))
              (insert "Documentation: "
                      (or (face-documentation f)
-                         "not documented as a face.")
+                         "Not documented as a face.")
                      "\n\n")
              (with-current-buffer standard-output
                (save-excursion
@@ -1319,6 +1315,8 @@ If FRAME is nil, the current FRAME is used."
                        ((eq req 'background)
                         (memq (frame-parameter frame 'background-mode)
                               options))
+                       ((eq req 'supports)
+                        (display-supports-face-attributes-p options frame))
                        (t (error "Unknown req `%S' with options `%S'"
                                  req options)))))
     match))
@@ -1478,6 +1476,33 @@ 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 satisified 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
+satisified 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.
@@ -1727,7 +1752,7 @@ created."
 ;; Update a frame's faces when we change its default font.
 
 (defalias 'frame-update-faces 'ignore)
-(make-obsolete 'frame-update-faces "No longer necessary" "21.1")
+(make-obsolete 'frame-update-faces "no longer necessary." "21.1")
 
 ;; Update the colors of FACE, after FRAME's own colors have been
 ;; changed.
@@ -1774,7 +1799,7 @@ created."
      :box (:line-width -1 :color "grey40" :style nil)
      :foreground "grey80" :background "grey30"))
   "Basic mode line face for non-selected windows."
-  :version "21.2"
+  :version "21.4"
   :group 'modeline
   :group 'basic-faces)
 
@@ -1795,7 +1820,8 @@ created."
      ;; highlighting; this may be too confusing in general, although it
      ;; happens to look good with the only current use of header-lines,
      ;; the info browser. XXX
-     :underline t)
+     :underline t
+     :inverse-video nil)
     (((class color grayscale) (background light))
      :background "grey90" :foreground "grey20"
      :box nil)
@@ -1835,7 +1861,7 @@ created."
                             (((type pc)) :foreground "magenta")
                             (t :foreground "dark blue"))
   "Face for minibuffer prompts."
-  :version "21.3"
+  :version "21.4"
   :group 'basic-faces)
 
 (setq minibuffer-prompt-properties
@@ -1915,7 +1941,16 @@ created."
   :group 'basic-faces)
 
 
-(defface italic '((t :slant italic))
+(defface italic
+  '((((supports :slant italic))
+     :slant italic)
+    (((supports :underline t))
+     :underline t)
+    (t
+     ;; default to italic, even it doesn't appear to be supported,
+     ;; because in some cases the display engine will do it's own
+     ;; workaround (to `dim' on ttys)
+     :slant italic))
   "Basic italic font."
   :group 'basic-faces)