]> code.delx.au - gnu-emacs/blobdiff - lisp/faces.el
(tar-header-block-tokenize): Decode codes of file
[gnu-emacs] / lisp / faces.el
index 5ad00c71cd39b3f811b2785e1d73ed6cceb8d8cc..24abd40a06cfc312fcdf1101384eba7d05ac8845 100644 (file)
@@ -149,7 +149,7 @@ If the optional FRAME argument is provided, change only
 in that frame; otherwise change each frame."
   (interactive (internal-face-interactive "font"))
   (if (stringp font)
-      (setq font (or (query-fontset font)
+      (setq font (or (resolve-fontset-name font)
                     (x-resolve-font-name font 'default frame))))
   (internal-set-face-1 face 'font font 3 frame)
   ;; Record that this face's font was set explicitly, not automatically,
@@ -164,9 +164,7 @@ If the optional FRAME argument is provided, change only
 in that frame; otherwise change each frame."
   (interactive (internal-face-interactive "font"))
   (if (stringp font)
-      (setq font (or (and (fontset-name-p font)
-                         (or (query-fontset font)
-                             (instantiate-fontset font)))
+      (setq font (or (resolve-fontset-name font)
                     (x-resolve-font-name font 'default frame))))
   (internal-set-face-1 face 'font font 3 frame))
 
@@ -283,7 +281,7 @@ in that frame; otherwise change each frame."
            (format "Set face %s %s: " face name))
          alist)))
     (cond ((equal value "none")
-          nil)
+          '(nil))
          ((equal value "")
           default)
          (t value))))
@@ -297,6 +295,7 @@ in that frame; otherwise change each frame.
 FOREGROUND and BACKGROUND should be a colour name string (or list of strings to
 try) or nil.  STIPPLE should be a stipple pattern name string or nil.
 If nil, means do not change the display attribute corresponding to that arg.
+If (nil), that means clear out the attribute.
 
 BOLD-P, ITALIC-P, UNDERLINE-P, and INVERSE-P specify whether
 the face should be set bold, italic, underlined or in inverse-video,
@@ -345,9 +344,15 @@ If called interactively, prompts for a face name and face attributes."
      (message "Face %s: %s" face
       (mapconcat 'identity
        (delq nil
-       (list (and foreground (concat (downcase foreground) " foreground"))
-             (and background (concat (downcase background) " background"))
-             (and stipple (concat (downcase new-stipple-string) " stipple"))
+       (list (if (equal foreground '(nil))
+                 " no foreground"
+               (and foreground (concat (downcase foreground) " foreground")))
+             (if (equal background '(nil))
+                 " no background"
+               (and background (concat (downcase background) " background")))
+             (if (equal stipple '(nil))
+                 " no stipple"
+               (and stipple (concat (downcase new-stipple-string) " stipple")))
              (and bold-p "bold") (and italic-p "italic")
              (and inverse-p "inverse")
              (and underline-p "underline"))) ", "))
@@ -1138,7 +1143,8 @@ selected frame."
            (while (not (eobp))
              (insert "                          ")
              (forward-line 1))))
-       (goto-char (point-min))))
+       (goto-char (point-min)))
+      (print-help-return-message))
     ;; If the *Faces* buffer appears in a different frame,
     ;; copy all the face definitions from FRAME,
     ;; so that the display will reflect the frame that was selected.
@@ -1168,7 +1174,8 @@ selected frame."
     (let ((doc (face-documentation face)))
       (if doc
          (princ doc)
-       (princ "not documented as a face.")))))
+       (princ "not documented as a face.")))
+    (print-help-return-message)))
 \f
 ;;; Setting a face based on a SPEC.
 
@@ -1345,6 +1352,19 @@ If FRAME is nil, the current FRAME is used."
          ;; Put the geometry parameters at the end.
          ;; Copy default-frame-alist so that they go after it.
          (setq parameters (append parameters default-frame-alist parsed)))))
+
+  (if default-enable-multibyte-characters
+      ;; If an ASCII font is specified in PARAMETERS, we try to create
+      ;; a fontset from it, and use it for the new frame.
+      (condition-case nil
+         (let ((font (cdr (assq 'font parameters))))
+           (if (and font
+                    (not (query-fontset font)))
+               (setq parameters
+                     (cons (cons 'font (create-fontset-from-ascii-font font))
+                           parameters))))
+       (error nil)))
+
   (let (frame)
     (if (null global-face-data)
        (progn
@@ -1432,36 +1452,41 @@ Set this to the symbol dark if your background color is dark, light if
 your background is light, or nil (default) if you want Emacs to
 examine the brightness for you."
   :group 'faces
+  :set #'(lambda (var value)
+          (set var value)
+          (mapcar 'frame-set-background-mode (frame-list)))
+  :initialize 'custom-initialize-changed
   :type '(choice (choice-item dark) 
                 (choice-item light)
                 (choice-item :tag "default" nil)))
 
 (defun frame-set-background-mode (frame)
   "Set up the `background-mode' and `display-type' frame parameters for FRAME."
-  (let ((bg-resource (x-get-resource ".backgroundMode"
-                                    "BackgroundMode"))
-       (params (frame-parameters frame))
-       (bg-mode))
-    (setq bg-mode
-         (cond (frame-background-mode)
-               (bg-resource (intern (downcase bg-resource)))
-               ((< (apply '+ (x-color-values
-                              (cdr (assq 'background-color params))
-                              frame))
-                   ;; Just looking at the screen,
-                   ;; colors whose values add up to .6 of the white total
-                   ;; still look dark to me.
-                   (* (apply '+ (x-color-values "white" frame)) .6))
-                'dark)
-               (t 'light)))
-    (modify-frame-parameters frame
-                            (list (cons 'background-mode bg-mode)
-                                  (cons 'display-type
-                                        (cond ((x-display-color-p frame)
-                                               'color)
-                                              ((x-display-grayscale-p frame)
-                                               'grayscale)
-                                              (t 'mono)))))))
+  (unless (eq (framep frame) t)
+    (let ((bg-resource (x-get-resource ".backgroundMode"
+                                      "BackgroundMode"))
+         (params (frame-parameters frame))
+         (bg-mode))
+      (setq bg-mode
+           (cond (frame-background-mode)
+                 (bg-resource (intern (downcase bg-resource)))
+                 ((< (apply '+ (x-color-values
+                                (cdr (assq 'background-color params))
+                                frame))
+                     ;; Just looking at the screen,
+                     ;; colors whose values add up to .6 of the white total
+                     ;; still look dark to me.
+                     (* (apply '+ (x-color-values "white" frame)) .6))
+                  'dark)
+                 (t 'light)))
+      (modify-frame-parameters frame
+                              (list (cons 'background-mode bg-mode)
+                                    (cons 'display-type
+                                          (cond ((x-display-color-p frame)
+                                                 'color)
+                                                ((x-display-grayscale-p frame)
+                                                 'grayscale)
+                                                (t 'mono))))))))
 
 ;; Update a frame's faces when we change its default font.
 (defun frame-update-faces (frame) nil)
@@ -1470,6 +1495,7 @@ examine the brightness for you."
 ;; This applies only to faces with global color specifications
 ;; that are not simple constants.
 (defun frame-update-face-colors (frame)
+  (frame-set-background-mode frame)
   (let ((faces global-face-data))
     (while faces
       (condition-case nil
@@ -1560,7 +1586,7 @@ examine the brightness for you."
        (set-face-inverse-video-p face t frame)
       (let (done)
        (while (and colors (not done))
-         (if (or (memq (car colors) '(t underline))
+         (if (or (memq (car colors) '(t underline nil))
                  (face-color-supported-p frame (car colors)
                                          (eq function 'set-face-background)))
              (if (cdr colors)
@@ -1604,6 +1630,11 @@ examine the brightness for you."
 
 (setq region-face (face-id 'region))
 
+(defgroup basic-faces nil
+  "The standard faces of Emacs."
+  :prefix "huh"
+  :group 'faces)
+
 ;; Specify how these faces look, and their documentation.
 (let ((all '((bold "Use bold font." ((t (:bold t))))
             (bold-italic "Use bold italic font." ((t (:bold t :italic t))))
@@ -1636,6 +1667,7 @@ examine the brightness for you."
          symbol (nth 0 entry)
          doc (nth 1 entry)
          spec (nth 2 entry))
+    (custom-add-to-group 'basic-faces symbol 'custom-face)
     (put symbol 'face-documentation doc)
     (put symbol 'face-defface-spec spec)))