gpt4 book ai didi

emacs - 无法将颜色主题应用于 Emacs 中的一个框架?

转载 作者:行者123 更新时间:2023-12-01 10:13:47 26 4
gpt4 key购买 nike

我的 .emacs 文件是 here .当我处于 shell-mode 时,我希望主题发生变化。但是发生的是主题被应用到所有窗口。我将变量color-theme-is-global设置为nil,但问题依然存在。

(add-hook 'shell-mode-hook 'color-theme-monokai-terminal)
(set-variable 'color-theme-is-global nil)

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

最佳答案

我通常将 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)

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

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

关于emacs - 无法将颜色主题应用于 Emacs 中的一个框架?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3035919/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com