Function: consult-theme
consult-theme is an autoloaded, interactive and byte-compiled function
defined in consult.el.
Signature
(consult-theme THEME)
Documentation
Disable current themes and enable THEME from consult-themes.
The command supports previewing the currently selected theme.
Key Bindings
Source Code
;; Defined in ~/.emacs.d/elpa/consult-20260805.1130/consult.el
;;;;; Command: consult-theme
;;;###autoload
(defun consult-theme (theme)
"Disable current themes and enable THEME from `consult-themes'.
The command supports previewing the currently selected theme."
(interactive
(list
(let* ((regexp (consult--regexp-filter
(mapcar (lambda (x) (if (stringp x) x (format "\\`%s\\'" x)))
consult-themes)))
(avail-themes (seq-filter
(lambda (x) (string-match-p regexp (symbol-name x)))
(cons 'default (custom-available-themes))))
(saved-theme (car custom-enabled-themes)))
(consult--read
(mapcar #'symbol-name avail-themes)
:prompt "Theme: "
:require-match t
:category 'theme
:history 'consult--theme-history
:lookup (lambda (selected &rest _)
(setq selected (and selected (intern-soft selected)))
(or (and selected (car (memq selected avail-themes)))
saved-theme))
:state (lambda (action theme)
(with-selected-window (or (active-minibuffer-window)
(selected-window))
(pcase action
('return (consult-theme (or theme saved-theme)))
((and 'preview (guard theme)) (consult-theme theme)))))
:default (symbol-name (or saved-theme 'default))))))
(when (eq theme 'default) (setq theme nil))
(unless (eq theme (car custom-enabled-themes))
(mapc #'disable-theme custom-enabled-themes)
(when theme
(unless (and (memq theme custom-known-themes) (get theme 'theme-settings))
(load-theme theme 'no-confirm 'no-enable))
(if (and (memq theme custom-known-themes) (get theme 'theme-settings))
(enable-theme theme)
(consult--minibuffer-message "%s is not a valid theme" theme)))))