是否可以从elisp函数中检查当前emacs框架是X窗口还是终端?
我有一个最大化窗口的函数,并且它设置为每当创建一个新帧时运行。但是,当我打开一个仅限终端的会话时,无论何时创建一个新帧,我都会收到错误消息。
我希望函数检查它是否是X窗口,否则什么都不做。这可能吗?
对于记录,这是当前的功能:
(defun fullscreen (&optional f)
(interactive) ;if called interactively, use current frame
(if f (select-frame f)) ;if called as hook, use new frame
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_VERT" 0))
(x-send-client-message nil 0 nil "_NET_WM_STATE" 32
'(2 "_NET_WM_STATE_MAXIMIZED_HORZ" 0))
)
答案 0 :(得分:3)
您可以查看window-system
功能。它接受一个frame可选参数(默认为当前帧)。或者,display-graphic-p
更新(根据文档)并允许检查包含多个帧的整个显示。在您的示例中,您可以写:
(if (display-graphic-p) ...)
答案 1 :(得分:0)
你也可以使用framep' since its return value is defined (according to
C-h f framep`):
Return non-nil if OBJECT is a frame.
Value is:
t for a termcap frame (a character-only terminal),
'x' for an Emacs frame that is really an X window,
'w32' for an Emacs frame that is a window on MS-Windows display,
'ns' for an Emacs frame on a GNUstep or Macintosh Cocoa display,
'pc' for a direct-write MS-DOS frame.
See also `frame-live-p'.