tags:

views:

179

answers:

2

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?)

+8  A: 

I think I found my own answer:

(when window-system
    (foo))

will only foo when I'm running in X.

JasonFruit
Please stop voting up my own answer to my question --- the one I accepted above is essentially the same, but more complete!
JasonFruit
+8  A: 

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 actualyl using X, you'd have to go

(if (eq window-system 'X) (foo))
Nathaniel Flath
Though I don't need that kind of specificity, that's a better answer than mine. Thanks!
JasonFruit
When I was trying to figure out how to disable theming in window only mode, I ended up going with JasonFruit's initial answer, but they're really getting at the same thing. `(if (eq window-system 'X) (foo))` or `(if window-system (foo))` or `(when window-system (foo))` it doesn't really make a difference. For those interested in the details, just let me tell you "C-h a" is your friend. Using it I searched "variable" and found 'describe-variable and using that plus tab-completion i found the window-system variable. Then I just typed `window-system` into the scratch buffer and then tested it
Ton as in Anton
They will work the same if all you care about is if the window system is X or not, but window-system's value can be a value other than 'X.
Nathaniel Flath