Subject: bug#65145: ‘enable-theme’ completion for themes loaded by ‘require-theme’

From: Mauro Aranda <[email-masked]>
Date: Wed, 9 Aug 2023 06:50:47 -0300

Shynur Xie <[email-masked]> writes:

 >> I can't reproduce it.  I did:
 >> emacs -Q
 >> (require-theme 'leuven-theme)
 >> M-x enable-theme
 >
 > Oh Oh, sorry, Mauro.  I forgot to say that, this occurs only when
 > using a third-party theme, e.g., you create a file named ‘X-theme.el’,
 > which is under ‘/tmp/’ and contains the following code:
 >
 >     (deftheme X)
 >     (provide 'X-theme)
 >
 > Then evaluate
 >
 >     (let ((custom-theme-load-path '("/tmp/")))
 >       (require-theme 'X-theme))
 >
 > Then call ‘enable-theme’ interactively.

Thanks, I see it now.  Note that if you change the X-theme.el file to
something like this:

(deftheme X)

(let ((class '((class color) (min-colors 89))))
   (custom-theme-set-faces
    'X
    `(default ((,class (:background "#222222" :foreground "#f6f6f6"))))))

(provide-theme 'X)

Then there's completion for "X".  The reason is that, for completion,
Custom looks for a non-nil theme-settings property.  Your empty theme
recipe doesn't have settings, so theme-settings is nil, while if you
change it to a non-empty theme, theme-settings will be non-nil.

I don't really see a need to change the code here.