Forrest logo
back to the emacsclient tool

emacsclient:tldr:e488f

emacsclient: Stop a running Emacs server and all its instances, asking for confirmation on unsaved files.
$ emacsclient --eval '(save-buffers-kill-emacs)'
try on your machine

The command emacsclient --eval '(save-buffers-kill-emacs)' is used to send an Emacs Lisp expression to an already running Emacs session and executes it. Let's break it down:

  1. emacsclient: This is the command-line program used to interact with a running Emacs instance. It is typically used as a way to open files in an already running Emacs session.

  2. --eval: It is an argument to the emacsclient command that tells it to evaluate and execute the given Emacs Lisp expression.

  3. '(save-buffers-kill-emacs)': This is the Emacs Lisp expression that will be evaluated by the running Emacs session. In this case, it is calling the save-buffers-kill-emacs function, which will prompt Emacs to save all modified buffers and then exit Emacs.

So, when you run emacsclient --eval '(save-buffers-kill-emacs)' in the terminal, it will send the expression (save-buffers-kill-emacs) to the running Emacs session, which will then save all modified buffers and close Emacs.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the emacsclient tool