How to use Emacs desktop functionality with emacs daemon + emacsclient instances?

I've enabled (desktop-save-mode 1) in my init file, and when I start the daemon I see messages like this:

Desktop: 1 frame, 2 buffers restored.

However, it does not restart any of emacsclient instances I have. When I start an emacsclient instance it's blank.

Is there a way to restore the desktop manually once I open a new emacsclient instance? Or is there a way to make this work another way?

1 Answer 1


I suspect you have unremoved desktop lockfiles, which will usually be in your config dir/folder, which is hopefully ~/.emacs.d/. Here's a procedure for testing my hypothesis from a commandline (e.g. a Bash shell running in a terminal app under Linux):

  1. Ensure you have no emacs* processes running: i.e., there should be null response to

    pgrep -l emacs

    If you do get a response, like

    $ pgrep -l emacs
    29422 emacs

    you will need to manually close your Emacsen, or brutally kill them with (e.g.)

    pkill -9 emacs
  2. Check for desktop lockfiles in your config dir with, e.g.,

    find ~/.emacs.d/ -name '*lock*'

If there is null response to the 2nd commandline && my hypothesis is correct, you should be able to start Emacs and see your desktop (i.e., all those buffers will be auto-open'ed). Note the preferred way to start both a fresh daemon and client is either

# create a GUI frame
emacsclient --alternate-editor '' --create-frame &


# start a TUI Emacs in current terminal
emacsclient --alternate-editor '' --tty

If there is not a null response to the 2nd commandline--i.e., you get something like

$ find ~/.emacs.d/ -name '*lock*'

in your shell, then delete those lockfiles, e.g.

find ~/.emacs.d/ -name '*lock*' | xargs rm

Then rerun

find ~/.emacs.d/ -name '*lock*'

until you get a null response, then retest my hypothesis. (I.e., start a fresh Emacs--if you see your desktop buffers, I'm correct, else I'm not.)

  • 1
    Hey, thanks for the reply. I ended up abandoning the whole desktops thing. I'll mark as answer. Dec 11, 2017 at 15:27

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.