diff options
| author | Richard M. Stallman | 1995-03-30 07:15:37 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 1995-03-30 07:15:37 +0000 |
| commit | 6ffb01c433ca90b07eae72db8570d77604faa254 (patch) | |
| tree | 0b1147c105a93443b1b06d664a080eabc5f5a668 | |
| parent | ad63249242d2480fff71cbcb880441695e4a46e9 (diff) | |
| download | emacs-6ffb01c433ca90b07eae72db8570d77604faa254.tar.gz emacs-6ffb01c433ca90b07eae72db8570d77604faa254.zip | |
(modify-face): Handle stipple. Handle defaulting properly.
Speed up making completion alists.
(modify-face-read-string): New subroutine.
| -rw-r--r-- | lisp/faces.el | 56 |
1 files changed, 37 insertions, 19 deletions
diff --git a/lisp/faces.el b/lisp/faces.el index 75b12fb03ec..af7b785157a 100644 --- a/lisp/faces.el +++ b/lisp/faces.el | |||
| @@ -162,40 +162,58 @@ in that frame; otherwise change each frame." | |||
| 162 | (interactive (internal-face-interactive "underline-p" "underlined")) | 162 | (interactive (internal-face-interactive "underline-p" "underlined")) |
| 163 | (internal-set-face-1 face 'underline underline-p 7 frame)) | 163 | (internal-set-face-1 face 'underline underline-p 7 frame)) |
| 164 | 164 | ||
| 165 | (defun modify-face (face foreground background bold-p italic-p underline-p) | 165 | (defun modify-face-read-string (default name alist) |
| 166 | (let ((value | ||
| 167 | (completing-read | ||
| 168 | (if default | ||
| 169 | (format "Set face %s %s (default %s): " | ||
| 170 | face name (downcase default)) | ||
| 171 | (format "Set face %s %s: " face name)) | ||
| 172 | alist))) | ||
| 173 | (cond ((equal value "none") | ||
| 174 | nil) | ||
| 175 | ((equal value "") | ||
| 176 | default) | ||
| 177 | (t value)))) | ||
| 178 | |||
| 179 | (defun modify-face (face foreground background stipple | ||
| 180 | bold-p italic-p underline-p) | ||
| 166 | "Change the display attributes for face FACE. | 181 | "Change the display attributes for face FACE. |
| 167 | FOREGROUND and BACKGROUND should be color strings. (Default color if nil.) | 182 | FOREGROUND and BACKGROUND should be color strings or nil. |
| 183 | STIPPLE should be a stipple pattern name or nil. | ||
| 168 | BOLD-P, ITALIC-P, and UNDERLINE-P specify whether the face should be set bold, | 184 | BOLD-P, ITALIC-P, and UNDERLINE-P specify whether the face should be set bold, |
| 169 | in italic, and underlined, respectively. (Yes if non-nil.) | 185 | in italic, and underlined, respectively. (Yes if non-nil.) |
| 170 | If called interactively, prompts for a face and face attributes." | 186 | If called interactively, prompts for a face and face attributes." |
| 171 | (interactive | 187 | (interactive |
| 172 | (let* ((completion-ignore-case t) | 188 | (let* ((completion-ignore-case t) |
| 173 | (face (symbol-name (read-face-name "Face: "))) | 189 | (face (symbol-name (read-face-name "Modify face: "))) |
| 174 | (foreground (completing-read | 190 | (colors (mapcar 'list x-colors)) |
| 175 | (format "Face %s set foreground (default %s): " face | 191 | (stipples (mapcar 'list |
| 176 | (downcase (or (face-foreground (intern face)) | 192 | (apply 'nconc |
| 177 | "foreground"))) | 193 | (mapcar 'directory-files |
| 178 | (mapcar 'list (x-defined-colors)))) | 194 | x-bitmap-file-path)))) |
| 179 | (background (completing-read | 195 | (foreground (modify-face-read-string (face-foreground (intern face)) |
| 180 | (format "Face %s set background (default %s): " face | 196 | "foreground" colors)) |
| 181 | (downcase (or (face-background (intern face)) | 197 | (background (modify-face-read-string (face-background (intern face)) |
| 182 | "background"))) | 198 | "background" colors)) |
| 183 | (mapcar 'list (x-defined-colors)))) | 199 | (stipple (modify-face-read-string (face-stipple (intern face)) |
| 184 | (bold-p (y-or-n-p (concat "Face " face ": set bold "))) | 200 | "stipple" stipples)) |
| 185 | (italic-p (y-or-n-p (concat "Face " face ": set italic "))) | 201 | (bold-p (y-or-n-p (concat "Set face " face " bold "))) |
| 186 | (underline-p (y-or-n-p (concat "Face " face ": set underline ")))) | 202 | (italic-p (y-or-n-p (concat "Set face " face " italic "))) |
| 187 | (if (string-equal background "") (setq background nil)) | 203 | (underline-p (y-or-n-p (concat "Set face " face " underline ")))) |
| 188 | (if (string-equal foreground "") (setq foreground nil)) | ||
| 189 | (message "Face %s: %s" face | 204 | (message "Face %s: %s" face |
| 190 | (mapconcat 'identity | 205 | (mapconcat 'identity |
| 191 | (delq nil | 206 | (delq nil |
| 192 | (list (and foreground (concat (downcase foreground) " foreground")) | 207 | (list (and foreground (concat (downcase foreground) " foreground")) |
| 193 | (and background (concat (downcase background) " background")) | 208 | (and background (concat (downcase background) " background")) |
| 209 | (and stipple (concat (downcase stipple) " stipple")) | ||
| 194 | (and bold-p "bold") (and italic-p "italic") | 210 | (and bold-p "bold") (and italic-p "italic") |
| 195 | (and underline-p "underline"))) ", ")) | 211 | (and underline-p "underline"))) ", ")) |
| 196 | (list (intern face) foreground background bold-p italic-p underline-p))) | 212 | (list (intern face) foreground background stipple |
| 213 | bold-p italic-p underline-p))) | ||
| 197 | (condition-case nil (set-face-foreground face foreground) (error nil)) | 214 | (condition-case nil (set-face-foreground face foreground) (error nil)) |
| 198 | (condition-case nil (set-face-background face background) (error nil)) | 215 | (condition-case nil (set-face-background face background) (error nil)) |
| 216 | (condition-case nil (set-face-stipple face stipple) (error nil)) | ||
| 199 | (funcall (if bold-p 'make-face-bold 'make-face-unbold) face nil t) | 217 | (funcall (if bold-p 'make-face-bold 'make-face-unbold) face nil t) |
| 200 | (funcall (if italic-p 'make-face-italic 'make-face-unitalic) face nil t) | 218 | (funcall (if italic-p 'make-face-italic 'make-face-unitalic) face nil t) |
| 201 | (set-face-underline-p face underline-p) | 219 | (set-face-underline-p face underline-p) |