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?


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? – Mertcan Ekiz Sep 23 '14 at 15:28
  • I can't give you a good answer to that, sorry. – Drew Sep 23 '14 at 18:03

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, privacy policy and cookie policy

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