Function: consult-theme
consult-theme is an interactive and natively 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
This command is not in any keymaps.
Source Code
;; Defined in /nix/store/6higv2v1wk916v4ynnybyrdkfy2gq44d-emacs-packages-deps/share/emacs/site-lisp/elpa/consult-20261004.957/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
(cl-loop for dir in (custom-theme--load-path)
for group = (file-name-nondirectory (directory-file-name dir))
if (file-directory-p dir) nconc
(cl-loop for file in (directory-files dir nil "-theme\\.el\\'")
for name = (string-remove-suffix "-theme.el" file)
for sym = (intern name)
if (and (string-match-p regexp name)
(custom-theme-name-valid-p sym))
collect (propertize name 'consult--group group))))
(saved-theme (car custom-enabled-themes)))
(setq avail-themes (delete-consecutive-dups
(sort (cons "default" avail-themes) #'string<)))
(consult--read
avail-themes
:prompt "Theme: "
:require-match t
:category 'theme
:history 'consult--theme-history
:group #'consult--group-prop
:lookup (lambda (selected &rest _)
(or (and selected (intern-soft (car (member 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)))))