The window-system
variable tells Lisp programs what window system Emacs is running under. The possible values are
- x
- Emacs is displaying the frame using X.
- w32
- Emacs is displaying the frame using native MS-Windows GUI.
- ns
- Emacs is displaying the frame using the Nextstep interface (used on GNUstep and Mac OS X).
- pc
- Emacs is displaying the frame using MS-DOS direct screen writes.
- nil
- Emacs is displaying the frame on a character-based terminal.
From the doc.
Edit: it seems that window-system is deprecated in favor of display-graphic-p
(source: C-h f window-system RET on emacs 23.3.1).
(display-graphic-p &optional DISPLAY)
Return non-nil if DISPLAY is a graphic display.
Graphical displays are those which are capable of displaying several
frames and several different fonts at once. This is true for displays
that use a window system such as X, and false for text-only terminals.
DISPLAY can be a display name, a frame, or nil (meaning the selected
frame's display).
So what you want to do is :
(if (display-graphic-p)
(progn
;; if graphic
(your)
(code))
;; else (optional)
(your)
(code))
And if you don't have an else clause, you can just:
;; more readable :)
(when (display-graphic-p)
(your)
(code))
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…