]> code.delx.au - gnu-emacs/blobdiff - lisp/faces.el
Update copyright.
[gnu-emacs] / lisp / faces.el
index 75b12fb03ec6b08e51ebf842193bf579e93fa3e0..e3a1acdb8f0baf8afb60c47732d81bb509cd44fb 100644 (file)
@@ -1,6 +1,6 @@
 ;;; faces.el --- Lisp interface to the c "face" structure
 
-;; Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
+;; Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
 
 ;; This file is part of GNU Emacs.
 
@@ -162,40 +162,61 @@ in that frame; otherwise change each frame."
   (interactive (internal-face-interactive "underline-p" "underlined"))
   (internal-set-face-1 face 'underline underline-p 7 frame))
 \f
-(defun modify-face (face foreground background bold-p italic-p underline-p)
+(defun modify-face-read-string (face default name alist)
+  (let ((value
+        (completing-read
+         (if default
+             (format "Set face %s %s (default %s): "
+                     face name (downcase default))
+           (format "Set face %s %s: " face name))
+         alist)))
+    (cond ((equal value "none")
+          nil)
+         ((equal value "")
+          default)
+         (t value))))
+
+(defun modify-face (face foreground background stipple
+                        bold-p italic-p underline-p)
   "Change the display attributes for face FACE.
-FOREGROUND and BACKGROUND should be color strings.  (Default color if nil.)
+FOREGROUND and BACKGROUND should be color strings or nil.
+STIPPLE should be a stipple pattern name or nil.
 BOLD-P, ITALIC-P, and UNDERLINE-P specify whether the face should be set bold,
 in italic, and underlined, respectively.  (Yes if non-nil.)
 If called interactively, prompts for a face and face attributes."
   (interactive
    (let* ((completion-ignore-case t)
-         (face         (symbol-name (read-face-name "Face: ")))
-         (foreground   (completing-read
-                        (format "Face %s set foreground (default %s): " face
-                                (downcase (or (face-foreground (intern face))
-                                              "foreground")))
-                        (mapcar 'list (x-defined-colors))))
-         (background   (completing-read
-                        (format "Face %s set background (default %s): " face
-                                (downcase (or (face-background (intern face))
-                                              "background")))
-                        (mapcar 'list (x-defined-colors))))
-         (bold-p       (y-or-n-p (concat "Face " face ": set bold ")))
-         (italic-p     (y-or-n-p (concat "Face " face ": set italic ")))
-         (underline-p  (y-or-n-p (concat "Face " face ": set underline "))))
-     (if (string-equal background "") (setq background nil))
-     (if (string-equal foreground "") (setq foreground nil))
+         (face        (symbol-name (read-face-name "Modify face: ")))
+         (colors      (mapcar 'list x-colors))
+         (stipples    (mapcar 'list
+                              (apply 'nconc
+                                     (mapcar 'directory-files
+                                             x-bitmap-file-path))))
+         (foreground  (modify-face-read-string
+                       face (face-foreground (intern face))
+                       "foreground" colors))
+         (background  (modify-face-read-string
+                       face (face-background (intern face))
+                       "background" colors))
+         (stipple     (modify-face-read-string
+                       face (face-stipple (intern face))
+                       "stipple" stipples))
+         (bold-p      (y-or-n-p (concat "Set face " face " bold ")))
+         (italic-p    (y-or-n-p (concat "Set face " face " italic ")))
+         (underline-p (y-or-n-p (concat "Set face " face " underline "))))
      (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 stipple) " stipple"))
              (and bold-p "bold") (and italic-p "italic")
              (and underline-p "underline"))) ", "))
-     (list (intern face) foreground background bold-p italic-p underline-p)))
+     (list (intern face) foreground background stipple
+          bold-p italic-p underline-p)))
   (condition-case nil (set-face-foreground face foreground) (error nil))
   (condition-case nil (set-face-background face background) (error nil))
+  (condition-case nil (set-face-stipple face stipple) (error nil))
   (funcall (if bold-p 'make-face-bold 'make-face-unbold) face nil t)
   (funcall (if italic-p 'make-face-italic 'make-face-unitalic) face nil t)
   (set-face-underline-p face underline-p)