2

如果当前的 emacs 框架是 X 窗口还是终端,是否可以从 elisp 函数中检查?

我有一个最大化窗口的功能,它设置为在创建新框架时运行。但是,当我打开仅限终端的会话时,每当创建新框架时都会收到错误消息。

我希望该函数检查它是否是 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))
  )
4

2 回答 2

3

你可以看看window-system函数。它接受一个帧可选参数(默认为当前帧)。或者,display-graphic-p更新(根据文档)并允许检查包含多个帧的整个显示。在您的示例中,您可以只写:

(if (display-graphic-p) ...)
于 2012-04-17T17:01:17.353 回答
0

您还可以将framep' since its return value is defined (according toCh 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'.
于 2012-04-21T03:00:52.390 回答