如何让 emacsclient 在终端和 X 窗口中使用不同的主题?

Hon*_*hen 7 terminal emacs elisp

有时我emacsclient -t -a ''在 xterm 中使用,有时我emacsclient -c用作 GUI 应用程序。令我烦恼的是,emacs 服务器启动时字体设置和颜色主题已初始化,因此window-system测试不生效。

那么我可以使用任何功能让 emacsclient 选择面部设置吗?

谢谢。

Shl*_*omi 5

尝试关注此帖子,他们正在谈论类似的问题。

这是帖子中的片段(虽然我自己没有尝试过):

  ;; last t is for NO-ENABLE
  (load-theme 'tango t t)
  (load-theme 'tango-dark t t)

  (defun mb/pick-color-theme (frame)
    (select-frame frame)
    (if (window-system frame)
        (progn  
          (disable-theme 'tango-dark) ; in case it was active
          (enable-theme 'tango))
      (progn  
        (disable-theme 'tango) ; in case it was active
        (enable-theme 'tango-dark))))
  (add-hook 'after-make-frame-functions 'mb/pick-color-theme)

  ;; For when started with emacs or emacs -nw rather than emacs --daemon
  (if window-system
      (enable-theme 'tango)
    (enable-theme 'tango-dark))
Run Code Online (Sandbox Code Playgroud)

如果一切顺利,它应该是这样的: 这个