Fixing Emacs on Windows
If you know me, you'll know I'm a big fan of GNU Emacs. To this day I've never managed to find a better "power user" editor. That being said there isn't any good guidance on how to install it on Windows in a way that integrates well with the OS. I'll explain how to remedy that here.
Installation
So if you download and install Emacs for Windows you'll notice there are multiple binaries that all seemingly do the same thing... run Emacs. You can get by just fine using runemacs.exe, but if you make that your default editor, you'll notice it opens up a new instance for every single file. Not only is this slow but it's extremely annoying having a billion Emacs windows floating around.
Running Emacs as a daemon
Enter the Emacs client/server system. You can set up Emacs to run in the background and spawn new client instances when needed. Most Windows programs implement this kind of behavior out of the box, but Emacs doesn't. So here's how you do it.
Making a daemon/server shortcut
- Go to your Emacs installation directory (C:\Program Files\Emacs\emacs-{VERSION}\bin) and make a shortcut for runemacs.exe.
- Right click the shortcut, go to "Properties", and append " --daemon" to the target.
- Put the shortcut in your Startup folder (C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup)
Using Emacs as your default editor
Next time you need to open a file via Explorer, when prompted to select an application in the "Open with..." menu, select "emacsclientw.exe" from your Emacs installation directory.
It's a lot more effort than it should be (it'd be great if emacsclientw.exe just started the daemon automatically...), but after doing these two things Emacs will behave like any other text editor.
Configuring Emacs
Another thing that caught me off guard when using Emacs on Windows is that the config files aren't in your home directory (at least not directly). You can find them in %APPDATA%\.emacs.d\. If you want a good init.el to use, try mine!
Last updated June 24th, 2023 at 05:51 PM CST