i cannot use emacsclient on windows 10. Starting it with the gui client works well but trying to start it in command line mode from a terminal, for example running emacsclient -nw -c is there a correct way to do that?
1 Answer
On Windows there is no terminal version of Emacs, only Gui-versions. So using emacslient.exe
or emacsclientw.exe
is the same thing. The behave slightly different in what they tell you on the command line. emacsclient.exe
starts a CMD console if run from Start menu or explorer. emacsclientw.exe
is a native GUI application that starts as any Windows app.
But you can still start a daemon with multiple client windows. The first client needs to start a server if there is no running already. You do that by adding -a ""
as an option. This tells Emacs to connect to the default server named "". You can start multiple servers with different names if needed. And you need to add -c
to create a new frame, otherwise emacsclient reuse an existing frame. And that is useful if you want to open a file from the command line.
You can add the option --tty
to emacsclient but that don't make any difference. You will get a GUI window anyway.
emacsclient.exe -c -a ""
- or-
emacsclientw.exe -c -a ""
- or -
emacsclient.exe --tty -c -a ""
All above will start a server and a window.
Or you can start the server first, either in background or foreground, and then start the emacsclient. Running a foreground server is good for troubleshooting. And the background is probably wanted when in a stable state.
emacs.exe --fg-daemon
- or -
emacs.exe --bg-daemon
emacsclient.exe -c
emacsclientw.exe -c
So the short answer, emacsclientw.exe -c -a ""
should be the command you are looking for.
To start a new client, use C-x 5 2
, and to close the window, C-x 5 0
. And to exit Emacs, run M-x kill-emacs
to kill all windows and the server.
Hopes this helps.
-
So I was wrong about that there being no terminal version of Emacs on Windows. To my surprise there was if you start with
emacs.exe -nw
. I guess that I used emacsclient.exe for so long and when that stop working I gave up on that. And forgot about it.– sdaaishCommented Feb 25, 2023 at 20:47 -
But it won't help anyway since you can't run an emacsclient in another console than in that the server is running. Described in the documentation, last paragraph. gnu.org/software/emacs/manual/html_node/emacs/… So strictly speaking you can run emacsclient in a terminal, but it's not practical in reality. Emacsclient and server don't support the '-s' option, a named server, so there is likely no way to make this work. Could be wrong, but my tests didn't work as they did with the GUI version.– sdaaishCommented Feb 25, 2023 at 21:00