emacs如何启动_使Emacs启动更快

emacs如何启动

I use Emacs in terminals and start/close Emacs frequently as needed like in a file checking-editing-closing loop. However, Emacs seems take some time to start up especially some heavy modes are used. How to make Emacs start up faster?

我在终端中使用Emacs,并根据需要像文件检查-编辑-关闭循环中那样频繁启动 / close Emacs。 但是,Emacs似乎需要一些时间才能启动,尤其是使用了一些繁重的模式。 如何使Emacs更快启动?

(If you just want the solution/script first, find the command in the summary section.)

(如果只想首先使用解决方案/脚本,请在“ 摘要”部分中找到该命令。)

我的解决办法是使用的Emacs的服务器/客户端功能 (My solution is to make use of the server/client feature of Emacs )

This is how it works.

这就是它的工作方式。

Emacs supports server/client architecture which is the key mechanism for faster Emacs startup here. Starting the server once and it is acceptable if it takes some time. When editing a file, start an Emacs client to connect to the server to edit the file, which is fast.

Emacs支持服务器/客户端体系结构 ,这是此处Emacs更快启动的关键机制。 启动服务器一次,如果需要一些时间,则可以接受。 编辑文件时,启动Emacs客户端以连接到服务器以编辑文件,这非常快。

However, several other tunnings/scripts are need to make it more handy.

但是,还需要其他一些调音/脚本来使其更方便。

如何以及何时启动Emacs服务器? (How and when to start the Emacs server? )

Invoking it at the startup of the desktop environment as a autostart script?—What if the server is killed? What if you are working on a remote server? Manually start it?—It will too annoying.

在桌面环境启动时作为自动启动脚本调用它吗?-如果服务器被杀死怎么办? 如果您正在使用远程服务器怎么办? 手动启动它?—太烦人了。

Either choice is not good enough. On the other hand, the emacsclient‘s -a option has a very nice feature: “If the value of EDITOR is the empty string, run emacs --daemon to start Emacs in daemon mode, and try to connect to it”. So, with the -a="" option in the command, the first time the emacsclient is invoked and there is no server running, the Emacs server is automatically started.

两种选择都不够好。 另一方面, emacsclient-a选项具有一个非常好的功能 :“如果EDITOR的值为空字符串,请运行emacs --daemon以守护程序模式启动Emacs,并尝试连接到它”。 因此,使用命令中的-a=""选项,第一次调用emacsclient且没有运行服务器时,将自动启动Emacs服务器。

每次调用emacsclient后,是否应该始终切换到服务器实例? (After each invoking of the emacsclient, should I always switch to the server instance? )

Not needed. Emacs support the convenient “multiple tty” feature. With the -c option, emacsclient starts a new frame just at the terminal or console where it is invoked: “-c, –create-frame create a new frame instead of trying to use the current Emacs frame”.

没有必要。 Emacs支持便捷的“多个tty”功能。 使用-c选项, emacsclient在调用它的终端或控制台上启动一个新框架:“-c,–create-frame创建一个新框架,而不是尝试使用当前的Emacs框架”。

如何手动关闭Emacs服务器? (How to manually shutdown the Emacs server? )

Simply killing the Emacs is not safe—some files may have been changed and not saved yet. Let’s use an elisp function to save the buffers and kill the emacs in the ~/.emacs:

简单地杀死Emacs并不安全-某些文件可能已更改且尚未保存。 让我们使用elisp函数保存缓冲区并杀死~/.emacs的emacs:

;; define function to shutdown emacs server instance
(defun server-shutdown ()
  "Save buffers, Quit, and Shutdown (kill) server"
  (interactive)
  (save-some-buffers)
  (kill-emacs))

When you want to kill the emacs server, run emacsclient -e '(server-shutdown)' which can be put into a command file like em-server-shutdown.

当您想杀死emacs服务器时,运行emacsclient -e '(server-shutdown)'可以将其放入命令文件,例如em-server-shutdown

总之,命令 (In summary, the command )

The key is this command: emacsclient -c -a="" $*. For faster invoking, save it as a executable command, like em, in some directory in your $PATH:

关键是以下命令: emacsclient -c -a="" $* 。 为了更快地调用,请将其另存为$PATH中某个目录中的可执行命令,例如em

#!/bin/env bash
emacsclient -c -a="" $*

When you want to edit a file, simply run em file.

当您要编辑文件时,只需运行em file

All the functions/scripts can be found in my Emacs config.

所有功能/脚本都可以在我的Emacs config中找到。

翻译自: https://www.systutorials.com/making-emacs-startup-faster/

emacs如何启动

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值