Hi everyone,
I created an Emacs function that randomly loads a theme at startup.
I don’t know much about Elisp, so I asked a popular genAI for help. It provided some code, and I added it to my config.org
file.
When I manually run the function using C-x C-e
, it works perfectly. I reopen Emacs, the function does not load as expected.
help me solve this issue
my config code
* My Functions
** Random-doom-theme
#+begin_src emacs-lisp
;themes list
(defvar my-doom-themes
'(doom-gruvbox
doom-solarized-dark-high-contrast
doom-Iosvkem
doom-dark+
doom-nord-aurora
doom-tokyo-night
doom-material
doom-dracula
doom-palenight)
)
;function
(defun load-random-doom-theme()
(let ((random-theme (nth (random (length my-doom-themes)) my-doom-themes)))
;disable previous theme
(mapc #'disable-theme custom-enabled-themes)
(load-theme random-theme t)
(message "Loading theme: %s" random-theme)
)
)
;call function
(load-random-doom-theme)
#+end_src
screenshot