0

我正在使用emacs配置prelude。我改变了主题,它工作正常,我添加它是preload directory这样的:

;; preload color theme
(setq prelude-theme 'my-theme)

我通过 安装了主题prelude-require-packages,但不在preload文件夹中(不确定它是否很快可用)。有没有办法以编程方式检查主题是否可用,用更安全的东西替换上一行,例如:

;; just to get the idea
(when (is-available 'my-theme)
      (setq prelude-theme 'my-theme))

编辑 我试过:

;; preload color theme
(when (featurep 'my-theme)
  (setq prelude-theme 'my-theme))

但在这种情况下,我得到默认主题,而不是“我的主题”。

4

1 回答 1

1

The load-theme function uses locate-file to find theme files. This approach is based that code:

(if (locate-file (concat (symbol-name 'my-theme) "-theme.el")
                 custom-theme-load-path '("" "c"))
    (setq prelude-theme 'my-theme))

You can replace the entire (concat ...) construct with the theme filename string, which for this example would be "my-theme-theme.el".

于 2015-07-25T14:08:58.437 回答