Today I decided to give Emacs another go. I was quite decided to stick with Vim, until I ran into a few XML formatting issues. The XML support is a bit limited and unfortunately it's not the only one on the list. I still think it's a great editor and knowing a few shortcuts always saves the day - and it's also deployed by default on all Unix like machines.
Emacs does have a few limitations too - in fact, they were probably the reason why I gave up to it a few times in the past. Lack of real word wrapping and a very complicated mechanism for using character encodings are my main annoyings - but hopefully I'll overcome them - somehow.
The first one on the list, is the installation on a Windows machine. I won't describe why it has to work on a Windows machine, since we don't live in a perfect world and things should work as they are.
First, let's get the binaries from the official site. We don't want to complicate our lives more than necessarily, so let's pick the precompiled distribution.
The second step is quite obvious - extract the zip file somewhere on the filesystem.
Now we should be able to start up Emacs by running runemacs. I highligy recommend adding the Emacs bin directory to the system PATH. In addition, the following environment variables should also be set:
HOME
This one is inherited from the Unix system, where it points to the "home" folder of the current user. On a Windows machine, this is a bit different - though judging from the current trends, it could be "C:\Documents and Settings\USERNAME" (or "C:\Users\USERNAME" for Vista). It doesn't really matter what folder you use, but keep in mind that other software designed for Unix systems might pick this setting up and use it as a default save location.ALTERNATE_EDITOR
You should set this to "runemacs.exe". The value defined here will be picked by theemacsclientutility. Failing to set this variable will cause "emacsclientw" to report the error: "No socket or alternate editor."EMACS_SERVER_FILE
Another setting required by theemacsclientutility. By default, it should point to%HOME%/.emacs/server- the location where the server file resides (this file is used to detected the Emacs server running in the background).
It is recommended to define these environment variables per user. On Windows Vista, you can do something like this:
setx ALTERNATE_EDITOR runemacs setx EMACS_SERVER_FILE ...
You can open files in Emacs in two modes:
- open a new instance of Emacs for each file
- open a single Emacs instance with multiple buffers (or windows)
I prefer the second approach, since it's faster and allows you to use Emacs in a more compact mode (without too much interference with the operating system). In order to use this mode, you need to start emacs with "emacsclientw.exe filename". This will check if there is an Emacs instance running in the background and it will use it. Otherwise it will just open a new instance.
You should have a functional Emacs installation by now. Unfortunately I still get the following error when starting up Emacs for the first time (with no server running): "connect: No connection could be made because the target machine actively refused it." It looks like Emacs is not removing the server file when the server shuts down. Because of this, future instances will attempt to connect to the host and port defined in this file - but nobody will listen there. Besides the annoying popup error message, there don't seem to be any other implications.