Tracking Emacs development is always nice, because I get to explore new things as soon as they are made available. Yesterday Lars Ingebrigtsen introduced a new command: restart-emacs.

Let’s C-h f restart-emacs RET to check what we are dealing with:

Kill the current Emacs process and start a new one. This goes through the same shutdown procedure as ‘save-buffers-kill-emacs’, but instead of killing Emacs and exiting, it re-executes Emacs (using the same command line arguments as the running Emacs).

It sounds useful, doesn’t it? So I quickly devised a new command to let me decide whether I want to quit Emacs or re-launch it:

(defun mu-quit-or-restart (&optional restart)
  "Quit Emacs or restart it with RESTART."
  (interactive "P")
  (if restart
    (save-buffers-kill-terminal t)))
(keymap-global-set "C-x C-c" #'mu-quit-or-restart)

This little command should be obvious: C-x C-c does the usually killing, whereas C-u C-x C-c re-executes Emacs. This will come in handy when I upgrade packages, because I tend to restart Emacs after that and being able to do it quickly is a great thing indeed.

Note that keymap-global-set may not be available if you are not following the Emacs master branch. Rely on global-set-key in that case.