The new Emacs process doesn't share buffers, a command history, orother kinds of information with any existing Emacs process. You cansolve this problem by setting up Emacs as an edit server, so that it"listens" for external edit requests and acts accordingly.
There are two ways to start an Emacs server. The first is to run the command server-start in an existing Emacs process:either type M-x server-start, or put the expression (server-start) in your initialization file. The existing Emacs process is the server; when you exit Emacs, the server dies with the Emacs process. The second way to start an Emacs server is to run Emacs as a daemon, using the '--daemon' command-line option.
Oncean Emacs server is set up, you can use a shell command called emacsclient to connect to the existing Emacs process and tell it to
visita file. If you set the EDITOR environment variable to 'emacsclient',programs such as mail will use the existing Emacs process for editting.
Youcan run multiple Emacs servers on the same machine by giving each onea unique "server name", using the variable server-name. For example, M-x set-variable RET server-name RET foo RET sets the server name to 'foo'. The emacsclient program can specify a server by name, using the '-s' option.
1. Invoking emacsclient
The simplest way to use the emacsclient program is to run the shell command ' emacsclient file', where file is a file name.
Ifthere is no Emacs server, the emacsclient program halts with an errormessage. If the Emacs process has no existing frame---which can happenif it was started as a daemon---then Emacs opens a frame on theterminal in which you called emacsclient. You can also forceemacsclient to open a new frame on a graphical display, or on atext-only terminal, using the '-c' or '-t' options.
When you finish editing file in the Emacs server, type C-x #(server-edit) in its buffer. This saves the file and sends a message back to the
emacsclient program, telling it to exit.
EachC-x # checks for other pending external requests to edit various files,and selects the next such file. You can switch to a server buffermanually if you wish; you don't have to arrive at it with C-x #. ButC-x # is the way to tell emacsclient that you are finished.
NOTE: This article comes from GNU Emacs Manual.
There are two ways to start an Emacs server. The first is to run the command server-start in an existing Emacs process:either type M-x server-start, or put the expression (server-start) in your initialization file. The existing Emacs process is the server; when you exit Emacs, the server dies with the Emacs process. The second way to start an Emacs server is to run Emacs as a daemon, using the '--daemon' command-line option.
Oncean Emacs server is set up, you can use a shell command called emacsclient to connect to the existing Emacs process and tell it to
visita file. If you set the EDITOR environment variable to 'emacsclient',programs such as mail will use the existing Emacs process for editting.
Youcan run multiple Emacs servers on the same machine by giving each onea unique "server name", using the variable server-name. For example, M-x set-variable RET server-name RET foo RET sets the server name to 'foo'. The emacsclient program can specify a server by name, using the '-s' option.
1. Invoking emacsclient
The simplest way to use the emacsclient program is to run the shell command ' emacsclient file', where file is a file name.
Ifthere is no Emacs server, the emacsclient program halts with an errormessage. If the Emacs process has no existing frame---which can happenif it was started as a daemon---then Emacs opens a frame on theterminal in which you called emacsclient. You can also forceemacsclient to open a new frame on a graphical display, or on atext-only terminal, using the '-c' or '-t' options.
When you finish editing file in the Emacs server, type C-x #(server-edit) in its buffer. This saves the file and sends a message back to the
emacsclient program, telling it to exit.
EachC-x # checks for other pending external requests to edit various files,and selects the next such file. You can switch to a server buffermanually if you wish; you don't have to arrive at it with C-x #. ButC-x # is the way to tell emacsclient that you are finished.
NOTE: This article comes from GNU Emacs Manual.