The binary distributions are distributed as zip files, which are handled natively by Windows XP and later. For earlier versions, there are many tools that can handle the zip format, from InfoZip's command line unzip tool, to 7zip's multi-format graphical archive explorer. Although popular, WinZip has caused problems with line-ends in the past, and is not Free software, so we do not recommend it.
Source distributions are distributed as gzipped tar files. 7zip and similar multi-format graphical tools can handle these, or you can get Windows ports of the command line gzip and tar tools from multiple sources. See Other useful ports.
The command to unpack a source distribution from the command line is:
tar xzf emacs-23.3.tar.gz
If this does not work with the versions of tar and gzip that you have, you may need to try a two step process:
gzip -dc emacs-23.3.tar.gz | tar xvf -
You may see many messages from tar complaining about being unable to change the modification time on directories, and from gzip complaining about a broken pipe. These messages are usually harmless, caused by incomplete ports that are not fully aware of the limitations of Windows.
You can run Emacs without any extra steps, but if you want icons in your Start Menu, or for Emacs to detect the image libraries that are already installed on your system as part of GTK, then you should run the program emacs-23.3\bin\addpm.exe.
Emacs has built in support for XBM and PBM/PGM/PPM images. This is sufficient to see the monochrome splash screen and tool-bar icons. Since 22.2, the official precompiled binaries for Windows have bundled libXpm, which is required to display the color versions of those images.
Emacs is compiled to recognize JPEG, PNG, GIF and TIFF images also, but displaying these image types require external DLLs which are not bundled with Emacs. See Other useful ports.
When Emacs starts up, it attempts to load and execute the contents of a file commonly called .emacs (though it may have other names, see Where do I put my init file?) which contains any customizations you have made. You can manually add lisp code to your .emacs, or you can use the Customization interface accessible from the Options menu. If the file does not exist, Emacs will start with the default settings.
On Windows, the .emacs file may be called _emacs for backward compatibility with DOS and FAT filesystems where filenames could not start with a dot. Some users prefer to continue using such a name, because Explorer cannot create a file with a name starting with a dot, even though the filesystem and most other programs can handle it. In Emacs 22 and later, the init file may also be called .emacs.d/init.el. Many of the other files that are created by lisp packages are now stored in the .emacs.d directory too, so this keeps all your Emacs related files in one place.
All the files mentioned above should go in your HOME directory. The HOME directory is determined by following the steps below:
HKCU\SOFTWARE\GNU\Emacs\HOME
is set, use the
directory it indicates.
HKLM\SOFTWARE\GNU\Emacs\HOME
is set, use the
directory it indicates. Not recommended, as it results in users sharing
the same HOME directory.
Within Emacs, <~> at the beginning of a file name is expanded to your HOME directory, so you can always find your .emacs file with C-x C-f ~/.emacs.
If you've set HOME to a directory using one of the above methods, and Emacs still doesn't load your init file, the first thing you should do is check to see what Emacs thinks HOME is set to. You can do this by evaluating the following expression in the *scratch* buffer using C-x C-e:
(insert (getenv "HOME"))
Look carefully at what is printed and make sure the value is valid. For example, if the value has trailing whitespace, Emacs won't be able to find the directory. Also, be sure that the value isn't a relative drive letter (e.g., d: without a backslash); if it is, then HOME is going to be whatever the current directory on that drive is, which is likely not what you want to happen.
The recommended way to associate files is to associate them with emacsclientw.exe. In order for this to work when Emacs is not yet started, you will also need to set the environment variable ALTERNATE_EDITOR to runemacs.exe. To open files in a running instance of Emacs, you will need to add the following to your init file:
(server-start)
You can use Emacs as the editor for composing mail for
<mailto:
> links, reading usenet for <news:
>
links, and viewing source. The following registry entries control
this:
Thanks to Jason Rumney and Sigbjorn Finne for these tips.
The location of the Desktop varies between different versions of Windows, and in a corporate environment can be moved around by the network administrator. On NT derivatives, you can use the value of the USERPROFILE environment variable to find where the desktop might be:
C-x C-f $USERPROFILE/Desktop
If this doesn't work, then you probably have to forgo the keyboard just this once, and either drag a file onto the Emacs frame from the desktop, or use the file dialog (displayed when you use the toolbar or menu by default). Once you have a file from the Desktop inside Emacs, C-x C-f will quickly reveal where your desktop is kept.
Customize the variables focus-follows-mouse
and
mouse-autoselect-window
. The former can be used to mislead
Emacs into giving focus to other frames when the mouse is over them,
even though Windows has a click to focus policy by default (there is
software available to change that though). The latter can be used to
make Emacs use a focus-follow-mouse policy within its own frames.
This cannot be done within Emacs, but you can modify the scan code mappings in the registry or define a new keyboard layout to swap the keys on a system wide basis.
Microsoft has a tool called keyremap that is part of their Kernel Toys add ons for Windows 95. The tool has also been confirmed to work on Windows 98.
Many beginning users find Emacs difficult to use because its user interface is different in many ways. Emacs predates most UI standards, and experienced Emacs users are used to the way things are, so changing the defaults is difficult. Most of the “standard” behavior can be approximated in Emacs after some configuring though.
Emacs has a concept of a mark and point that is similar to selections in other programs. But the mark in Emacs is used for more than just defining the selected region, it lives on while you continue to edit and move around the buffer so it can also be a kind of bookmark. The history of marks is saved so you can pop previous marks back to the top of the stack to go back to somewhere you were some time ago. Because of this dual purpose, the region between mark and point is not highlighted by default unless you select a region by clicking and dragging the mouse.
The minor mode transient-mark-mode
changes the behavior of
the mark in two ways. First, it distinguishes between an active mark
that has just been defined or reactivated, and an inactive mark. When
the mark is active, some commands that normally act on lines, words,
buffers etc. will instead act on the region. An inactive mark needs
to be reactivated to operate on it, unless mark-even-if-inactive
is set. Secondly, transient-mark-mode
also highlights the
region when it is active, providing the same visual clue that you get
in other programs.
In addition to seeing the highlighting, new Emacs users often expect
editing commands to replace the region when it is active. This behavior
can be obtained with delete-selection-mode
, but see the following
question also.
The keybindings of Emacs predate modern GUIs, and the keys that were
chosen by later GUIs for cut and copy were given important functions
as extended keymaps in Emacs. CUA mode attempts to let both bindings
co-exist by defining C-x and C-c as kill-region
and
copy-region-as-kill
when the region is active, and letting
them have their normal Emacs bindings when the region is not active.
Many people find this to be an acceptable compromise. CUA mode also
defines a number of other keys (C-v, Shift selection), and can be turned
on from the Options menu.
The function w32-send-sys-command
can be used to simulate
choosing commands from the system menu (in the top left corner of the
Window) and a few other system wide functions. It takes an integer
argument, the value of which should be a valid WM_SYSCOMMAND
message as documented in Microsoft's API documentation.
Emacs does not come with an uninstall program. No files are installed
outside of the Emacs base directory, so deleting that directory is
sufficient to clean away the files. If you ran addpm,
you'll need to delete the Start Menu group too. The registry entries
inserted by addpm will not cause any problems if you leave
them there, but for the sake of completeness, you can use regedit
to remove the keys under HKEY_LOCAL_MACHINE
orx
HKEY_CURRENT_USER
: SOFTWARE\GNU\Emacs
, and the key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\emacs.exe
if it exists.
Emacs could have failed to run for a number of reasons. The most common symptom is that, when Emacs is started, the cursor changes for a second but nothing happens. If this happens to you, it is quite likely that the distribution was unpacked incorrectly.
Check for the following to see if there was a problem during unpacking:
If it is still not working, send mail to the list, describing what you've done, and what you are seeing. (The more information you send the more likely it is that you'll receive a helpful response..
There have been reports in the past that some virus scanners claim that the Emacs distribution has a virus. This is extremely unlikely if you have downloaded Emacs from the GNU FTP site or one of its mirrors and the GPG signature for it is valid and listed in the GNU keyring, unless perhaps it is a new release made in the last few days, in which case you should exercise more caution and report the problem. Past problems seem to have been caused by virus checkers running into a buffer size limit when unpacking large tar.gz files for scanning, and reporting the failure as an “unknown virus”.
Anti-virus and firewall software can block Emacs from starting subprocesses and opening network connections. Most such products have an Advanced mode where they will prompt you rather than silently blocking. In some cases the “scan all files” or “auto protect” option of anti-virus programs has caused failures running shell related commands within Emacs. See Why is nothing happening when I enter shell commands?.