I have my color theme settings and a function to automatically maximize emacs on startup in my .emacs file, however, using this .emacs file with no window mode -nw results in an error since an X window is not initialized. So I was wondering if it was possible to use a separate init file or check in the original .emacs file to see if emacs is started in no window mode, and then call the maximize and set color theme commands accordingly?

2 Answers 2


No, window-system is not recommended for this, ever since graphic-display-p was added to Emacs (way back in Emacs 22). Do not use (if window-system...). Use this instead:

 (if (display-graphic-p) ...)

If you use your init file with both an old Emacs version (prior to Emacs 22) and a new one, then use this:

 (if (if (fboundp 'display-graphic-p) (display-graphic-p) window-system) ...)
  • Alright, I will use that instead, but what is the difference between display-graphic-p and window-system? Sep 23, 2014 at 15:28
  • I can't give you a good answer to that, sorry.
    – Drew
    Sep 23, 2014 at 18:03
  • This answer of @Lindydancer shows the docs of display-graphic-p and window-system and when the use of window-system is not recomended emacs.stackexchange.com/a/8200
    – campisano
    Feb 26, 2022 at 23:09

You can wrap the X specific part into

(if window-system ...)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.