diff options
| author | Richard M. Stallman | 2002-12-23 18:40:38 +0000 |
|---|---|---|
| committer | Richard M. Stallman | 2002-12-23 18:40:38 +0000 |
| commit | a39979074bd2b2ad36de9ae41222cd2b0e869c6e (patch) | |
| tree | ec1c0d2ae27fa2065bbead76c7df20c779012848 | |
| parent | c942535f88a7cb50e8df6795c7608c8a76df681b (diff) | |
| download | emacs-a39979074bd2b2ad36de9ae41222cd2b0e869c6e.tar.gz emacs-a39979074bd2b2ad36de9ae41222cd2b0e869c6e.zip | |
(custom-set-faces): Call custom-theme-set-faces.
(custom-theme-set-faces): New function.
(custom-theme-face-value): New function.
(custom-theme-reset-internal-face): New function.
(custom-theme-reset-faces): New function.
(custom-reset-faces): New function.
| -rw-r--r-- | lisp/cus-face.el | 133 |
1 files changed, 110 insertions, 23 deletions
diff --git a/lisp/cus-face.el b/lisp/cus-face.el index f6b00ed17b1..4b33f1e4f04 100644 --- a/lisp/cus-face.el +++ b/lisp/cus-face.el | |||
| @@ -1,10 +1,9 @@ | |||
| 1 | ;;; cus-face.el --- customization support for faces | 1 | ;;; cus-face.el --- customization support for faces |
| 2 | ;; | 2 | ;; |
| 3 | ;; Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc. | 3 | ;; Copyright (C) 1996, 1997, 1999, 2000, 2001, 2002 Free Software Foundation, Inc. |
| 4 | ;; | 4 | ;; |
| 5 | ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> | 5 | ;; Author: Per Abrahamsen <abraham@dina.kvl.dk> |
| 6 | ;; Keywords: help, faces | 6 | ;; Keywords: help, faces |
| 7 | ;; Version: Emacs | ||
| 8 | 7 | ||
| 9 | ;; This file is part of GNU Emacs. | 8 | ;; This file is part of GNU Emacs. |
| 10 | 9 | ||
| @@ -67,7 +66,7 @@ | |||
| 67 | '((:family | 66 | '((:family |
| 68 | (string :tag "Font Family" | 67 | (string :tag "Font Family" |
| 69 | :help-echo "Font family or fontset alias name.")) | 68 | :help-echo "Font family or fontset alias name.")) |
| 70 | 69 | ||
| 71 | (:width | 70 | (:width |
| 72 | (choice :tag "Width" | 71 | (choice :tag "Width" |
| 73 | :help-echo "Font width." | 72 | :help-echo "Font width." |
| @@ -249,7 +248,6 @@ The POST-FILTER should also take a single argument, the value after | |||
| 249 | being customized, and should return a value suitable for setting the | 248 | being customized, and should return a value suitable for setting the |
| 250 | given face attribute.") | 249 | given face attribute.") |
| 251 | 250 | ||
| 252 | |||
| 253 | (defun custom-face-attributes-get (face frame) | 251 | (defun custom-face-attributes-get (face frame) |
| 254 | "For FACE on FRAME, return an alternating list describing its attributes. | 252 | "For FACE on FRAME, return an alternating list describing its attributes. |
| 255 | The list has the form (KEYWORD VALUE KEYWORD VALUE...). | 253 | The list has the form (KEYWORD VALUE KEYWORD VALUE...). |
| @@ -272,36 +270,125 @@ If FRAME is nil, use the global defaults for FACE." | |||
| 272 | ;;;###autoload | 270 | ;;;###autoload |
| 273 | (defun custom-set-faces (&rest args) | 271 | (defun custom-set-faces (&rest args) |
| 274 | "Initialize faces according to user preferences. | 272 | "Initialize faces according to user preferences. |
| 273 | This associates the settings with the `user' theme. | ||
| 274 | The arguments should be a list where each entry has the form: | ||
| 275 | |||
| 276 | (FACE SPEC [NOW [COMMENT]]) | ||
| 277 | |||
| 278 | SPEC is stored as the saved value for FACE, as well as the value for the | ||
| 279 | `user' theme. The `user' theme is one of the default themes known to Emacs. | ||
| 280 | See `custom-known-themes' for more information on the known themes. | ||
| 281 | See `custom-theme-set-faces' for more information on the interplay | ||
| 282 | between themes and faces. | ||
| 283 | See `defface' for the format of SPEC. | ||
| 284 | |||
| 285 | If NOW is present and non-nil, FACE is created now, according to SPEC. | ||
| 286 | COMMENT is a string comment about FACE." | ||
| 287 | (apply 'custom-theme-set-faces 'user args)) | ||
| 288 | |||
| 289 | (defun custom-theme-set-faces (theme &rest args) | ||
| 290 | "Initialize faces for theme THEME. | ||
| 275 | The arguments should be a list where each entry has the form: | 291 | The arguments should be a list where each entry has the form: |
| 276 | 292 | ||
| 277 | (FACE SPEC [NOW [COMMENT]]) | 293 | (FACE SPEC [NOW [COMMENT]]) |
| 278 | 294 | ||
| 279 | SPEC is stored as the saved value for FACE. | 295 | SPEC is stored as the saved value for FACE, as well as the value for the |
| 296 | `user' theme. The `user' theme is one of the default themes known to Emacs. | ||
| 297 | See `custom-known-themes' for more information on the known themes. | ||
| 298 | See `custom-theme-set-faces' for more information on the interplay | ||
| 299 | between themes and faces. | ||
| 300 | See `defface' for the format of SPEC. | ||
| 301 | |||
| 280 | If NOW is present and non-nil, FACE is created now, according to SPEC. | 302 | If NOW is present and non-nil, FACE is created now, according to SPEC. |
| 281 | COMMENT is a string comment about FACE. | 303 | COMMENT is a string comment about FACE. |
| 282 | 304 | ||
| 283 | See `defface' for the format of SPEC." | 305 | Several properties of THEME and FACE are used in the process: |
| 284 | (while args | 306 | |
| 285 | (let ((entry (car args))) | 307 | If THEME property `theme-immediate' is non-nil, this is equivalent of |
| 286 | (if (listp entry) | 308 | providing the NOW argument to all faces in the argument list: FACE is |
| 287 | (let ((face (nth 0 entry)) | 309 | created now. The only difference is FACE property `force-face': if NOW |
| 288 | (spec (nth 1 entry)) | 310 | is non-nil, FACE property `force-face' is set to the symbol `rogue', else |
| 289 | (now (nth 2 entry)) | 311 | if THEME property `theme-immediate' is non-nil, FACE property `force-face' |
| 290 | (comment (nth 3 entry))) | 312 | is set to the symbol `immediate'. |
| 291 | (put face 'saved-face spec) | 313 | |
| 292 | (put face 'saved-face-comment comment) | 314 | SPEC itself is saved in FACE property `saved-face' and it is stored in |
| 293 | (when now | 315 | FACE's list property `theme-face' \(using `custom-push-theme')." |
| 294 | (put face 'force-face t)) | 316 | (custom-check-theme theme) |
| 295 | (when (or now (facep face)) | 317 | (let ((immediate (get theme 'theme-immediate))) |
| 296 | (put face 'face-comment comment) | 318 | (while args |
| 297 | (make-empty-face face) | 319 | (let ((entry (car args))) |
| 298 | (face-spec-set face spec)) | 320 | (if (listp entry) |
| 321 | (let ((face (nth 0 entry)) | ||
| 322 | (spec (nth 1 entry)) | ||
| 323 | (now (nth 2 entry)) | ||
| 324 | (comment (nth 3 entry))) | ||
| 325 | (put face 'saved-face spec) | ||
| 326 | (put face 'saved-face-comment comment) | ||
| 327 | (custom-push-theme 'theme-face face theme 'set spec) | ||
| 328 | (when (or now immediate) | ||
| 329 | (put face 'force-face (if now 'rogue 'immediate))) | ||
| 330 | (when (or now immediate (facep face)) | ||
| 331 | (unless (facep face) | ||
| 332 | (make-empty-face face)) | ||
| 333 | (put face 'face-comment comment) | ||
| 334 | (face-spec-set face spec)) | ||
| 299 | (setq args (cdr args))) | 335 | (setq args (cdr args))) |
| 300 | ;; Old format, a plist of FACE SPEC pairs. | 336 | ;; Old format, a plist of FACE SPEC pairs. |
| 301 | (let ((face (nth 0 args)) | 337 | (let ((face (nth 0 args)) |
| 302 | (spec (nth 1 args))) | 338 | (spec (nth 1 args))) |
| 303 | (put face 'saved-face spec)) | 339 | (put face 'saved-face spec) |
| 304 | (setq args (cdr (cdr args))))))) | 340 | (custom-push-theme 'theme-face face theme 'set spec)) |
| 341 | (setq args (cdr (cdr args)))))))) | ||
| 342 | |||
| 343 | ;;;###autoload | ||
| 344 | (defun custom-theme-face-value (face theme) | ||
| 345 | "Return spec of FACE in THEME if THEME modifies FACE. | ||
| 346 | Value is nil otherwise. The association between theme and spec for FACE | ||
| 347 | is stored in FACE's property `theme-face'. The appropriate face | ||
| 348 | is retrieved using `custom-theme-value'." | ||
| 349 | ;; Returns car because the value is stored inside a one element list | ||
| 350 | (car-safe (custom-theme-value theme (get face 'theme-face)))) | ||
| 351 | |||
| 352 | (defun custom-theme-reset-internal-face (face to-theme) | ||
| 353 | "Reset FACE to the value defined by TO-THEME. | ||
| 354 | If FACE is not defined in TO-THEME, reset FACE to the standard | ||
| 355 | value. See `custom-theme-face-value'. The standard value is | ||
| 356 | stored in SYMBOL's property `face-defface-spec' by `defface'." | ||
| 357 | (let ((spec (custom-theme-face-value face to-theme)) | ||
| 358 | was-in-theme) | ||
| 359 | (setq was-in-theme spec) | ||
| 360 | (setq spec (or spec (get face 'face-defface-spec))) | ||
| 361 | (when spec | ||
| 362 | (put face 'save-face was-in-theme) | ||
| 363 | (when (or (get face 'force-face) (facep face)) | ||
| 364 | (unless (facep face) | ||
| 365 | (make-empty-face face)) | ||
| 366 | (face-spec-set face spec))) | ||
| 367 | spec)) | ||
| 368 | |||
| 369 | ;;;###autoload | ||
| 370 | (defun custom-theme-reset-faces (theme &rest args) | ||
| 371 | "Reset the value of the face to values previously defined. | ||
| 372 | Associate this setting with THEME. | ||
| 373 | |||
| 374 | ARGS is a list of lists of the form | ||
| 375 | |||
| 376 | (FACE TO-THEME) | ||
| 377 | |||
| 378 | This means reset FACE to its value in TO-THEME." | ||
| 379 | (custom-check-theme theme) | ||
| 380 | (mapcar '(lambda (arg) | ||
| 381 | (apply 'custom-theme-reset-internal-face arg) | ||
| 382 | (custom-push-theme 'theme-face (car arg) theme 'reset (cadr arg))) | ||
| 383 | args)) | ||
| 384 | |||
| 385 | ;;;###autoload | ||
| 386 | (defun custom-reset-faces (&rest args) | ||
| 387 | "Reset the value of the face to values previously saved. | ||
| 388 | This is the setting assosiated the `user' theme. | ||
| 389 | |||
| 390 | ARGS is defined as for `custom-theme-reset-faces'" | ||
| 391 | (apply 'custom-theme-reset-faces 'user args)) | ||
| 305 | 392 | ||
| 306 | ;;; The End. | 393 | ;;; The End. |
| 307 | 394 | ||