Bear - This is here for your joy

EmacsW32 - Adjustments for Emacs on MS Windows

Version 1.55 2007-06-17

For latest info, downloading etc, see the home page at http://ourcomments.org/Emacs/EmacsW32.html
See also the wiki page at http://www.emacswiki.org/cgi-bin/wiki/EmacsW32.

On THIS Page:

This version is for Emacs 22. If you are using Emacs 21.3 then look for EmacsW32 version 0.92.

Introduction

EmacsW32 tries to make it easier for an MS Windows user to get used to Emacs. (W32 is Emacs' abbreviation for MS Windows.)

EmacsW32 was written primarily for MS Windows, but parts of it (see the list of packages) can be used on other platforms too.

You may wonder if there is any reason to use Emacs on MS Windows, is it not an editor for GNU/Linux? The answer is yes, it is a very good editor for GNU/Linux - and for a lot of other operating systems too. And maybe, some day you will be using GNU/Linux?

Please notice that EmacsW32 is essentially a combination of some good packages already made available. What it offers is trying to bring all these enhancement together in a simple fashion.

Using Emacs On MS Windows

If you use plain Emacs on MS Windows you will soon notice that it does not really behave as other MS Windows applications. You can not access the menus from the keyboard with Alt+letter. The CUA keys (C-c, C-x, C-v and C-z) whichs works in nearly all applications does not work. A networked printer may not work. And even if you happen to get used to those anomalities there are still problems because Emacs uses some external utilities that are not there on MS Windows (to begin with).

EmacsW32 Helps

You may want the power of Emacs. You may wish to learn Emacs because it is available on GNU/Linux too. Seems good to prepare for a move. Still you may get desperate over all this trouble and just give it up. But don't panic, EmacsW32 will help you with part of it. CUA keys can work. (You can also use vi keys, even together with CUA keys!) And to make it easier to get started some of the most commonly used unix utility programs are already included in EmacsW32. (If you want more see Unix Utilities for Emacs on MS Windows.) The ftp program that comes with MS Windows does not behave as Emacs expects. Therefore EmacsW32 includes a more unix-like ftp program!

By default you can not access the menus with Alt+letter as 508 requires, but with the patched version of Emacs that you can get together with EmacsW32 you can do that too (even with StickyKeys on which is otherwise a problem in current Emacs on MS Windows).

Another problem is line endings. On MS Windows this is normally CR-LF while it on unix-like operating systems (like GNU/Linux) is only LF. Some files on MS Windows needs CR-LF while other files (like XHTML files for example) can use just LF instead. Using just LF instead makes it a bit easier to transfer those files to other operating systems. Emacs has good support for changing line endings and some support for telling which files should or can have LF line endings. EmacsW32 extends the latter a little bit.

Using the Keyboard in Emacs

Emacs uses a lot of keyboard commands. It combines control, meta and shift to make it easy to access a lot of often used commands. (Meta is by default Alt - that is why you can not access the menus with Alt+letter.) That takes some time to get used to, but you can do a lot without learning them because the CUA keys can be used in Emacs. (Or, if you are used to vi its keyboard keys can be used too.)

Accessibility Feature StickyKeys can Help You

StickyKeys is a feature on MS Windows for people with a disability that makes it hard to type key combinations. It is actually mentioned in 508 requirements for making information technology accessible to people with disabilities. StickyKeys is a feature of MS Windows that works also in Emacs.

StickyKeys can be a great help for anyone using Emacs on MS Windows. Some key combinations can be very hard to type, especially on a national keyboard. If you use StickyKeys you can (but does not have too) type the keys one by one and that makes it much simpler. As a positive side effect this may perhaps also help saving your hands from problems.

For more information about StickyKeys see StickyKeys on MS Windows. See also GNOME User Interface Guidelines to learn about how this works in GNOME on GNU/Linux.

AltGr+Control - Is That Possible?

Emacs uses some keys that are a combination of AltGr+Control. Those keys might seem impossible to type on MS Windows since you might have heard that AltGr is the same as Alt+Control. The truth is that AltGr is the same as Alt+Left Control. You can still use the AltGr+Right Control.

Important: You must type Right Control before AltGr ! Normally the order between shift, control etc does not matter, but here they do. (Previously it was the other way round, AltGr before Right Control, but something seems to have changed now (2006-12-17).

Getting Started with Emacs+EmacsW32

Installing and Setting Up Emacs+EmacsW32

Please see EmacsW32 Install Wizard for how to get and install Emacs+EmacsW32. Please observe that you need not start emacs server in any of the startup files for Emacs (unless you are using the unpatched version of Emacs)! Instead Emacs and emacs server will be started automatically when you start emacsclient.

Important: At the end of installation you must activate the EmacsW32 specific options inside Emacs to take advantage of them. Or, after installation start Emacs and in the menus choose Options - Customize EmacsW32.

Determine Which Emacs to Start

If you want to switch to another version of Emacs run the file usethis.exe in the Emacs bin directory and restart Emacs. This will tell emacsclient to use that version of Emacs.

Since none of the startup files should start emacs server you can run a second copy of Emacs without problems if you want to for some reason. Just use emacs.exe then.

Opening Files from outside Emacs

To start Emacs and edit a file you can use the various shortcuts created at the installation, for example the Send To shortcut in Explorer. There is also a file e.cmd that you can copy to your path for open files from the command line. Note that this calls emacsclient.exe, not emacs. So you can not use the command line switches for emacs.exe, but you can use those for emacsclinet.exe instead. (Emacs default installation adds a Start menu entry called GNU Emacs. You should not use this if you are using EmacsW32 and the patched version of Emacs.)

When Emacs is started you can of course open files from within Emacs. If you do not want to start Emacs by opening a file as above you can use the shortcuts that just starts Emacs or e.cmd.

During the installation you also have the choice to associate files with Emacs (or really emacsclient).

Emacs is an Edit Server

The shortcuts and e.cmd will only start one copy of Emacs for you. If you try to open a file that you are already editing Emacs will only switch to the buffer containting that file.

If you want to use Emacs as an external editor in some program you would probably want to enter something like "YOUR-PATH\emacsclientw.exe" %* for the edit command. For just viewing you can include the --no-wait (short form -n) argument which means "do not wait".

Opening and Comparing Files with Ediff

As a small convenience you can start Emacs ediff directly from the command line with the command file ediff.cmd.

Learning to use Emacs

Now you are ready to learn Emacs! Emacs has a builtin tutorial and builtin documentation. From the tutorial you can learn about how to use Emacs from the keyboard. Emacs has its own key bindings choosen for what many people have found to be fast and efficient for editing. You can however also use CUA keys or vi keys and even those two together with Emacs.

A good starting place for documentation is to choose Help - Read Emacs Manual from the menus. Another good place to start from is EmacsWiki.


Features Added by EmacsW32

Features Summary

Here is a summary of the features you get with EmacsW32.

All the adjustments inside Emacs can be set by options that you find under Options - Customize EmacsW32 on the menus. There you also find the automatic lookup of the registry values. Some of the things in integration with MS Windows (like shortcuts) most be selected during the installation.

Features Details

This list is rather technical and not at all required reading.


Changes made by EmacsW32

EmacsW32 does not change much if you do not want it too. Some changes are however always made when you use it.

Changes to menus are small:

File Menu:
The printing entries may be changed. An entry called Quick Print (to MS Windows printer) is added if w32-print.el is used. The default print entries are by default removed.
Options Menu:
An entry for customization, Customize EmacsW32 is added at the bottom. Go there if you want to use the features that Emacs+EmacsW32 can give you.
Help Menu:
Some help entries for EmacsW32 and W32 are added at the top.

Keyboard Keys Changes by EmacsW32

Note that these changes are only made if you turn on the corresponding options in menu Options - Customize EmacsW32.

Notation explanation:

C-
means press control-key
S-
means press shift-key
M-
means press alt-key
A-
also means press alt-key, but in the state when Emacs sends this key to MS Windows (which it normally does not do, set with Emacs customization).
Words like f6, tab, delete
means keyboard key usually named so

"CUA" Keyboard Keys (only when cua-mode on):

      C-c             copy
      C-x             cut
      C-v             paste
      C-z             undo
    

Other MS Windows Standard Keyboard Keys (only when emacsw32-mode on):

      C-a             mark whole buffer
    

Those are "mnemonics" (only when emacsw32-mode on):

      C-tab           switch to next buffer
      C-S-tab         switch to previous buffer
    

C-z and Viper

C-z is undo in most MS Windows programs. In viper this normally instead runs viper-toggle-key-action which temporary switches to Emacs default keypad map and back. EmacsW32 can change this to C-x C-z (which normally runs iconify-or-deiconify-frame, which is rather useless on MS Windows).

      C-x C-z        switch viper keymap on/off
    

Miscellaneous Keyboard Keys Defined by the Used Packages

In addition to provide the functionality wanted by emacsw32-mode the included packages gives some extra functionality, some of it available from the keyboard:

      C-return        cua-set-rectangle-mark (see cua-mode function inside Emacs for more info)
    

The Alt-key War between Emacs and MS Windows

The design of Emacs makes it very hungry for keyboard keys. This unfortunately leads to some keyboard conflicts on MS Windows. On MS Windows Emacs by default uses the Alt keyboard key for what is in Emacs called the Meta key. However the Alt key is used by MS Windows itself and therefore Emacs does not see all Alt key combinations. One of these is Alt-Tab which switches between applications' top level windows. (Emacs could with its current design catch Alt-Tab prior to Windows 2000.)

Using the Alt key as Emacs Meta is also unfortunate since it prevents the use of Alt for the menus instead. (I think Microsoft would have prevented this if they could, since it their GUI guidelines says that Alt should be used for the menus. Since Alt also is used to move around between fields in an application it is however hard for them to do this.)

To get out of this problem I have done some changes to Emacs C sources that permits the right and left Window keyboard keys to be used as as Emacs Meta key. If you use this changed version of Emacs then there is an extra option that allows this feature to be turned on. Using that you can let the Alt key have its standard use in MS Windows and still have easy access to Emacs Meta key. (Of course you also need a keyboard with the Window keyboard keys, but all newer keyboards have this.)

Note: Emacs already without my patch allows the use of the Windows keys as Meta. This does unfortunately not work for all Meta key sequences. For example Right Window-key + e will bring up Windows Explorer. (With my patch it does forward-sentence as expected.)

Patches in Emacs+EmacsW32 distribution

There are also some patches made to Emacs itself when you are using the patched version of Emacs+EmacsW32. See the information about patches on the EmacsW32 home page for more information and the documentation in the EmacsW32 subdirectory of your installation.

If you want to test from elisp if it is the patched version you are running then you can use the function (emacsw32-is-patched).


Files that Comes with EmacsW32

Below is a list of some the special files and packages emacsw32-mode uses and some instruction about how to get them. Notice that if you got emacsw32-mode with the EmacsW32 Install Wizard then you have all those packages.

cua-mode.el
CUA-keys, visible region etc. Comes with your Emacs installation.
htmlize.el, htmlize-view.el
Used by w32-print.el for color printing. You can find htmlize.el on http://fly.srk.fer.hr/~hniksic/emacs/htmlize.el.
recentf.el
List of recenctly used files. Comes with your Emacs installation.
emacsw32-eol.el
Decide which files should have unix line endings based on the full file name.
swbuff-y.el, swbuff.el
Buffer switching with C-tab/C-S-tab. You can find swbuff-y.el on EmacsW32 web site. You also needs swbuff.el which you can find on http://www.EmacsWiki.org/.
w32shell.el
Helps you choose inferior shells to use from Emacs. Support for cmd.exe, Cygwin and MSYS.
w32-print.el, w32-integ.el
Simple and easy printing. (MS Windows only.)
w32-regdat.el, w32-reg-iface.el, w32-reg-iface.exe, winforms.exe
Fetches registry values. (MS Windows only.)
emacsw32.el
Keeps the above together and offers some (very small) keyboard key adjustments.
emacs.exe
Emacs main executable file. Comes with Emacs of course, but Emacs+EmacsW32 provides a patched version (and an unpatched too). To allow the Alt key to be passed to MS Windows and and use the Windows keyboard keys as Meta you must use the emacs.exe that comes with the Emacs+EmacsW32 installation package. (Or you can built it yourself, of course.) EmacsW32 will work with the standard emacs.exe too, but this feature will not be available. (MS Windows only.)
emacsclient.exe, emacsclientw.exe
Comes with Emacs, but with Emacs+EmacsW32 you can get a patched version that starts Emacs automatically.
grep, find, diff etc
With EmacsW32 comes some unix utility programs that you may need with Emacs.

Also in the Installation: nXml/nXhtml

In the package I have also included nXml and nXhtml. These are Emacs modes for editing XML and XHTML files. They come with documentation inside (though it could be more in the case of nXhtml). To read the documentation enable the use of this modes through the menus in Emacs: Options - Customize EmacsW32. Then do C-h f nxhtml-mode RET.

See also NxmlMode and NxhtmlMode on EmacsWiki.