systemd启动系统已经在多个Linux版本下运行,Ubuntu、arch等。把emacs(spacemacs)作为系统服务运行可以大幅提高启动速度,改善使用体验。
创设systemd启动服务:
首先我们要新建一个systemd启动文件,可以参考emacs wiki。 文件要放到 ** /etc/systemd/system/emacs@.service**
[Unit]
Description=Emacs: the extensible, self-documenting text editor
[Service]
Type=forking
ExecStart=/usr/bin/emacs --daemon
ExecStop=/usr/bin/emacsclient --eval "(progn (setq kill-emacs-hook 'nil) (kill-emacs))"
Restart=always
User=%i
WorkingDirectory=%h
[Install]
WantedBy=multi-user.target
启动服务
通过systemd我们可以启动、禁止等服务
~$ sudo systemctl enable emacs@lefteris.service
~$ sudo systemctl disable emacs@lefteris.service
~$ sudo systemctl start emacs@lefteris.service
~$ sudo systemctl stop emacs@lefteris.service
~$ systemctl status emacs@lefteris.service
不需要root权限,客户模式下启动
要把emacs.service文件复制到_ ~/.config/systemd/user/emacs.service_
systemctl --user enable emacs
systemctl --user start emacs
systemctl --user stop emacs
systemctl --user disable emacs
客户端启动,启动时窗口最大化
-修改emacs.d文件
(add-to-list 'default-frame-alist '(fullscreen . fullboth))
-使用启动参数(我倾向于)
emacsclient -c -F "'(fullscreen . fullboth)"
emacsclient -c -F "'(fullscreen . maximized)"
alias ecx="emacsclient -c -F \"'(fullscreen . maximized)\""
emacsclient -c -F "((width . 100) (height . 100) (left . 400))"
持久化 Emacs 服务器
在emacs-china中说,直接使用 :
emacs --daemon &
这样就可以满足要求,尝试了下,使用spacemacs "space q q “ 推出后,emacs仍然驻留。
我们可以持久化 Emacs 服务器,在 Emacs 关闭的时候,服务器不被杀掉。只要设置 ~/.spacemacs 中 dotspacemacs-persistent-server 为 t 即可。
参考:
1、 https://emacs-china.org/t/emacs/720 1、[Running emacs as a daemon with systemd]http://blog.refu.co/?p=1296 2、https://medium.com/@bobbypriambodo/blazingly-fast-spacemacs-with-persistent-server-92260f2118b7