Search code examples
emacsrandomelispcolor-scheme

Emacs - random color theme every hour?


I know that to (funcall (car (nth (random (length color-themes)) color-themes))) gives me a random color theme on every Emacs startup; but I hardly restart Emacs. How do I cycle between random color themes, say, every hour?


Solution

  • (defun random-color-theme ()
      (interactive)
      (random t)
      (funcall (car (nth (random (length color-themes)) color-themes))))
    
    (random-color-theme)
    
    (run-with-timer 1 (* 60 60) 'random-color-theme)
    

    Credit goes to ggole @ #emacs (freenode); and aecrvol (below) for the (random t) tip.