This is a simple package to restart Emacs for within Emacs. Inspired by this stackoverflow question.
restart-emacs
is available on MELPA and MELPA Stable. Please follow the instructions on
MELPA website to enable it, if you haven’t already.
You can then install restart-emacs
from the package menu. Alternatively install it by doing the following
Refresh the package index
M-x package-refresh-contents RET
And then install it by doing
M-x package-install RET restart-emacs
restart-emacs
can also be installed using el-get
. Assuming you have latest version of el-get installing it by doing something similar to
M-x el-get-install RET restart-emacs
It offers a command restart-emacs
which kills current Emacs session
and starts a new session.
Additional arguments to be passed to the new instance can be specified using prefix arguments
- with a single
universal-argument
(C-u
) Emacs is restarted with--debug-init
flag - with two
universal-argument
(C-u
C-u
) Emacs is restarted with-Q
flag - with three
universal-argument
(C-u
C-u
C-u
) the user is prompted for the arguments
restart-emacs
can restore frames on restart, right this is experimental and
disabled by default to enable it set restart-emacs-restore-frames
to t
.
There is also a second command restart-emacs-start-new-emacs
which starts a
new session of Emacs without killing the current one. It takes the same arguments
as restart-emacs
.
Restarting graphical Emacs should work on any UNIXy system with sh
and on
Windows.
This requires that the shell from which Emacs was launched supports job
control. This has been tested to work on sh
, bash
, zsh
, fish
, csh
and tcsh
, however this does not work on Windows.
The latest version of restart-emacs
can now restart Emacs daemons. The the
frames are restored once the daemon restarts using desktop-mode
. However
since desktop-mode
learned to restore frames only Emacs version 24.4
onwards the daemons can be restarted only on Emacs versions 24.4 and later.
Another issue with restarting Emacs daemons is that the frames open in a
terminal cannot be recreated on restart, instead the restart-emacs
would
write a notification on the terminal with the instructions to reconnect, any
suggestions to improve this are welcome.
Code as well as documentation contributions are welcome.
Cask is used to manage project dependencies so make sure you have it installed. To run the tests you need to install the dependencies by running the following
cask install
After the installation completes you can run the tests by running the following command
cask exec ert-runner
The new Emacs instance does not use the same command line arguments as the running instance. See #11 for more details
See #10 (comment)