I’m trying to create a theme switcher prompt, but I don’t understand how prompter:active-attributes-keys
is supposed to work. I list Name and Package, but only Name is visible. If I don’t include active-attribute-keys, Name, Visibility and Documentation is shown. So I guess my prompter:object-attributes isn’t called…?
My configuration:
(defun set-current-theme (theme)
(setf (slot-value *browser* 'theme) theme))
(defun get-themes (&optional (package 'nyxt-user))
(cl:remove-if-not (lambda (x) (theme:themep (symbol-value x)))
(nsymbols:package-variables package)))
(defun all-themes ()
(mapcan #'get-themes (list-all-packages)))
(define-class theme-source (prompter:source)
((prompter:name "Themes")
(prompter:constructor (all-themes))
(prompter:filter-preprocessor #'prompter:filter-exact-matches)
(prompter:active-attributes-keys '("Name" "Package"))
(prompter:actions-on-return (list (lambda-command set-theme (themes)
(set-current-theme (symbol-value (car themes))))))))
(defmethod prompter:object-attributes ((theme theme:theme) (source theme-source))
(declare (ignore source))
`(("Name" ,(symbol-name theme))
("Package" ,(package-name (symbol-package theme)))))
(define-command switch-theme ()
(prompt
:prompt "Set current theme"
:sources (make-instance 'theme-source)))