systemctl 调用 emacs 服务器

systemctl invoke an emacs server

阅读 Emacs Server - GNU Emacs Manual,
它说明了调用 emacs 服务器的 3 种方法,

  1. 在 运行 框架内输入 M-x server-start
  2. emacs --daemon

第三个

If your operating system uses systemd to manage startup, you can automatically start Emacs in daemon mode when you login using the supplied systemd unit file. To activate this:
systemctl --user enable emacs

(If your Emacs was installed into a non-standard location, you may need to copy the emacs.service file to a standard directory such as ~/.config/systemd/user/.)

emacs 是标准目录

$ which emacs
/usr/bin/emacs

运行

$ systemctl --user enable emacs
Created symlink /home/me.config/systemd/user/default.target.wants/emacs.service → /usr/lib/systemd/user/emacs.service.

经过以上操作

检查没有服务器运行
 ps -ef |grep emacs | sed "s/$USER/me/g"
me   32251  3018  0 19:21 pts/2    00:00:00 grep --color=auto emacs

运行 ystemctl --user enable emacs 多次,但没有找到服务器 运行 .

启动一个 emacs 实例

$ ps -ef |grep emacs | sed "s/$USER/me/g"
me   32336  3018 47 19:22 pts/2    00:00:03 emacs
me   32379  3018  0 19:22 pts/2    00:00:00 grep --color=auto emacs

仍然找不到服务器 运行。

我使用 systemctl 有什么问题?

systemctl enable不启动任何东西,它只是为未来配置东西, 如 systemctl manpage:

中所述

Enabling units should not be confused with starting (activating) units, as done by the start command. Enabling and starting units is orthogonal: units may be enabled without being started and started without being enabled. Enabling simply hooks the unit into various suggested places (for example, so that the unit is automatically started on boot or when a particular kind of hardware is plugged in). Starting actually spawns the daemon process (in case of service units), or binds the socket (in case of socket units), and so on.

要真正启动守护进程现在而不是在下次登录时:

combine this command with the --now switch, or invoke start with appropriate arguments later.