Emacs random-load-theme function

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

genAI இடம் உன் நிரலை இயக்கினால் Emacs இந்த திரையில் வருவதுபோல் திட்டுகிறது என்று கூறினீர்களா? அதற்கு genAI என்ன பதில் அளித்தது? --debug-init என்றால் என்ன என்று விளக்கம் அளித்ததா? அல்லது --debug-init என்ற வார்த்தை அதன் கண்களுக்கு தெரியாமல் போய்விட்டதா?

genAIயிடம் கேட்கவில்லை. genAI இரண்டு பிரச்சனையை நான்கு ஆக்கிவிடும் என்பதால் உங்களிடம் வந்தேன் :upside_down_face:

Emacs திரையில் என்ன கூறுகின்றது என்று படித்துப் பார்தீர்களா? அதன்படி Emacs ஐ இயக்கினீர்களா? என்ன வந்தது? அதை இங்கே பகிரவும்.

–debug-init
show Backtrace

உங்கள் config.org கோப்பில் My Functions என்ற வரிக்கு முன் #end_ என்று உள்ளது, அதை #end_src என்று வைத்து முயற்சித்து பார்க்கவும்.

ஒரு சிறிய உதவி அந்த load-random-doom-theme function இயக்க ஒரு keybind set செய்ய வேண்டும் அது எப்படி?

genAI இடம் கேட்டுப்பாருங்கள். அது உங்கள் வினாவை சுலபமாக தீர்க்கும். அதைவிட மேலும் சுலபமான வழி ஒன்று உள்ளது, அதற்கு பெயர் டாக்குமெண்டுகளை படித்து புரிந்து கொள்வது, முடிந்தால் படிக்க முயற்சித்து பாருங்கள். பலவும் புரிய வரும்.

1 Like

சரி.
நன்றி நண்பரே :slight_smile: