attaching to Emacs server

I am already using Emacs server for some of the problems described in the documentation, For example, I have (server-start) in my .emacs init file, and I have set the EDITOR env. variable to emacsclient so that git and other programs don't open a new instance of Emacs when they need me to type text or log message. This is working great so far.

I am now wondering if I can use Emacs server for something else: I often launch Emacs remotely through an ssh -X session. Sometimes I need to close the ssh session (eg I need to reboot my local computer) and re-connect. It would be great if instead of fully closing Emacs for this, I could detach from Emacs, and reattach later.

Is this possible with Emacs server? I believe from things I have read online that the answer is yes, but:

My question:

How can I safely detach from an Emacs server and reattach later?


If you directly start Emacs from within the SSH session, you cannot gracefully detach, because the Emacs process becomes part of the process group created by the remote shell, and if the shell exists it will terminate all processes in its process groups.

However, you can start Emacs in Daemon mode first, with emacs --daemon . Emacs will load the configuration, start an edit server (even without an explicit (server-start) in your configuration), and detach from the terminal. This Emacs daemon will stay alive across different SSH session.

Subsequently, only use emacsclient to connect to the running daemon.


emacs --daemon or (server-start) in .emacs .

Next use emacsclient file , emacsclient -n file or emacsclient -c for just an attaching.

To leave attach as usual Cx Cc .

链接地址: http://www.djcxy.com/p/62184.html

上一篇: 错误的类型参数:(或eieio

下一篇: 附加到Emacs服务器