diff options
author | Chong Yidong <cyd@stupidchicken.com> | 2011-07-03 18:16:07 -0400 |
---|---|---|
committer | Chong Yidong <cyd@stupidchicken.com> | 2011-07-03 18:16:07 -0400 |
commit | 1485f4c03a3e887f8e60fefb96e5e3d9ca484cf7 (patch) | |
tree | 07c3889b6d224dbf2c2fcc647580c2ff548e56dd /lisp/custom.el | |
parent | 9fa3dd45482a9fa8084fae495b3a857a216decf2 (diff) | |
download | emacs-1485f4c03a3e887f8e60fefb96e5e3d9ca484cf7.tar.gz emacs-1485f4c03a3e887f8e60fefb96e5e3d9ca484cf7.tar.bz2 emacs-1485f4c03a3e887f8e60fefb96e5e3d9ca484cf7.zip |
Fix how custom themes handle faces, so the multi-tty/multi-frame case works.
* lisp/custom.el (custom-push-theme): Don't record faces in `changed'
theme; this doesn't work correctly for per-frame face settings.
(disable-theme): Use face-set-after-frame-default to reset faces.
(custom--frame-color-default): New function.
* lisp/frame.el (frame-background-mode, frame-set-background-mode):
Moved from faces.el.
(frame-default-terminal-background): New function.
* src/xfaces.c (Finternal_merge_in_global_face): Modify the foreground
and background color parameters if they have been changed.
Diffstat (limited to 'lisp/custom.el')
-rw-r--r-- | lisp/custom.el | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/lisp/custom.el b/lisp/custom.el index a1c7f3e11e7..11dc1859c00 100644 --- a/lisp/custom.el +++ b/lisp/custom.el @@ -855,25 +855,18 @@ See `custom-known-themes' for a list of known themes." ;; Add a new setting: (t (unless old - ;; If the user changed the value outside of Customize, we - ;; first save the current value to a fake theme, `changed'. - ;; This ensures that the user-set value comes back if the - ;; theme is later disabled. - (cond ((and (eq prop 'theme-value) - (boundp symbol)) - (let ((sv (get symbol 'standard-value)) - (val (symbol-value symbol))) - (unless (and sv (equal (eval (car sv)) val)) - (setq old `((changed ,(custom-quote val))))))) - ((and (facep symbol) - (not (face-attr-match-p - symbol - (custom-fix-face-spec - (face-spec-choose - (get symbol 'face-defface-spec)))))) - (setq old `((changed - (,(append '(t) (custom-face-attributes-get - symbol nil))))))))) + ;; If the user changed a variable outside of Customize, save + ;; the value to a fake theme, `changed'. If the theme is + ;; later disabled, we use this to bring back the old value. + ;; + ;; For faces, we just use `face-new-frame-defaults' to + ;; recompute when the theme is disabled. + (when (and (eq prop 'theme-value) + (boundp symbol)) + (let ((sv (get symbol 'standard-value)) + (val (symbol-value symbol))) + (unless (and sv (equal (eval (car sv)) val)) + (setq old `((changed ,(custom-quote val)))))))) (put symbol prop (cons (list theme value) old)) (put theme 'theme-settings (cons (list prop symbol theme value) theme-settings)))))) @@ -1356,11 +1349,33 @@ See `custom-enabled-themes' for a list of enabled themes." ;; If the face spec specified by this theme is in the ;; saved-face property, reset that property. (when (equal (nth 3 s) (get symbol 'saved-face)) - (put symbol 'saved-face (and val (cadr (car val))))) - (custom-theme-recalc-face symbol))))) + (put symbol 'saved-face (and val (cadr (car val))))))))) + ;; Recompute faces on all frames. + (dolist (frame (frame-list)) + ;; We must reset the fg and bg color frame parameters, or + ;; `face-set-after-frame-default' will use the existing + ;; parameters, which could be from the disabled theme. + (set-frame-parameter frame 'background-color + (custom--frame-color-default + frame :background "background" "Background" + "unspecified-bg" "white")) + (set-frame-parameter frame 'foreground-color + (custom--frame-color-default + frame :foreground "foreground" "Foreground" + "unspecified-fg" "black")) + (face-set-after-frame-default frame)) (setq custom-enabled-themes (delq theme custom-enabled-themes))))) +(defun custom--frame-color-default (frame attribute resource-attr resource-class + tty-default x-default) + (let ((col (face-attribute 'default attribute t))) + (cond + ((and col (not (eq col 'unspecified))) col) + ((null (window-system frame)) tty-default) + ((setq col (x-get-resource resource-attr resource-class)) col) + (t x-default)))) + (defun custom-variable-theme-value (variable) "Return (list VALUE) indicating the custom theme value of VARIABLE. That is to say, it specifies what the value should be according to |