前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Emacs的Server Client模式

Emacs的Server Client模式

作者头像
ExASIC
发布2022-03-29 14:12:25
9000
发布2022-03-29 14:12:25
举报
文章被收录于专栏:ExASIC

Emacs的server/client模式只需要加载一次配置文件,所以打开文件会快一些。

EmacsClient allows one to open a file for editing in an already running Emacs. Because it doesn’t start a new Emacs instance at each invocation, you can set up EmacsClient as the default editor, e.g. in the environment variable EDITOR or VISUAL.

所以,简单的说就是,emacs client通过tcp/ip链接server,告诉server打开文件。

启动Server端

启动server端命令如下,启动后这个后台命令一直在运行。

代码语言:javascript
复制
emacs -daemon

也可以先打开一个空的emacs,再M-x server-start

启动Client端编辑文件

代码语言:javascript
复制
emacsclient xxx.v

启动时,emacs会与server通信,把文件名传递给server,让server打开文件,再在client编辑。

自动启动Server端

如果Server没有提前运行,client默认会报错。但我们也可以用client的命令行参数来自动启动server。

代码语言:javascript
复制
emacsclient --alternate-editor="" xxx.v
或者
emacsclient -a="" xxx.v

当然,Emacs启动速度慢也可能是你配置文件里要加载的东西太多了,或者有bug,可以用benchmark-init来分析一下。这篇文章写了一些优化的方法,大家可以参考一下:

https://manateelazycat.github.io/emacs/2019/05/12/emacs-optimize-startup-speed.html

参考资料:

https://www.emacswiki.org/emacs/EmacsClient

https://www.gnu.org/software/emacs/manual/html_node/emacs/Emacs-Server.html

本文参与 腾讯云自媒体同步曝光计划,分享自微信公众号。
原始发表:2022-02-03,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 ExASIC 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 启动Server端
  • 启动Client端编辑文件
  • 自动启动Server端
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档