【问题标题】:Emacs - random color theme every hour?Emacs - 每小时随机颜色主题?
【发布时间】:2010-08-13 23:37:51
【问题描述】:

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

【问题讨论】:

  • 这听起来很可怕 :) 随机选择配色方案,直到你偶然发现一个你想要保留的想法?

标签: emacs random elisp color-scheme


【解决方案1】:
(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) 提示。

【讨论】:

  • 我收到一个错误void variable color-themes。我应该做什么作为先决条件?
【解决方案2】:

一点改进:添加到函数(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))))

【讨论】:

    【解决方案3】:

    这是我的更新:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-03-17
      • 1970-01-01
      • 1970-01-01
      • 2014-09-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多