在没有交互模式的情况下在启动时设置emacs主题

mur*_*a52 2 emacs elisp

我使用以下代码片段在Emacs启动时设置主题.

(load-theme 'sanityinc-tomorrow-eighties)
Run Code Online (Sandbox Code Playgroud)

但是它还要求我确认这将加载一些lisp代码,我该如何关闭此确认?

Dre*_*rew 6

使用load-theme非零NOCONFIRMarg.

C-h f load-theme告诉你(load-theme 'sanityinc-tomorrow-eighties t)应该加载主题而不要求确认:

,----
| load-theme is an interactive compiled Lisp function in `custom.el'.
| 
| (load-theme THEME &optional NO-CONFIRM NO-ENABLE)
| 
| Load Custom theme named THEME from its file.
| The theme file is named THEME-theme.el, in one of the directories
| specified by `custom-theme-load-path'.
| 
| If the theme is not considered safe by `custom-safe-themes',
| prompt the user for confirmation before loading it.  But if
| optional arg NO-CONFIRM is non-nil, load the theme without
| prompting.
| 
| Normally, this function also enables THEME.  If optional arg
| NO-ENABLE is non-nil, load the theme but don't enable it, unless
| the theme was already enabled.
| 
| This function is normally called through Customize when setting
| `custom-enabled-themes'.  If used directly in your init file, it
| should be called with a non-nil NO-CONFIRM argument, or after
| `custom-safe-themes' has been loaded.
| 
| Return t if THEME was successfully loaded, nil otherwise.
`----
Run Code Online (Sandbox Code Playgroud)

你应该先学会问Emacs. C-h f在问这么简单之前,你应该知道和使用的是最少的.

  • 解决方案实际上是“(load-theme 'sanityinc-tomorrow-eighties t)”。如果没有在主题前面加上引号,我会收到错误:“调试器已输入 - Lisp 错误:(void-variable sanityinc-tomorrow-eighties)” (2认同)