If I spawn Emacs in --daemon mode, I can then use emacsclient to connect to the daemon from within a terminal window. If this then dies, I can reconnect my terminal and my Emacs session is still available.

The only problem with this is that whatever window layout I had previously configured is not preserved. If I'm working on a flakey connection it becomes tedious having to partition up my screen with the window layout I want on each connection drop.

I am aware of commands such as

C-x r f – frame-configuration-to-register
C-x r j – jump-to-register

Which should make it possible to save and reload a frame configuration. Whilst these work fine in normal mode, in daemon mode I find that the results are very unpredictable.

Sometimes it just looses the layout! Also you end up having to remember to save the layout and exit using C-x 5 1 or multiple C-x 5 0, which kills the underlying emacsclient window without killing the underlying daemon.

There must be something better!

Firstly - is the daemon/client layout behaviour buggy, or am I misusing it somehow?

Secondly - Is there a stable way of automatically/seamlessly preserving your window layout between connections to an Emacs daemon?

  • As an alternative, if you run Emacs locally and open files using Tramp, then you won't lose your window layout when the connection dies. I think(?) tramp doesn't require a continuous connection either, so if you lose your connection you might not even notice, as Tramp will reconnect when necessary.
    – Tyler
    Commented Nov 9, 2017 at 16:29
  • Thanks - yes this would work for most people. I didn't mention it in my question, but for security reasons I'm not allowed to use tramp on my local machine. So although I use tramp elsewhere I'm stuck with terminal emacs - at least for now.
    – Phil
    Commented Nov 10, 2017 at 11:11

2 Answers 2


To answer my own question and having tried many ways to achieve the above, I've only found one method that at least so far has proved stable/reliable even when using the daemon.


Or the slightly improved rewrite:



This does not directly address the request to restore emacs layout from within emacs. If you are willing and able to use tmux, then there is a solution.

You can preserve the layout by running emacs inside of a tmux session. If the ssh connection dies, you can reconnect and restore the tmux session. This will restore your emacs instance in the state it was in when the connection died.


  1. ssh to your remote machine
  2. Start tmux
  3. Start emacs within tmux
  4. Disconnect ssh
  5. Reconnect ssh
  6. Execute tmux attach -t 0 from the cli, to restore the existing tmux session

Add an alias in your shell configuration to easily run the tmux attach command, when you reconnect.



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.