Using Emacs as a server

转载 2011年10月13日 22:17:22
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.

用 emacsclient 来连接 emacs server

用 emacsclient 来连接 emacs server这个方法首先要有一个启动好了的 Emacs ,并且要已经启动了 server 模式,你可以用 M-x server-start 来启动 se...
  • lvhongya
  • lvhongya
  • 2011年07月16日 20:39
  • 2580

Eclipse配置Tomcat:Cannot create a server using the selected type

前言 Eclipse配置Tomcat过程: 打开Eclipse,点击菜单栏中的windows中的Preferences配置属性 然后选择server中的runtime Environments,添加所...
  • zhaokx3
  • zhaokx3
  • 2016年11月16日 14:04
  • 860

Cannot create a server using the selected type (Eclipse中新建一个服务器)

昨天重装了系统,今天要把各种软件重新安装和配置。在Eclipse中新建一个Tomcat服务器的时候报错, Cannot create a server using the selected type...
  • zhouyingge1104
  • zhouyingge1104
  • 2012年08月26日 17:11
  • 7172


emacs快速启动的目标 emacs因为插件太多,启动速度慢。使用emacsclient,实现快速启动emacs; emacs的buffer管理特别方便,特别是spacemacs。打开的文件,最好不要...
  • u011729865
  • u011729865
  • 2016年09月22日 20:45
  • 941

emacs使用本地emacs server模式打开远程文件

使用emacs的用户都知道,一般要打开远程机器上的文件要使用TrampMode模式,调用方式如下: C-x C-f /remotehost:filename RET (or /method:use...
  • loveaborn
  • loveaborn
  • 2014年05月11日 14:50
  • 6172

Windows - "Multiple connections to a server or shared resource by the same user..."

After created a new smb share directories in Ubuntu and trying to access in Windows, it complains as...
  • 2013年01月09日 14:58
  • 2819

Tomcat --> Cannot create a server using the selected type(Eclipse添加tomcat 6失败)

Tomcat --> Cannot create a server using the selected type(Eclipse添加tomcat 6失败)
  • zhangjq520
  • zhangjq520
  • 2017年06月30日 17:22
  • 198


error in process sentinel: Can't read anaconda-mode server response  或是类似的问题(Can't start anaconda...
  • gniuk
  • gniuk
  • 2015年09月18日 17:45
  • 2263

116.Your database instance is started using the server parameter file (SPFILE). You executed a comma

116.Your database instance is started using the server parameter file (SPFILE). You executed a comma...
  • dwj19830118
  • dwj19830118
  • 2016年08月01日 23:27
  • 419

执行server-start时emacs报错说“The directory `~/.emacs.d/server' is unsafe”

  • lujun9972
  • lujun9972
  • 2015年05月26日 07:37
  • 755
您举报文章:Using Emacs as a server