无法将颜色主题应用于 Emacs 中的一帧?

prt*_*xna 3 emacs customization themes

我的.emacs文件在这里。我希望主题在我进入时改变shell-mode。但所发生的情况是该主题被应用到所有窗口。我将变量设置color-theme-is-globalnil,但问题仍然存在。

(add-hook 'shell-mode-hook 'color-theme-monokai-terminal)
(set-variable 'color-theme-is-global nil)
Run Code Online (Sandbox Code Playgroud)

这些是我的文件中的相应行.emacs。我应该做什么才能让它发挥作用?

mal*_*ana 5

我通常将 Emacs 作为守护进程启动,然后根据需要打开框架。我对 X 框架和终端框架使用不同的颜色主题,如下所示:

(require 'color-theme)
(color-theme-initialize)

(defun apply-color-theme (frame)
  "Apply color theme to a frame based on whether its a 'real'
   window or a console window."
  (select-frame frame)
  (if (window-system frame)
      (color-theme-tango)
    (color-theme-tango-black)))

(setq color-theme-is-global nil)
(add-hook 'after-make-frame-functions 'apply-color-theme)
Run Code Online (Sandbox Code Playgroud)

您可以将(if window-system ...)检查 shell-script-mode 的部分替换为您喜欢的主题,并将 color-theme-X 部分替换为您喜欢的主题。

这样做有一个缺点:如果您不将 Emacs 作为守护进程启动,则自定义只会在您创建第二个框架后启动,弹出的第一个框架将具有标准主题。