3

I use emacs gui in daemon mode and also in standalone terminal mode. There is a package that I just want to use when I'm using emacs in terminal mode.

the problem is that I can't use (display-graphic-p) because when I run emacs --daemon the initialization system thinks that I have no graphic-display, but I'll have when I connect the emacsclient to the daemon.

I wish I had access to a function like this:

(if (emacs-initiating-in-daemon-mode)
    (my-setup-for-gui)
    (my-setup-for-terminal))

Is that possible?

1
  • 1
    When started in daemon mode, you may later open up a tty frame (i.e. use emacsclient from a terminal), so your daemon should be prepared for both GUI and text-terminal frames at the same time. How to do that depends on the details of what you want/need to do, which you haven't provided.
    – Stefan
    Nov 7, 2016 at 14:06

1 Answer 1

6

I think daemonp is what you're looking for. From its docstring:

Return non-nil if the current emacs process is a daemon.
If the daemon was given a name argument, return that name.

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.