Function: customize-themes

customize-themes is an autoloaded, interactive and byte-compiled function defined in cus-theme.el.gz.

Signature

(customize-themes &optional BUFFER)

Documentation

Display a selectable list of Custom themes.

When called from Lisp, BUFFER should be the buffer to use; if omitted, a buffer named *Custom Themes* is used.

View in manual

Probably introduced at or before Emacs version 24.1.

Key Bindings

Source Code

;; Defined in /usr/src/emacs/lisp/cus-theme.el.gz
;;;###autoload
(defun customize-themes (&optional buffer)
  "Display a selectable list of Custom themes.
When called from Lisp, BUFFER should be the buffer to use; if
omitted, a buffer named *Custom Themes* is used."
  (interactive)
  (switch-to-buffer (get-buffer-create (or buffer "*Custom Themes*")))
  (let ((inhibit-read-only t))
    (erase-buffer))
  (custom-theme-choose-mode)
  (setq-local custom--listed-themes nil)
  (make-local-variable 'custom-theme-allow-multiple-selections)
  (and (null custom-theme-allow-multiple-selections)
       (> (length custom-enabled-themes) 1)
       (setq custom-theme-allow-multiple-selections t))

  (widget-insert
   (substitute-command-keys
    "Type RET or click to enable/disable listed custom themes.
Type \\[custom-describe-theme] to describe the theme at point.
Theme files are named *-theme.el in `"))
  (widget-create 'link :value "custom-theme-load-path"
		 :button-face 'custom-link
		 :mouse-face 'highlight
		 :pressed-face 'highlight
		 :help-echo "Describe `custom-theme-load-path'."
		 :keymap custom-mode-link-map
		 :follow-link 'mouse-face
		 :action (lambda (_widget &rest _ignore)
			   (describe-variable 'custom-theme-load-path)))
  (widget-insert (substitute-command-keys "'.\n\n"))

  ;; If the user has made customizations, display a warning and
  ;; provide buttons to disable or convert them.
  (let ((user-settings (get 'user 'theme-settings)))
    (unless (or (null user-settings)
		(and (null (cdr user-settings))
		     (eq (caar user-settings) 'theme-value)
		     (eq (cadr (car user-settings)) 'custom-enabled-themes)))
      (widget-insert
       (propertize
	" Note: Your custom settings take precedence over theme settings.
       To migrate your settings into a theme, click "
	'face 'font-lock-warning-face))
      (widget-create 'link :value "here"
		     :button-face 'custom-link
		     :mouse-face 'highlight
		     :pressed-face 'highlight
		     :help-echo "Migrate."
		     :keymap custom-mode-link-map
		     :follow-link 'mouse-face
		     :action (lambda (_widget &rest _ignore)
			       (customize-create-theme 'user)))
      (widget-insert ".\n\n")))

  (widget-create 'push-button
		 :tag " Save Theme Settings "
		 :help-echo "Save the selected themes for future sessions."
                 :action #'custom-theme-save)
  (widget-insert ?\n)
  (widget-create 'checkbox
		 :value custom-theme-allow-multiple-selections
                 :action #'custom-theme-selections-toggle)
  (widget-insert (propertize " Select more than one theme at a time"
			     'face '(variable-pitch (:height 0.9))))

  (widget-insert "\n\nAvailable Custom Themes:\n")
  (let ((help-echo "mouse-2: Enable this theme for this session")
	widget)
    (dolist (theme (custom-available-themes))
      ;; Don't list obsolete themes.
      (unless (get theme 'byte-obsolete-info)
        (setq widget (widget-create 'checkbox
				    :value (custom-theme-enabled-p theme)
				    :theme-name theme
				    :help-echo help-echo
                                    :action #'custom-theme-checkbox-toggle))
        (push (cons theme widget) custom--listed-themes)
        (widget-create 'push-button
                       :button-face-get 'ignore
                       :mouse-face-get 'ignore
                       :value (format " %s" theme)
                       :action (lambda (_w &optional event)
                                 (custom-theme-checkbox-toggle widget event))
                       :help-echo help-echo)
        (widget-insert " -- "
		       (propertize (custom-theme-summary theme)
				   'face 'shadow)
		       ?\n))))
  (goto-char (point-min))
  (widget-setup))