A script to runs emacs(1) and/or emacsclient(1) as appropriate per given command-line arguments.
Shell Makefile Roff Ruby M4
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
contrib
.gitignore
AUTHORS
COPYING
ChangeLog
FAQ
FAQ.md
INSTALL
Makefile.am
Makefile.in
NEWS
README
README.md
TODO
aclocal.m4
autogen.sh
configure
configure.ac
depcomp
em.1
em.in
install-sh
missing

README.md

Em, CLI front end for Emacs and emacsclient

The em script runs emacs(1) and/or emacsclient(1) as appropriate per given command-line arguments. For interactive sessions, emacs(1) is started in daemon mode as necessary prior to running emacsclient(1).

Invoking em with multiple FILE arguments opens, by default, FILEs in the top-most frame either sequentially, via the server-edit (C-x #) command, or randomly, via switch-to-buffer (C-x b).

In addition to command-line options from either emacs(1) or emacsclient(1), the following options are recognized:

OPTION DESCRIPTION
--buffer[=BUF] Visit buffer BUF if given, otherwise *scratch*.
--dired[=DIR] Visit directory DIR if given, otherwise ..
--markdown, -md=FILE Visit FILE in mode markdown-live-preview-mode.
--new-frame Visit FILEs in a new frame.
--preload-files Load FILEs in parallel, but visit one at a time.
--many-frames Visit FILEs in parallel, each in its own frame.
--save-kill Save buffers and kill Emacs and Emacs server.
--super-user Visit FILEs with root privileges via tramp.
--trace Trace execution of em script.
--two-way-merge=F1,F2[,OUT] Call emerge-files with file args F1 and F2.
--update-loaddefs[=DIR] Build autoload file DIR-loaddefs.el.
--wait Run emacsclient(1) in foreground.

Options may be abbreviated (e.g., -new instead of --new-frame) provided they are unambiguous.

If em is invoked with either no command-line options or emacsclient options only, then it runs as a background process and switches focus to the Emacs server. Otherwise, Emacs-specific command-line options (see emacs --help) force a new Emacs process to be run in the foreground, allowing this script to be invoked, e.g., in batch mode within a Makefile.

If the environment variable SSH_TTY is set and the SSH client and server differ, then the command-line option--tty is enabled by default.

Similarly, if environment variable SUDO_USER is set and not equal to USER, then command-line option --tty is enabled by default. Rather than override this behavior, generally a better solution is to use tramp mode. For example, if not logged in as user root, to edit file /etc/hosts, use em -su /etc/hosts.

To kill the Emacs server, use em --save-kill, which can be shortened to em -sa.

See also FAQ for troubleshooting.