Emacs Server: GUI or Terminal?
Emacs can also be run as a server, with some advantages: editing sessions open faster and all edits take place in the same instance.
There are different ways to start an Emacs server.
From Emacs, with
M-x server-start or by putting the following code
in the init file (e.g.,
(require 'server) (unless (server-running-p) (server-start))
From the command line:
By enabling the
emacs service, on systems with
systemctl --user enable --now emacs
Once a server is started, Emacs sits in memory, ready to open with the
emacsclient. The interesting part, at least for me, is that
emacsclient can open editing session in a terminal or in a GUI window.
Open Emacs in a terminal with:
-c option to open Emacs as a GUI window:
Emacs can thus serve multiple editing sessions at the same time, some in terminals and others as GUI:
emacsclient -c . & emacsclient -t .emacs &
The buffers are shared among all the instances, that is, a file opened in a GUI instance can be accessed from another instance opened in a terminal. Supercool.