在.emacs
文件中,有没有可能检查emacs是否在--no-window-system
(-nw
)模式下运行?我想只有当Emacs处于窗口模式(或者不是)时才启用/包含某些扩展。
顺祝商祺, mefiX
在.emacs
文件中,有没有可能检查emacs是否在--no-window-system
(-nw
)模式下运行?我想只有当Emacs处于窗口模式(或者不是)时才启用/包含某些扩展。
顺祝商祺, mefiX
如果所选帧位于仅支持文本的终端上,则变量window-system
为nil
。
(when window-system ... stuff ...)
来评估我只想在窗口模式下运行的所有内容。 - mefiXwindow-system
的值是针对当前的窗口而言的。如果你以 GUI 模式启动 Emacs,则 window-system
将为 t
,但如果你从终端使用 emacsclient -t
连接到同一个 Emacs 实例,则该终端窗口中的 window-system
将为 nil
。因此,在 .emacs
文件中基于 window-system
做决定并不是一个好的实践方法,相反,应将相应的条件代码嵌入到钩子或其他稍后将被调用的函数中。 - sanityinc如果您想在Emacs运行于窗口环境中时执行代码,请将其放在when块内,并使用display-graphic-p谓词,例如:
(when (display-graphic-p)
(do something)
(do-another-thing))