Function: disable-theme

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

Signature

(disable-theme THEME)

Documentation

Disable all variable and face settings defined by THEME.

See custom-enabled-themes for a list of enabled themes.

After THEME has been disabled, runs disable-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 disable-theme (theme)
  "Disable all variable and face settings defined by THEME.
See `custom-enabled-themes' for a list of enabled themes.

After THEME has been disabled, runs `disable-theme-functions'."
  (interactive (list (intern
		      (completing-read
		       "Disable custom theme: "
                       (mapcar #'symbol-name custom-enabled-themes)
		       nil t))))
  (when (custom-theme-enabled-p theme)
    (let ((settings (get theme 'theme-settings)))
      (dolist (s settings)
	(let* ((prop   (car s))
	       (symbol (cadr s))
	       (val (assq-delete-all theme (get symbol prop))))
          (put symbol prop val)
	  (cond
	   ((eq prop 'theme-value)
            (custom-theme-recalc-variable symbol)
            ;; We might have to reset the stashed value of the variable, if
            ;; no other theme is customizing it.  Without this, loading a theme
            ;; that has a setting for an unbound user option and then disabling
            ;; it will leave this lingering setting for the option, and if then
            ;; Emacs evaluates the defcustom the saved-value might be used to
            ;; set the variable.  (Bug#20766)
            (unless (get symbol 'theme-value)
              (put symbol 'saved-value nil)))
	   ((eq prop 'theme-face)
	    ;; 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 (cadar 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))
    ;; Allow callers to react to the disabling.
    (run-hook-with-args 'disable-theme-functions theme)))