diff options
| author | Gerd Moellmann | 1999-07-21 21:43:03 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 1999-07-21 21:43:03 +0000 |
| commit | da0b1f5650408f45d6404e92dfd753bdbf447be6 (patch) | |
| tree | 6a02e3f898b8de8a16c882ecdea7c2a75648a6e0 | |
| parent | f3bbef8728240757ec66bf67bca862aeffa218ef (diff) | |
| download | emacs-da0b1f5650408f45d6404e92dfd753bdbf447be6.tar.gz emacs-da0b1f5650408f45d6404e92dfd753bdbf447be6.zip | |
Ditto.
(custom-face-attributes): Add overline, strike-through, box.
(custom-face-attributes): Use `choice' everywhere so that "*"
can be entered.
(custom-face-attributes): Don't use `#''.
(custom-face-attributes): Accept color name.
(custom-facep): Always define as alias for facep.
(custom-face-attributes): Use choice widgets. Remove
:bold and :italic.
(custom-face-attributes): Add :bold and :italic
for compatibility with old code.
(custom-face-attributes): Use new face attributes.
(custom-declare-face): Don't make frame-local faces.
(global): Face relief added.
| -rw-r--r-- | lisp/cus-face.el | 302 |
1 files changed, 246 insertions, 56 deletions
diff --git a/lisp/cus-face.el b/lisp/cus-face.el index b94ebbd033b..4137161de0c 100644 --- a/lisp/cus-face.el +++ b/lisp/cus-face.el | |||
| @@ -30,9 +30,7 @@ | |||
| 30 | 30 | ||
| 31 | ;;; Code: | 31 | ;;; Code: |
| 32 | 32 | ||
| 33 | (defalias 'custom-facep | 33 | (defalias 'custom-facep 'facep) |
| 34 | (if (fboundp 'facep) 'facep | ||
| 35 | '(lambda (face) nil))) | ||
| 36 | 34 | ||
| 37 | ;;; Declaring a face. | 35 | ;;; Declaring a face. |
| 38 | 36 | ||
| @@ -63,48 +61,243 @@ | |||
| 63 | (run-hooks 'custom-define-hook)) | 61 | (run-hooks 'custom-define-hook)) |
| 64 | face) | 62 | face) |
| 65 | 63 | ||
| 66 | ;;; Font Attributes. | 64 | ;;; Face attributes. |
| 65 | |||
| 66 | ;; Below, nil is used in widget specifications for `unspecified' face | ||
| 67 | ;; attributes and `off' is used instead of nil attribute values. The | ||
| 68 | ;; reason for this is that nil corresponds to the result you get when | ||
| 69 | ;; looking up an attribute in a defface spec that isn't contained in | ||
| 70 | ;; the spec. | ||
| 67 | 71 | ||
| 68 | (defconst custom-face-attributes | 72 | (defconst custom-face-attributes |
| 69 | '((:bold (boolean :tag "Bold" | 73 | '((:family |
| 70 | :help-echo "Control whether a bold font should be used.") | 74 | (choice :tag "Font family" |
| 71 | set-face-bold-p | 75 | :help-echo "Font family or fontset alias name." |
| 72 | face-bold-p) | 76 | (const :tag "*" nil) |
| 73 | (:italic (boolean :tag "Italic" | 77 | (string :tag "Family")) |
| 74 | :help-echo "\ | 78 | (lambda (face value &optional frame) |
| 75 | Control whether an italic font should be used.") | 79 | (set-face-attribute face frame :family (or value 'unspecified))) |
| 76 | set-face-italic-p | 80 | (lambda (face &optional frame) |
| 77 | face-italic-p) | 81 | (let ((family (face-attribute face :family frame))) |
| 78 | (:underline (boolean :tag "Underline" | 82 | (if (eq family 'unspecified) nil family)))) |
| 79 | :help-echo "\ | 83 | |
| 80 | Control whether the text should be underlined.") | 84 | (:width |
| 81 | set-face-underline-p | 85 | (choice :tag "Width" |
| 82 | face-underline-p) | 86 | :help-echo "Font width." |
| 83 | (:inverse-video (boolean :tag "Inverse Video" | 87 | (const :tag "*" nil) |
| 84 | :help-echo "\ | 88 | (const :tag "compressed" condensed) |
| 85 | Control whether the text should be in inverse video.") | 89 | (const :tag "condensed" condensed) |
| 86 | set-face-inverse-video-p | 90 | (const :tag "demiexpanded" semi-expanded) |
| 87 | face-inverse-video-p) | 91 | (const :tag "expanded" expanded) |
| 88 | (:foreground (color :tag "Foreground" | 92 | (const :tag "extracondensed" extra-condensed) |
| 89 | :value "" | 93 | (const :tag "extraexpanded" extra-expanded) |
| 90 | :help-echo "Set foreground color.") | 94 | (const :tag "medium" normal) |
| 91 | set-face-foreground | 95 | (const :tag "narrow" condensed) |
| 92 | face-foreground) | 96 | (const :tag "normal" normal) |
| 93 | (:background (color :tag "Background" | 97 | (const :tag "regular" normal) |
| 94 | :value "" | 98 | (const :tag "semicondensed" semi-condensed) |
| 95 | :help-echo "Set background color.") | 99 | (const :tag "semiexpanded" semi-expanded) |
| 96 | set-face-background | 100 | (const :tag "ultracondensed" ultra-condensed) |
| 97 | face-background) | 101 | (const :tag "ultraexpanded" ultra-expanded) |
| 98 | (:stipple (editable-field :format "Stipple: %v" | 102 | (const :tag "wide" extra-expanded)) |
| 99 | :help-echo "Name of background bitmap file.") | 103 | (lambda (face value &optional frame) |
| 100 | set-face-stipple | 104 | (set-face-attribute face frame :width (or value 'unspecified))) |
| 101 | face-stipple)) | 105 | (lambda (face &optional frame) |
| 102 | "Alist of face attributes. | 106 | (let ((width (face-attribute face :width frame))) |
| 103 | The elements are of the form (KEY TYPE SET GET), | 107 | (if (eq width 'unspecified) nil width)))) |
| 104 | where KEY is the name of the attribute, | 108 | |
| 105 | TYPE is a widget type for editing the attribute, | 109 | (:height |
| 106 | SET is a function for setting the attribute value, | 110 | (choice :tag "Height" |
| 107 | and GET is a function for getiing the attribute value. | 111 | :help-echo "Face's font height." |
| 112 | (const :tag "*" nil) | ||
| 113 | (integer :tag "Height in 1/10 pt")) | ||
| 114 | (lambda (face value &optional frame) | ||
| 115 | (set-face-attribute face frame :height (or value 'unspecified))) | ||
| 116 | (lambda (face &optional frame) | ||
| 117 | (let ((height (face-attribute face :height frame))) | ||
| 118 | (if (eq height 'unspecified) nil height)))) | ||
| 119 | |||
| 120 | (:weight | ||
| 121 | (choice :tag "Weight" | ||
| 122 | :help-echo "Font weight." | ||
| 123 | (const :tag "*" nil) | ||
| 124 | (const :tag "black" ultra_bold) | ||
| 125 | (const :tag "bold" bold) | ||
| 126 | (const :tag "book" semi-light) | ||
| 127 | (const :tag "demibold" semi-bold) | ||
| 128 | (const :tag "extralight" extra-light) | ||
| 129 | (const :tag "extrabold" extra-bold) | ||
| 130 | (const :tag "heavy" extra-bold) | ||
| 131 | (const :tag "light" light) | ||
| 132 | (const :tag "medium" normal) | ||
| 133 | (const :tag "normal" normal) | ||
| 134 | (const :tag "regular" normal) | ||
| 135 | (const :tag "semibold" semi-bold) | ||
| 136 | (const :tag "semilight" semi-light) | ||
| 137 | (const :tag "ultralight" ultra-light) | ||
| 138 | (const :tag "ultrabold" ultra-bold)) | ||
| 139 | (lambda (face value &optional frame) | ||
| 140 | (set-face-attribute face frame :weight (or value 'unspecified))) | ||
| 141 | (lambda (face &optional frame) | ||
| 142 | (let ((weight (face-attribute face :weight frame))) | ||
| 143 | (if (eq weight 'unspecified) nil weight)))) | ||
| 144 | |||
| 145 | (:slant | ||
| 146 | (choice :tag "Slant" | ||
| 147 | :help-echo "Font slant." | ||
| 148 | (const :tag "*" nil) | ||
| 149 | (const :tag "italic" italic) | ||
| 150 | (const :tag "oblique" oblique) | ||
| 151 | (const :tag "normal" normal)) | ||
| 152 | (lambda (face value &optional frame) | ||
| 153 | (set-face-attribute face frame :slant (or value 'unspecified))) | ||
| 154 | (lambda (face &optional frame) | ||
| 155 | (let ((slant (face-attribute face :slant frame))) | ||
| 156 | (if (eq slant 'unspecified) nil slant)))) | ||
| 157 | |||
| 158 | (:underline | ||
| 159 | (choice :tag "Underline" | ||
| 160 | :help-echo "Control text underlining." | ||
| 161 | (const :tag "*" nil) | ||
| 162 | (const :tag "On" t) | ||
| 163 | (const :tag "Off" off) | ||
| 164 | (color :tag "Colored")) | ||
| 165 | (lambda (face value &optional frame) | ||
| 166 | (cond ((eq value 'off) (setq value nil)) | ||
| 167 | ((null value) (setq value 'unspecified))) | ||
| 168 | (set-face-attribute face frame :underline value)) | ||
| 169 | (lambda (face &optional frame) | ||
| 170 | (let ((underline (face-attribute face :underline frame))) | ||
| 171 | (cond ((eq underline 'unspecified) (setq underline nil)) | ||
| 172 | ((null underline) (setq underline 'off))) | ||
| 173 | underline))) | ||
| 174 | |||
| 175 | (:overline | ||
| 176 | (choice :tag "Overline" | ||
| 177 | :help-echo "Control text overlining." | ||
| 178 | (const :tag "*" nil) | ||
| 179 | (const :tag "On" t) | ||
| 180 | (const :tag "Off" off) | ||
| 181 | (color :tag "Colored")) | ||
| 182 | (lambda (face value &optional frame) | ||
| 183 | (cond ((eq value 'off) (setq value nil)) | ||
| 184 | ((null value) (setq value 'unspecified))) | ||
| 185 | (set-face-attribute face frame :overline value)) | ||
| 186 | (lambda (face &optional frame) | ||
| 187 | (let ((overline (face-attribute face :overline frame))) | ||
| 188 | (cond ((eq overline 'unspecified) (setq overline nil)) | ||
| 189 | ((null overline) (setq overline 'off))) | ||
| 190 | overline))) | ||
| 191 | |||
| 192 | (:strike-through | ||
| 193 | (choice :tag "Strike-through" | ||
| 194 | :help-echo "Control text strike-through." | ||
| 195 | (const :tag "*" nil) | ||
| 196 | (const :tag "On" t) | ||
| 197 | (const :tag "Off" off) | ||
| 198 | (color :tag "Colored")) | ||
| 199 | (lambda (face value &optional frame) | ||
| 200 | (cond ((eq value 'off) (setq value nil)) | ||
| 201 | ((null value) (setq value 'unspecified))) | ||
| 202 | (set-face-attribute face frame :strike-through value)) | ||
| 203 | (lambda (face &optional frame) | ||
| 204 | (let ((value (face-attribute face :strike-through frame))) | ||
| 205 | (cond ((eq value 'unspecified) (setq value nil)) | ||
| 206 | ((null value) (setq value 'off))) | ||
| 207 | value))) | ||
| 208 | |||
| 209 | (:box | ||
| 210 | (choice :tag "Box around text" | ||
| 211 | :help-echo "Control box around text." | ||
| 212 | (const :tag "*" nil) | ||
| 213 | (const :tag "Off" off) | ||
| 214 | (list :tag "Box" | ||
| 215 | :value (1 "black" nil) | ||
| 216 | (integer :tag "Width") | ||
| 217 | (color :tag "Color") | ||
| 218 | (choice :tag "Shadows" | ||
| 219 | (const :tag "None" nil) | ||
| 220 | (const :tag "Raised" raised) | ||
| 221 | (const :tag "Sunken" sunken)))) | ||
| 222 | (lambda (face value &optional frame) | ||
| 223 | (cond ((consp value) | ||
| 224 | (let ((width (nth 0 value)) | ||
| 225 | (color (nth 1 value)) | ||
| 226 | (shadow (nth 2 value))) | ||
| 227 | (setq value (list :width width :color color :shadow shadow)))) | ||
| 228 | ((eq value 'off) | ||
| 229 | (setq value nil)) | ||
| 230 | ((null value) | ||
| 231 | (setq value 'unspecified))) | ||
| 232 | (set-face-attribute face frame :box value)) | ||
| 233 | (lambda (face &optional frame) | ||
| 234 | (let ((value (face-attribute face :box frame))) | ||
| 235 | (cond ((consp value) | ||
| 236 | (let ((width (plist-get value :width)) | ||
| 237 | (color (plist-get value :color)) | ||
| 238 | (shadow (plist-get value :shadow))) | ||
| 239 | (setq value (list width color shadow)))) | ||
| 240 | ((eq value 'unspecified) | ||
| 241 | (setq value nil)) | ||
| 242 | ((null value) | ||
| 243 | (setq value 'off))) | ||
| 244 | value))) | ||
| 245 | |||
| 246 | (:inverse-video | ||
| 247 | (choice :tag "Inverse-video" | ||
| 248 | :help-echo "Control whether text should be in inverse-video." | ||
| 249 | (const :tag "*" nil) | ||
| 250 | (const :tag "On" t) | ||
| 251 | (const :tag "Off" off)) | ||
| 252 | (lambda (face value &optional frame) | ||
| 253 | (cond ((eq value 'off) (setq value nil)) | ||
| 254 | ((null value) (setq value 'unspecified))) | ||
| 255 | (set-face-attribute face frame :inverse-video value)) | ||
| 256 | (lambda (face &optional frame) | ||
| 257 | (let ((value (face-attribute face :inverse-video frame))) | ||
| 258 | (cond ((eq value 'unspecified) (setq value nil)) | ||
| 259 | ((null value) (setq value 'off))) | ||
| 260 | value))) | ||
| 261 | |||
| 262 | (:foreground | ||
| 263 | (choice :tag "Foreground" | ||
| 264 | :help-echo "Set foreground color." | ||
| 265 | (const :tag "*" nil) | ||
| 266 | (color :tag "Color")) | ||
| 267 | (lambda (face value &optional frame) | ||
| 268 | (set-face-attribute face frame :foreground (or value 'unspecified))) | ||
| 269 | (lambda (face &optional frame) | ||
| 270 | (let ((value (face-attribute face :foreground frame))) | ||
| 271 | (if (eq value 'unspecified) nil value)))) | ||
| 272 | |||
| 273 | (:background | ||
| 274 | (choice :tag "Background" | ||
| 275 | :help-echo "Set background color." | ||
| 276 | (const :tag "*" nil) | ||
| 277 | (color :tag "Color")) | ||
| 278 | (lambda (face value &optional frame) | ||
| 279 | (set-face-attribute face frame :background (or value 'unspecified))) | ||
| 280 | (lambda (face &optional frame) | ||
| 281 | (let ((value (face-attribute face :background frame))) | ||
| 282 | (if (eq value 'unspecified) nil value)))) | ||
| 283 | |||
| 284 | (:stipple | ||
| 285 | (choice :tag "Stipple" | ||
| 286 | :help-echo "Name of background bitmap file." | ||
| 287 | (const :tag "*" nil) | ||
| 288 | (file :tag "File" :must-match t)) | ||
| 289 | (lambda (face value &optional frame) | ||
| 290 | (set-face-attribute face frame :stipple (or value 'unspecified))) | ||
| 291 | (lambda (face &optional frame) | ||
| 292 | (let ((value (face-attribute face :stipple frame))) | ||
| 293 | (if (eq value 'unspecified) nil value))))) | ||
| 294 | |||
| 295 | "Alist of face attributes. | ||
| 296 | |||
| 297 | The elements are of the form (KEY TYPE SET GET), where KEY is the name | ||
| 298 | of the attribute, TYPE is a widget type for editing the attibute, SET | ||
| 299 | is a function for setting the attribute value, and GET is a function | ||
| 300 | for getiing the attribute value. | ||
| 108 | 301 | ||
| 109 | The SET function should take three arguments, the face to modify, the | 302 | The SET function should take three arguments, the face to modify, the |
| 110 | value of the attribute, and optionally the frame where the face should | 303 | value of the attribute, and optionally the frame where the face should |
| @@ -113,25 +306,22 @@ be changed. | |||
| 113 | The GET function should take two arguments, the face to examine, and | 306 | The GET function should take two arguments, the face to examine, and |
| 114 | optionally the frame where the face should be examined.") | 307 | optionally the frame where the face should be examined.") |
| 115 | 308 | ||
| 309 | |||
| 116 | (defun custom-face-attributes-get (face frame) | 310 | (defun custom-face-attributes-get (face frame) |
| 117 | "For FACE on FRAME, return an alternating list describing its attributes. | 311 | "For FACE on FRAME, return an alternating list describing its attributes. |
| 118 | The list has the form (KEYWORD VALUE KEYWORD VALUE...). | 312 | The list has the form (KEYWORD VALUE KEYWORD VALUE...). |
| 119 | Each keyword should be listed in `custom-face-attributes'. | 313 | Each keyword should be listed in `custom-face-attributes'. |
| 120 | We include only those attributes that differ from the default face. | ||
| 121 | 314 | ||
| 122 | If FRAME is nil, use the global defaults for FACE." | 315 | If FRAME is nil, use the global defaults for FACE." |
| 123 | (let ((atts custom-face-attributes) | 316 | (let ((attrs custom-face-attributes) |
| 124 | att result get) | 317 | plist) |
| 125 | (while atts | 318 | (while attrs |
| 126 | (setq att (car atts) | 319 | (let* ((attribute (car (car attrs))) |
| 127 | atts (cdr atts) | 320 | (value (face-attribute face attribute frame))) |
| 128 | get (nth 3 att)) | 321 | (setq attrs (cdr attrs)) |
| 129 | (when get | 322 | (unless (eq value 'unspecified) |
| 130 | (let ((answer (funcall get face frame))) | 323 | (setq plist (cons attribute (cons value plist)))))) |
| 131 | (if (and (not (equal answer (funcall get 'default frame))) | 324 | plist)) |
| 132 | (widget-apply (nth 1 att) :match answer)) | ||
| 133 | (setq result (cons (nth 0 att) (cons answer result))))))) | ||
| 134 | result)) | ||
| 135 | 325 | ||
| 136 | ;;; Initializing. | 326 | ;;; Initializing. |
| 137 | 327 | ||