Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell in elisp if Emacs is using X?

Tags:

emacs

elisp

I have some items in my .emacs that I don't want to run if I ran emacs -nw. How can I tell in elisp if that is the case?

(edited to change -nox to -nw --- where was my brain?)

like image 278
JasonFruit Avatar asked May 28 '09 20:05

JasonFruit


3 Answers

Your answer above is correct, although if you want to differentiate between other window systems and only want to run the code if you are actually using X, you'd have to go

(if (eq window-system 'X) (foo))
like image 147
Nathaniel Flath Avatar answered Nov 16 '22 13:11

Nathaniel Flath


I think I found my own answer:

(when window-system
    (foo))

will only foo when I'm running in X.

like image 14
JasonFruit Avatar answered Nov 16 '22 15:11

JasonFruit


Note that the question is somewhat ill-conceived: Emacs can run with both tty frames and GUI frames at the very same time.

The window-system variable is "terminal-local" which means that its value will depend on whether the currently selected frame is a tty frame or GUI frame.

like image 3
Stefan Avatar answered Nov 16 '22 15:11

Stefan