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)

Is that possible?

  • 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
    Commented Nov 7, 2016 at 14:06

1 Answer 1


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 you have read our privacy policy.

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