This is based on Emacs 24.4.1 (KAEL) on Windows 7 from the emacs-w64 project, but should work on other releases of the same major version.
Add this to your .emacs
:
(load "server")
(unless (server-running-p) (server-start))
which will run the server if it's not running; taken from here. If you're using cygwin/msys/msys2 then you could add this to your .bashrc
:
edit_file() {
emacsclient -nqa "runemacs.exe" $1 &
}
alias edit=edit_file
or do the equivalent in a batch script for cmd
. Now all you've to do is
edit 1.txt # will start the server, if it's not running
edit 2.txt # will send a request to the server to open this file
The explanation part is that emacsclient
would run runemacs.exe
if a server is not running; -q
would be to silence it's success message. -n
is to not wait for server to return; if not for -n
, you should clean up the buffer using server-edit
and not the usual kill-buffer
.
One additional point is that, if you want to use emacsclient.exe
from GUI instead of CLI/TUI then use emacsclientw.exe
.
emacsclient.exe
.Chocolatey
, aapt-get
like package management tool for Windows. I use it to install many opensource or free software. There's aemacsclient.exe
too. How do you use it? Emacs doesn't supportdaemon
on Windows.