I am trying to have specific settings when I start a new emacs frame in X as opposed to in the terminal while using emacs-server. My initial attempt was using this solution, but it appears it isn't working for me (using Emacs 24.4.1).
Basically, my minimimal non-working example is this:
(defun new-frame-setup (&optional frame) (if (display-graphic-p) (message "window system") (message "not a window system") )) ;; run when regular emacs is started (new-frame-setup) ;; run when a new frame is created using server (add-hook 'after-make-frame-functions 'new-frame-setup)
When I start regular emacs and go to my Messages buffer it says:
So this works just as I expected. However, if I run the command
emacsclient -c, the Messages buffer says
not a window system Starting Emacs daemon not a window system
The first "not a window system" makes sense, as it's starting the emacs server in the terminal. However, the second one doesn't make sense, as that frame is already a graphical window. Furthermore, after the fact, if I evaluate
(display-graphic-p) in my scratch buffer, it evaluates as
t. Any ideas as to what I'm doing wrong?
So the big problem here is not that
(display-graphic-p) doesn't work, it's that it doesn't know what frame to check. This was a problem for me since the daemon didn't have a window-system, but it's an even bigger problem if I have a terminal version and an X version of emacsclient running at the same time. For example, if I create a frame with
emacsclient -c and have it change some settings, and then I create a frame with
emacsclient -nw and have it change some other settings - all of those settings are getting changed at the global level.
So I guess the real question is: how can I get emacs to check the display of the most recently created frame, and then run some elisp code only on that frame? I have absolutely no idea if this is possible.