changeset 9197:3fe469325a8b

(modify-face): New function.
author Richard M. Stallman <rms@gnu.org>
date Fri, 30 Sep 1994 21:01:13 +0000
parents e537b2e10006
children af7bd3312376
files lisp/faces.el
diffstat 1 files changed, 39 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/faces.el	Fri Sep 30 20:47:37 1994 +0000
+++ b/lisp/faces.el	Fri Sep 30 21:01:13 1994 +0000
@@ -128,7 +128,45 @@
 in that frame; otherwise change each frame."
   (interactive (internal-face-interactive "underline-p" "underlined"))
   (internal-set-face-1 face 'underline underline-p 7 frame))
-
+
+(defun modify-face (face foreground background bold-p italic-p underline-p)
+  "Change the display attributes for face FACE.
+FOREGROUND and BACKGROUND should be color strings.  (Default color if 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))
+     (message "Face %s: %s" face
+      (mapconcat 'identity
+       (delq nil
+	(list (and foreground (concat (downcase foreground) " foreground"))
+	      (and background (concat (downcase background) " background"))
+	      (and bold-p "bold") (and italic-p "italic")
+	      (and underline-p "underline"))) ", "))
+     (list (intern face) foreground background 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))
+  (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)
+  (and (interactive-p) (redraw-display)))
 
 ;;;; Associating face names (symbols) with their face vectors.