Function: enable-theme

enable-theme is an interactive and byte-compiled function defined in custom.el.gz.

Signature

(enable-theme THEME)

Documentation

Reenable all variable and face settings defined by THEME.

THEME should be either user, or a theme loaded via load-theme.

After this function completes, THEME will have the highest precedence (after user) among enabled themes.

Note that any already-enabled themes remain enabled after this function runs. To disable other themes, use disable-theme.

After THEME has been enabled, runs enable-theme-functions.

This function has :after advice: cider--test-adapt-to-theme. This function has :after advice: cider--stacktrace-adapt-to-theme. This function has :after advice: cider--docview-adapt-to-theme.

View in manual

Probably introduced at or before Emacs version 22.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/custom.el.gz
(defun enable-theme (theme)
  "Reenable all variable and face settings defined by THEME.
THEME should be either `user', or a theme loaded via `load-theme'.

After this function completes, THEME will have the highest
precedence (after `user') among enabled themes.

Note that any already-enabled themes remain enabled after this
function runs.  To disable other themes, use `disable-theme'.

After THEME has been enabled, runs `enable-theme-functions'."
  (interactive (list (intern
		      (completing-read
		       "Enable custom theme: "
		       obarray (lambda (sym) (get sym 'theme-settings)) t))))
  (unless (custom-theme-p theme)
    (error "Undefined Custom theme %s" theme))
  (let ((settings (get theme 'theme-settings)) ; '(prop symbol theme value)
        ;; We are enabling the theme, so don't inhibit enabling it.  (Bug#34027)
        (custom--inhibit-theme-enable nil))
    ;; Loop through theme settings, recalculating vars/faces.
    (dolist (s settings)
      (let* ((prop (car s))
             (symbol (cadr s))
             (spec-list (get symbol prop))
             (val (and (boundp symbol) (symbol-value symbol))))
        ;; We can't call `custom-push-theme' when enabling the theme: it's not
        ;; that the theme settings have changed, it's just that we want to
        ;; enable those settings.  But we might need to save a user setting
        ;; outside of Customize, in order to get back to it when disabling
        ;; the theme, just like in `custom-push-theme'.
        (when (and (custom--should-apply-setting theme)
                   ;; Only do it for variables; for faces, using
                   ;; `face-new-frame-defaults' is enough.
                   (eq prop 'theme-value)
                   (boundp symbol)
                   (not (or spec-list
                            ;; Only if the current value is different from
                            ;; the standard value.
                            (custom--standard-value-p symbol val)
                            ;; And only if the changed value is different
                            ;; from the new value under the user theme.
                            (and (eq theme 'user)
                                 (equal (custom-quote val) (nth 3 s))))))
          (setq spec-list `((changed ,(custom-quote val)))))
        (put symbol prop (cons (cddr s) (assq-delete-all theme spec-list)))
	(cond
	 ((eq prop 'theme-face)
	  (custom-theme-recalc-face symbol))
	 ((eq prop 'theme-value)
	  ;; Ignore `custom-enabled-themes' and `custom-safe-themes'.
	  (unless (memq symbol '(custom-enabled-themes custom-safe-themes))
	    (custom-theme-recalc-variable symbol)))))))
  (unless (eq theme 'user)
    (setq custom-enabled-themes
	  (cons theme (remq theme custom-enabled-themes)))
    ;; Give the `user' theme the highest priority.
    (enable-theme 'user))
  ;; Allow callers to react to the enabling.
  (run-hook-with-args 'enable-theme-functions theme))