Emacs - 每小时随机颜色主题?

时间:2010-08-13 23:37:52

标签: emacs random elisp color-scheme

我知道(funcall (car (nth (random (length color-themes)) color-themes)))在每个Emacs创业公司给我一个random color theme;但我几乎没有重启Emacs。如何在随机颜色主题之间循环,比方说,每小时?

3 个答案:

答案 0 :(得分:9)

(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)

归功于ggole @ #emacs(freenode); aecrvol小费(random t)(下方)。

答案 1 :(得分:3)

一点点改进:添加到函数(random t), 否则生成的序列在每个Emacs运行中都是相同的( 来自http://www.gnu.org/software/emacs/elisp/html_node/Random-Numbers.html)。

(defun random-color-theme ()
  (interactive)
  (random t)  ; randomazing
  (funcall (car (nth (random (length color-themes)) color-themes))))

答案 2 :(得分:0)

这是我的最新消息:

(setq color-themes (custom-available-themes))

(defun random-color-theme ()
  (interactive)
  (random t)
  (load-theme
   (nth (random (length color-themes)) color-themes)
   t))


(random-color-theme)

(run-with-timer 1 (* 60 60) 'random-color-theme)