comparison lisp/faces.el @ 9197:3fe469325a8b

(modify-face): New function.
author Richard M. Stallman <rms@gnu.org>
date Fri, 30 Sep 1994 21:01:13 +0000
parents c3a04b8a2786
children 943acba6d366
comparison
equal deleted inserted replaced
9196:e537b2e10006 9197:3fe469325a8b
126 "Specify whether face FACE is underlined. (Yes if UNDERLINE-P is non-nil.) 126 "Specify whether face FACE is underlined. (Yes if UNDERLINE-P is non-nil.)
127 If the optional FRAME argument is provided, change only 127 If the optional FRAME argument is provided, change only
128 in that frame; otherwise change each frame." 128 in that frame; otherwise change each frame."
129 (interactive (internal-face-interactive "underline-p" "underlined")) 129 (interactive (internal-face-interactive "underline-p" "underlined"))
130 (internal-set-face-1 face 'underline underline-p 7 frame)) 130 (internal-set-face-1 face 'underline underline-p 7 frame))
131 131
132 (defun modify-face (face foreground background bold-p italic-p underline-p)
133 "Change the display attributes for face FACE.
134 FOREGROUND and BACKGROUND should be color strings. (Default color if nil.)
135 BOLD-P, ITALIC-P, and UNDERLINE-P specify whether the face should be set bold,
136 in italic, and underlined, respectively. (Yes if non-nil.)
137 If called interactively, prompts for a face and face attributes."
138 (interactive
139 (let* ((completion-ignore-case t)
140 (face (symbol-name (read-face-name "Face: ")))
141 (foreground (completing-read
142 (format "Face %s set foreground (default %s): " face
143 (downcase (or (face-foreground (intern face))
144 "foreground")))
145 (mapcar 'list (x-defined-colors))))
146 (background (completing-read
147 (format "Face %s set background (default %s): " face
148 (downcase (or (face-background (intern face))
149 "background")))
150 (mapcar 'list (x-defined-colors))))
151 (bold-p (y-or-n-p (concat "Face " face ": set bold ")))
152 (italic-p (y-or-n-p (concat "Face " face ": set italic ")))
153 (underline-p (y-or-n-p (concat "Face " face ": set underline "))))
154 (if (string-equal background "") (setq background nil))
155 (if (string-equal foreground "") (setq foreground nil))
156 (message "Face %s: %s" face
157 (mapconcat 'identity
158 (delq nil
159 (list (and foreground (concat (downcase foreground) " foreground"))
160 (and background (concat (downcase background) " background"))
161 (and bold-p "bold") (and italic-p "italic")
162 (and underline-p "underline"))) ", "))
163 (list (intern face) foreground background bold-p italic-p underline-p)))
164 (condition-case nil (set-face-foreground face foreground) (error nil))
165 (condition-case nil (set-face-background face background) (error nil))
166 (funcall (if bold-p 'make-face-bold 'make-face-unbold) face nil t)
167 (funcall (if italic-p 'make-face-italic 'make-face-unitalic) face nil t)
168 (set-face-underline-p face underline-p)
169 (and (interactive-p) (redraw-display)))
132 170
133 ;;;; Associating face names (symbols) with their face vectors. 171 ;;;; Associating face names (symbols) with their face vectors.
134 172
135 (defvar global-face-data nil 173 (defvar global-face-data nil
136 "Internal data for face support functions. Not for external use. 174 "Internal data for face support functions. Not for external use.