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

发布于 2024-09-05 04:14:33 字数 375 浏览 2 评论 0原文

我的 .emacs 文件位于此处。我希望当我处于 shell 模式 时主题能够改变。但所发生的情况是该主题被应用到所有窗口。我将变量 color-theme-is-global 设置为 nil,但问题仍然存在。

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

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

My .emacs file is here. I want the theme to change when I am in shell-mode. But what happens is that the theme gets applied to all the windows. I set the variable color-theme-is-global to nil, but the problem still persists.

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

These are the corresponding lines in my .emacs file. What should I do to make it work?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

弥繁 2024-09-12 04:14:33

我通常将 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 作为守护进程启动,则自定义只会在您创建第二个框架后启动,弹出的第一个框架将具有标准主题。

I usually start Emacs as a daemon and then open frames as needed. I use different color themes for X frames and terminal frames like so:

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

You can replace the (if window-system ...) part with your check for shell-script-mode and the color-theme-X parts with your favorite themes.

There is one downside to this: if you don't start Emacs as a deamon, the customization will only kick in after you create a second frame, the first one that pops up will have the standard theme.

执笔绘流年 2024-09-12 04:14:33

我认为你的术语是错误的:在 emacs-speak 中,frame 意味着人们通常在图形环境中所说的 window。 (也就是说,具有关闭、最小化和最大化按钮以及标题栏等的东西是“框架”。)而当您执行 Cx 3 (拆分- window)被称为windows,当你执行诸如Mx shell-mode之类的操作时,你会得到一个新的缓冲区,它可能位于也可能不位于一个新窗口。

颜色主题始终是框架全局的(据我所知,这当然也是文档所建议的)变量color-theme-is-global确定单个主题是否跨框架传播 /em>.

我认为最接近您想要的东西是这样的(完全未经测试,可能已损坏):

(defun shell-mode-in-new-frame ()
    (interactive)
    (select-frame (make-frame))
    (color-theme-monokai-terminal)
    (shell-mode))

尽管这确实创建了一个新框架,但这不是您想要的。

I think your terminology is off: in emacs-speak frame means what people normally mean by window in a graphical environment. (That is, the thing that has the close, minimize and maximize buttons and a titlebar, etc, is the "frame".) Whereas the things that show up when you do a C-x 3 (split-window) are called windows, and when you do something like M-x shell-mode you get a new buffer, which may or may not be in a new window.

Color themes are always frame-global (as far as I know, and it's certainly what the documentation suggests) the variable color-theme-is-global determines whether a single theme propagates across frames.

I'm thinking that the closest thing to what you want is something like (completely untested, probably broken):

(defun shell-mode-in-new-frame ()
    (interactive)
    (select-frame (make-frame))
    (color-theme-monokai-terminal)
    (shell-mode))

Although this does create a new frame, which isn't what you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文