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

10

我知道每次启动Emacs时,(funcall (car (nth (random (length color-themes)) color-themes)))会给我一个随机颜色主题;但我几乎不重启Emacs。我该如何在随机颜色主题之间循环,比如每小时更换一次?


这听起来很糟糕 :) 你的想法是随机选择颜色方案,直到你找到一个想要保留的吗? - phils
3个回答

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)

感谢 #emacs (freenode) 的 ggole 和下面的 aecrvol 提供了 (random t) 技巧。


我遇到了一个错误 void variable color-themes。在此之前,我应该做些什么准备工作? - jdhao

3

1
这是我的更新:
(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)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接