Combined Document | Split Document

GNU Emacs FAQ For Windows 95/98/ME, and 2000

Note: This FAQ is now being hosted at

http://www.gnu.org/software/emacs/windows/ntemacs.html

and now takes advantage of all of the GNU mirrors.

 The latest version of GNU Emacs is v20.7.1, see The Introduction, Getting Emacs, and Installing Emacs, for more details.

1. Introduction

2. Getting Emacs

3. Installing Emacs.

4. Display Settings

5. Fonts, and text translation

6. Printing

7. Sub-processes

8. Mail, News, and Network access

9. Text, and utility, modes for Emacs

10. Developing with Emacs

11. Other Unix Ports, and further information

What is Emacs?

 "Emacs is the extensible, customizable, self-documenting real-time display editor. "

For a more detailed description, see the GNU pages at http://www.gnu.org/software/emacs/emacs.html.

Which versions of Windows, (and Windows NT), are supported?

This port is known to run on all versions of Windows NT - on all its supported platforms, as well as Windows 95, Windows 98, and Windows 2000.

This port is built using the Windows Win32 API and supports most of the features of the Unix version.

MSDOS and Windows 3.11

Eli Zaretskii <eliz@is.elta.co.il> maintains the port of GNU Emacs for MSDOS and MS Windows. You can download precompiled versions with the latest DJGPP archives:

Eli strongly recommends that you start with the emacs.README file: it contains crucial info about what's in the other 10 zip files and how to install them and get started with Emacs on MSDOS/MS-Windows platforms.

More from Eli:

It might be of interest to Windows users that this version of Emacs supports long filenames (Windows 9x only - not Windows NT, or Windows 2000) and the Windows clipboard (all versions of MS-Windows). It also supports multiple frames, but they all overlap, like when Emacs runs on a ``glass teletype'' terminal.

People who would like to run Emacs on plain DOS (as opposed to Windows) will need to download and install a DPMI host at this URL:

ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2misc/csdpmi3b.zip

MULE/Meadow

Hisashi Miyashita <himi@bird.scphys.kyoto-u.ac.jp> maintains MULE, multilingual Emacs, and its descendant; Meadow. You can get distributions of MULE at ftp://ftp.tokyonet.AD.JP/pub/windows/win32/mule-win32. With the multilingual support now merged into NTEmacs in 20.4, it is no longer necessary to use a special version of Emacs for other languages, but MULE users may find upgrading to Meadow easier than to NTEmacs because of slight differences in the way they handle fonts. Meadow also has a couple of features that are still missing from NTEmacs, such as support for native IMEs and the special keys on Japanese keyboards.

DJGPP

 There is a version of Emacs which has been compiled using the Free compiler, DJGPP, (a version of GCC), available at http://www.delorie.com.

XEmacs

There are a couple of XEmacs for Windows NT/9X porting projects. See the XEmacs FAQ entry for more info, as well as Hrvoje Niksic's XEmacs on Windows FAQ.

MacOS

Occasionally I get requests for information about ports of Emacs to the Mac. Here are the ones that I know about:

Where can I get the source distribution?

The latest source distribution can be found in ftp://ftp.gnu.org/gnu/windows/emacs/latest. It is distributed in two formats: one large gzipped tar file (emacs*.tar.gz), and a collection of smaller zip files that can be copied to 1.44 Mbyte floppies (em-src-_?.zip).

In the same directory you should also find patch files that enable you to upgrade source distributions to the latest version. These patch files are mirrors of the ones on the FSF server at ftp://ftp.gnu.org/gnu.

You can also browse the source online; look in ftp://ftp.gnu.org/gnu/windows/emacs/latest for a directory named "emacs-<version>".

For more information about the contents of the various files you should read the README file contained in the FTP directory.

Where can I get precompiled versions?

Starting with Emacs 20.4, precompiled distributions are being hosted at ftp.gnu.org. Distributions for the latest version are at:

Distributions for all architectures and the source are now in the same directory; look for the architecture-specific binary distribution for your machine (e.g., Intel NT and Win9X have "bin-i386" in the distribution name).

Now that the precompiled distributions are hosted on ftp.gnu.org, they also take advantage of all of the gnu ftp mirrors. A list of gnu mirror sites can be found at http://www.gnu.org/order/ftp.html; once you are at one of those sites, look in the gnu/windows/emacs sudirectory to find the NT Emacs directory.

There are also a number of sites that just mirror the NT Emacs distributions:

Regarding ftp.cs.washington.edu: I've had numerous reports from people outside North America saying that their ftp connection aborts for no apparent reason roughly a third of the way through a transfer of a full distribution. Marc Haber <s_haber@ira.uka.de> said that he suffered from the same problem, and later found that a timeout configured into his WWW proxy would cancel the transfer when the link to the US was very busy. Going around his proxy solved the problem. Andy Moreton <ajm@atml.co.uk> describes his situation when using SOCKS:

The FAQ page mentions some people have problems downloading - I may be able to shed some light on it. Our site has a reasonably secure firewall, and so all access to the outside world requires use of SOCKS based connections via a SOCKS5 server (i.e. a circuit-level gateway).

When doing an FTP transfer, two connections are up - a telnet for the control connection, and the data transfer on another. As the telnet connection is idle during the file transfer, the SOCKS server disconnects it. Some FTP servers get upset by this (especially the NT FTP server), and drop the data connection if the control connection goes down.

If you do have trouble downloading the full distribution, try downloading it in the 1.44MB chunks, or try one of the mirror sites.

I dont want the precompiled version. How do I compile Emacs myself?

To compile Emacs, you will need a Microsoft C compiler package. For NT, this can be any of the SDK compilers from NT 3.1 and up, Microsoft Visual C++ for NT (versions 1.0 and up), or Microsoft Visual C++ (versions 2.0 and up). For Windows 95, this can be Microsoft Visual C++ versions 2.0 and up.

Download and place the source distribution in a directory (say, c:\emacs). Unpack the distribution, and go to the nt subdirectory of the emacs directory that gets created in the unpacking process. Read the README and INSTALL files included with the distribution for the full details of this process.

How do I use a debugger on Emacs?

Emacs is just like any other Windows application compiled and linked using MSVC, and it can be debugged using Windows debuggers like DevStudio. By default, Emacs will compile with debugging options turned on. Once compiled, you should be able to load either temacs.exe, the undumped executable, or emacs.exe, the dumped executable, into the debugger (almost always you will want to debug emacs.exe).

Note that Emacs has conventions for naming built-in C identifiers corresponding to lisp functions and variables. You will, of course, need to use the C identifier names when examining variables and setting breakpoints. The C identifier versions of lisp identifiers have dashes converted to underscores, and they are prefixed with a capital letter denoting the type of lisp object that they refer to (functions use 'F', variables use 'V', etc.). For example, the C function implementing the lisp function expand-file-name is Fexpand_file_name, and the C variable corresponding to the lisp variable load-path is Vload_path.

What are the differences between Emacs 19.x, and 20.x

There have been many changes from the older versions of Emacs, 19.x, to the latest versions, 20.x.

These changes have been made in two main areas:

 If you are using an older version of NTEmacs, and are having problems the recommended action is to upgrade to the latest version.

 Then if you still have problems you should send mail to the list, describing your problem in as much detail as possible.

One of the biggest changes has been the mass renaming of symbols, and functions; All functions, and symbols, that used to start with the prefix "win32-" now start with the prefix "w32-".

For example what was once called "win32-select-font" is now called "w32-select-font"

How do I unpack the distributions?

Open a command prompt (MSDOS) window. Decide on a directory in which to place Emacs. Move the distribution to that directory, and then unpack it. If you have the gzipped tar version, first use gunzip to uncompress the tar file, and then use tar with the "xvfm" flags to extract the files from the tar file:

% gunzip -c -d emacs.tar.gz | tar xvf -

(Note: Apparently the alpha version of gunzip cannot handle long file names, so you will need to rename the file to something like "emacstar.gz" before uncompressing it.)

The "-d" flag forces gunzip to decompress (its behavior depends upon the case of the name of the executable, and sometimes it doesn't recognize that it is really gunzip), and the "-c" flag tells it to pipe its output to stdout. Similarly, the "-" flag to tar tells it to read the tar file from stdin. Unpacking the distribution this way leaves the distribution in compressed form so it takes up less space.

You may see messages from tar about not being able to change the modification time on directories, and from gunzip complaining about a broken pipe. These messages are harmless and you can ignore them.

If for some reason you also want to have the tar file gunzipped, then invoke gunzip without the -c option:

% gunzip -d emacs.tar.gz

If you have the zip version, use unzip with the "-x" flag on all of the .zip files (note that you cannot use pkunzip on these files, as pkunzipwill not preserve the long filenames):

% unzip -x emacs-_1.zip
% (repeat for the remaining .zip files)

You can find precompiled versions of all of the compression and archive utilities in ftp://ftp.gnu.org/gnu/windows/emacs/utilities (ftp mirrors).

How do I install Emacs, after unpacking?

After unpacking the archive there's very little left to do, you have the choice of:

If you run "addpm.exe", and answer OK to the message box that pops up then GNU Emacs will be added to your start menu, and certain registry keys will be created for you. This isn't compulsorary as in previous releases - so the choice is yours.

What do I do if Emacs does not work?

See the section below on troubleshooting Emacs if, after downloading a precompiled distribution and unpacking it according to the instructions above, you have trouble running Emacs.

How do I customize Emacs?

 At its core Emacs contains a Lisp interpretter, this engine is used to implement most of the core functionality of Emacs.

 To customize Emacs mostly involves writing extra functions in Lisp, or changing variables that affect the behaviour which is already present.

 Emacs reads a file ".emacs" when it starts up, this is where it expects to find any customizations that you have made.

What is a .emacs file?

When Emacs starts up it attempts to load, and execute the contents of a file called ".emacs", or "_emacs". This file is where all the customizations are saved, and restored from when you restart Emacs. All of these settings are stored as Lisp expressions, for a general introduction to Lisp you could see : http://cons.org, more Emacs Specific information can be found in the Emacs Lisp Manual.

Where do I put my .emacs, (or _emacs), file?

Your startup file can be named either _emacs or .emacs, and should be placed in your "home" directory. If you have both files in your home directory, Emacs will load the .emacs file and ignore _emacs.

Your home directory is where the HOME configuration variable tells Emacs it is. As with the other Emacs configuration variables, HOME can be set in a number of ways:

If Emacs cannot find HOME set in any of the above locations, it will assume your HOME directory is "C:/".

The directory specified by HOME is also the directory substituted for tildes (~) in file names used in Emacs (so, by definition, you can always load your startup file in Emacs by doing C-x C-f "~/.emacs").

Troubleshooting: If you've set HOME to a directory using one of the above methods, and Emacs still doesn't load your startup 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.

Sample .emacs Files

Ingo Koch <ingo.koch@ikoch.de> maintains a web site of sample .emacs files contributed by various users. His site is at http://www.dotemacs.de/.

There is also a small selection of sample .emacs files available at http://www.dotfiles.com

How can I have Emacs prompt me before closing?

If you would like to have Emacs prompt you before closing, add the following to your startup file:

(setq kill-emacs-query-functions
      (cons (lambda () (yes-or-no-p "Really kill Emacs? "))
            kill-emacs-query-functions))

How do I associate files with Emacs (i.e., use Emacs as a server with gnuserv/gnuclient)?

You can use a package like gnuserv to associate files with Emacs so that opening a file outside of Emacs (e.g., by double-clicking on its icon) will create a new frame in a running Emacs displaying that file. Peter Breton <pbreton@dirac.i-kinetics.com> originally ported a version of gnuserv to NT that used named pipes, and Nico Francois <nico.francois@ping.be> has continued development on gnuserv since. It now works on both NT and Windows 95, and has a number of useful features.

Also, be sure to place the gnuserv executables in your path (or modify your path or Emacs' exec-path to include them), and be sure that runemacs.exe is in your path if you use gnuserv to launch Emacs.

Note that you can set up file associations in Windows 95/98/NT 4.0 using Explorer by selecting the "View->Options..." menu operation, and then clicking on the "File Types" tab in the dialog that pops up. Clicking on a file type will allow you to edit it and associate the file with gnuclient.exe.

Warning: Be sure to quote the %1 in the association so that filenames with blanks in them are treated as one argument when sent to Emacs, e.g.:

C:\bin\gnuclientw.exe "%1"

[Discussion of other problems and solutions]

Controlling the use of frames

By default, gnuserv will load files into new frames. If you would rather have gnuserv load files into an existing frame, then evaluate the following in the chosen frame:

(setq gnuserv-frame (selected-frame))

Placing the above in your startup file, for example, will have gnuserv load files into the original Emacs frame. Note: one drawback of this approach is that if the frame associated with gnuserv is ever closed, gnuserv won't have a frame in which to place buffers.

For use with Internet Explorer

You can use Emacs as the editor for composing mail for mailto: links, reading news for news: links, and editing HTML files in Internet Explorer. You first need to install the gnuserv utilities above, and then modify or create the following registry entries using regedit:

Mail

Key: HKEY_CLASSES_ROOT\mailto\shell\open\command(Default)
Value: gnudoit -q (message-mail (substring \"%1\" 7))
News
Key: HKEY_CLASSES_ROOT\news\shell\open\command(Default)
Value: gnudoit -q (gnus-fetch-group (substring \"%1\" 5))
Edit HTML
Key: HKEY_CLASSES_ROOT\htmlfile\shell\edit\command(Default)
Value: gnuclientw %1

Thanks to Jason Rumney <jasonr@gnu.org> and Sigbjorn Finne <sigbjorn@cse.ogi.edu> for these tips.

For use with Netscape

You can use Emacs to view document source from Netscape 3.1. First install the gnuserv utilities, and then edit the Preferences->Apps tab. In the "View Source" field, enter "gnuclientw.exe". Amy Abascal <vhchelp@wsos.com> describes what to do with Netscape 4.

I don't know of any way to have Netscape use Emacs for mailto: and news: links as with IE above.

PIF file for gnuserv

Jerrad Pierce <belg4mit@mit.edu> has packaged together a PIF file and batch file for associating Emacs with file-types via gnuserv.

How do I use find-file to load files that are on the desktop?

Files that you add to the desktop are stored in a directory somewhere under your Windows directory. On NT 4.0, this directory is %USERPROFILE%\desktop (in other words, c:\winnt\profiles(user)\desktop if you installed NT in c:\winnt).

How do I make the active window follow the mouse?

 If you're running Emacs in a windowing mode, and not in the console you may use a package called follow-mouse to make the current frame, or buffer the one with the mouse over it.

Find it here.

How do I swap CapsLock and Control?

CapsLock and Control cannot be swapped from within Emacs, and Windows does not have a convenient mechanism like xmodmap to change virtual key bindings. Instead, new keyboard layouts or device drivers can be installed, or the registry can be modified, to swap the two keys.

WARNING: If you use a new keyboard layout to switch CapsLock and Control, beware of the option to use hotkey sequences to switch keyboard layouts. This option is in Control Panel->Keyboard under the Language (Windows 95) or Input Locales (Windows NT) tabs; the sequences themselves are "Left Alt+Control" and "Ctrl+Shift". If you enable one of these options, then you will likely at some point switch keyboard layouts while trying to use an Emacs key combination.

NT 4.0:

NT 3.5, 3.51: James Kittock has provided a program for NT that installs a new keyboard layout with the two keys swapped. Once installed, you can then select it using the "International" control panel applet. Windows 95: Microsoft has placed a keyboard remapping program for Windows 95 on their ftp site (keyremap). For more info, take a look at their Kernel Toys page.

Mark Russinovich has also written a freeware VxD that swaps CapsLock and Control under Windows 95. (I've been told that you might have to hit the real Control key once after installing the VxD to jumpstart the mapping.)

Windows 98: I've been told that the Windows 95 keyremap utility also works on Windows 98, despite the warnings on the web page.

How can I modify Emacs to be more like a Windows app?

 There are several differences in the way in which Emacs behaves compared to a standard Windows application, however most of the functionality is already present within Emacs, its just a matter of enabling it.

Keypad keys, highlighting selections, etc.

Some behaviors typically found in other Windows apps, such as deleting typed-over highlighted selections, are not configured by default in Emacs. You can, however, enable them by loading various packages. If you would like to highlight the region between the point and the mark, see the help text for transient-mark-mode; if you would like highlighted selections to be deleted when you type over them, see the help text for delete-selection-mode; if you would like to change the semantics of keypad keys such as "home" and "end", see the help text for pc-selection-mode.

Standard Windows application keymaps (C-c, C-v, C-x, etc.)

If you are used to standard Windows application keybindings, such as C-c for copy, C-v for paste, and C-x for cut, or selecting text with <shift>-movement, then you probably want to use Kim Storms <stormware@get2net.dk> CUA-mode.el.

Window operations (maximize, minimize, etc.)

As of Emacs 20.4.1 there is native support for maximizing, and minimizing the Emacs window from Lisp, the following functions will do the job for you:
  (defun w32-restore-frame ()
    "Restore a minimized frame"
     (interactive)
     (w32-send-sys-command 61728))

  (defun w32-maximize-frame ()
    "Maximize the current frame"
     (interactive)
     (w32-send-sys-command 61488))

Open File dialog box

Binu Jose Philip <binu@teil.soft.net> has written the dlgopen package to use the Windows Open File dialog box for opening files. Download dlgopen.zip, unpack, and read the top of the dlgopen.el file for directions on using the package.

How do I uninstall Emacs?

The only thing that Emacs changes in your system is the registry (if you used addpm to install it). Emacs does not, for example, install any files in your system directory. If you don't mind the registry settings remaining in the registry, then you don't need to do anything to uninstall Emacs.

If you want to remove the registry settings, then you can use the regedt32 program to remove the Emacs registry keys. Depending upon what kind of permissions you have, the registry entries could have been installed in either HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs or HKEY_CURRENT_USER\SOFTWARE\GNU\Emacs.

When I run Emacs, nothing happens. Whats the deal?

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:

  1. Be sure to disable the CR/LF translation or the executables will be unusable. Older versions of WinZipNT would enable this translation by default. If you are using WinZipNT, disable it.
  2. Check that filenames were not truncated to 8.3. For example, in Emacs 19.34.6 there should be a file lisp\term\win32-win.el (it has been renamed to w32-win.el in Emacs 20); if this has been truncated to win32-wi.el, your distribution has been corrupted while unpacking and Emacs will not start.
  3. I've also had reports that the GNU Windows port of tar corrupts the executables. Use the version of tar on my ftp site instead.

If you are in doubt about whether the utilities you used unpacked the distribution incorrectly, use the gunzip, tar, and unzip executables provided in the utilities directory. These are the ones I use to create and test the distributions. My advice would be to use these utilities from the start.

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 helpfull response..

I just upgraded the operating system, and Emacs no longer works.

I have received reports that, after upgrading the operating system (e.g., from NT 3.51 to NT 4.0), an installed Emacs will start but will not accept keyboard or mouse input. Apparantly, running addpm.exe as described in the installation section above fixes the problem.

I use anti-virus software. What problems can this cause?

Some anti-virus software seems to interact badly with older version of Emacs, these programs shouldn't cause any problems if you are running a version of Emacs newer than 20.3.

Dr. Solomons

A number of users have reported that Dr. Solomon's WinGuard prevent shell-related commands from working properly within Emacs. Turning off "Scan all files" makes it work, though.

McAfee

A similar report from Charles Curley. <ccurley@wyoming.com> It has also been reported that you only need to select "Programming Files Only" instead of "All Files" to prevent Emacs from hanging.

Norton

A third report from Peter Haas about Norton Antivirus 2000 (Emacs 20.5.1, Win98): a DOS shell cannot be started within Emacs without disabling the antivirus autoprotect feature (e.g., clicking on the icon in the system tray).

Does Emacs contain a virus?

 There have been reports from some people that the McAfee virus scanner, (versions unreported), claims that the latest version of NTEmacs contains a virus.

 Assuming that you are downloading from the official gnu.org site, then these are false positive's which you might see in the following files:

 These warnings seem to be artifacts of the way in which Emacs is built - the process of compiling a program, then using a "dumping" process to ensure that things are pre-loaded in the emacs.exe executable - and can be safely ignored.

 To remove these warnings, update your virus scanner to the latest version.

Sometimes when I exit Emacs, my machine hangs or crashes immediately.

Have you installed an Iomega Zip drive recently? The Iomega driver and Emacs appear to have a conflict that causes this crash. At present, the only solution is to disable the driver, reboot, and then use Emacs normally. To do this, look in the Startup folder (inside the Programs folder in the taskbar), locate the Iomega-related programs, and move them to a different folder. Then reboot. Emacs will work normally. If you want to use the Zip drive, manually execute the Iomega programs you moved. Then reboot before you use Emacs again. It's not convenient, but at least ou won't crash. Thanks to Will Duquette for this information.

How does Emacs determine the name of my computer?

Emacs initializes the variable "system-name" with the name of your computer upon startup. However, Emacs uses two different methods for determining the computer name depending upon whether Winsock is loaded by default when Emacs starts up. If Winsock is automatically loaded, then Emacs uses gethostname, otherwise Emacs uses GetComputerName. Alternatively, you can override all of this by explicitly setting system-name in your startup file (also look at user-mail-address for composing mail messages).

By default, Emacs does not automatically load Winsock because doing so will cause Winsock to establish a connection to the network. If you are connected to a LAN, then nothing will happen, but if you dialup to an ISP then invoking Emacs (thereby loading Winsock) will prompt you to unexpectedly dialup to your ISP.

You can have Emacs automatically load Winsock by defining the environment variable PRELOAD_WINSOCK. You can set it to an arbitrary value; Emacs just checks to see if it is defined. Similarly, you can create a registry entry PRELOAD_WINSOCK with the other Emacs registry entries (in HKEY_LOCAL_MACHINE\SOFTWARE\GNU\Emacs or HKEY_CURRENT_USER\SOFTWARE\GNU\Emacs), which will do the same thing.

How do I change the size, position, font, and color attributes of Emacs?

Emacs can run in two different interface modes: the Windows interface, which allows the flexible use and mixture of fonts and colors; and the console interface, which constrains Emacs to the limitations of console windows. The following two sections describe how to specify and change the size, position, font, and color attributes of Emacs in both interface modes.

Windows Interface

With the Windows interface, you can change the size, position, font, and color attributes of Emacs using three different mechanisms: using the mouse with the user interface, by specifying them as command line arguments, or by invoking Emacs Lisp functions. You will probably find it convenient to specify command line arguments in the Properties of the shortcut to the runemacs.exe file, and to invoke the lisp functions in your startup file. For information on how to propagate attributes to new frames, see the section below on frames .

How do I enable color syntax highlighting in Emacs (font-lock)?

Font-lock mode is a mode that performs color syntax highlighting for other major modes in Emacs. To use font-lock, place the following in your startup file:

(cond ((fboundp 'global-font-lock-mode)
       ;; Turn on font-lock in all modes that support it
       (global-font-lock-mode t)
       ;; Maximum colors
       (setq font-lock-maximum-decoration t)))

The above code uses the default faces for decoration. If you would like to customize the attributes of the faces, you can use the following startup code to get started:

(cond ((fboundp 'global-font-lock-mode)
       ;; Customize face attributes
       (setq font-lock-face-attributes
             ;; Symbol-for-Face Foreground Background Bold Italic Underline
             '((font-lock-comment-face       "DarkGreen")
               (font-lock-string-face        "Sienna")
               (font-lock-keyword-face       "RoyalBlue")
               (font-lock-function-name-face "Blue")
               (font-lock-variable-name-face "Black")
               (font-lock-type-face          "Black")
               (font-lock-reference-face     "Purple")
               ))
       ;; Load the font-lock package.
       (require 'font-lock)
       ;; Maximum colors
       (setq font-lock-maximum-decoration t)
       ;; Turn on font-lock in all modes that support it
       (global-font-lock-mode t)))

Also see the help text for the function global-font-lock-mode and the variable font-lock-face-attributes.

To see a list of colors that Emacs understands by name, select the "Edit->Text Properties->Display Colors" menu command.

An alternative to useing font-lock-mode is to use lazy-lock, to do this use the following:

    (setq font-lock-support-mode 'lazy-lock-mode)

Converting font-lock buffers into HTML markup

You can use the htmlize.el package by Hrvoje Niksic <hniksic@srce.hr> to convert font-lock attributes in buffers to HTML markups. See the comments at the top of the file on how to use it.

If you are using a version of Emacs before 19.34.6 and an 8-bit display, then you should download this version of htmlize.el instead. However, this is likely to become out of date with respect to Hrvoje's version, so I would actually recommend upgrading to 19.34.6.

Font-locking embedded code (e.g., ASP) in HTML documents

Gian Uberto Lauri <lauri@mail.eng.it> has modified html-helper-mode to enable font-locking and mode editing of code embedded in HTML documents (ASP, PHP).

How do I change the format of the mode line?

The format of the mode line is determined by the variable mode-line-format, a buffer-local variable. To understand how to interpret the mode line, see the Info node "C-h i m emacs RET m mode line RET". For a description of minor modes that provide additional information on the mode line (like line and column number, current time, and mail status), see the Info node "C-h i m emacs RET m optional mode line features".

You can also directly customize the format by assigning a new format string to the mode-line-format variable in your startup file. For a description of the format codes, see the help string for the variable ("C-h v mode-line-format").

What do I do if I have problems with Emacs and my mouse buttons?

You can use either a two- or three-button mouse with Emacs. If you have trouble with either of these working with Emacs, see below.

How do I use Emacs with a two-button mouse?

Emacs assumes that you have a three-button mouse by default. However, if you have a two-button mouse, you can press both buttons at once to emulate the missing middle button expected by Emacs.

Three variables control mouse button emulation under Emacs: w32-num-mouse-buttons, w32-mouse-button-tolerance, and w32-swap-mouse-buttons (win32-num-mouse-buttons, win32-mouse-button-tolerance. If you use help on w32-num-mouse-buttons (i.e., with "C-h v"), it will tell you how many buttons Emacs thinks your mouse has; if w32-num-mouse-buttons is less than 3, then Emacs will emulate the middle mouse button.

Emacs emulates the middle mouse button by treating simultaneous button presses of the left and right buttons as a middle button press. Since both button presses cannot really be simultaneous, Emacs compares button presses within a specified window of time to determine whether it should emulate the middle button. This window of time is controlled using w32-mouse-button-tolerance. Help on this variable will show you the value Emacs uses by default, and you can change this value to suit your needs.

Depending upon the type of two-button mouse, you may find it useful to swap the mapping of middle and right mouse buttons. By default, the middle button is mapped to mouse-2 and the right button is mapped to mouse-3. If you set w32-swap-mouse-buttons to a non-nil value, then you can swap these two mappings.

How do I get Emacs to recognize the third button on my mouse?

If you have a three-button mouse, Emacs should recognize and support the third (middle) button automatically. However, some people find that they have a three button mouse, but the middle mouse button does not work for them. First check to see if w32-num-mouse-buttons is set correctly. If so, then check to see whether your mouse has been installed with the proper driver (open Control Panel->Mouse to examine the driver being used). If you have the right driver, then, on NT, check if HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Busmouse\Paramete rs\NumberOfButtons is set to 3, and change it to 3 if it is not. If nothing seems to be amiss, then at the very least you can have Emacs emulate the middle button by setting w32-num-mouse-buttons to 2.

Strange two-button mouse behavior on Windows 95.

Some people have reported that using a two-button mouse with Emacs sometimes causes problems when they go to click in other windows or the desktop (e.g., double left-clicks are interpreted as a right-click); apparently this is a known bug in Windows 95, and is not confined to using Emacs. If this is happening to you, you might want to flip through a discussion on the topic.

One workaround is to right-click on the desktop, and then left-click on the desktop, and the mouse should be back in its normal state.

How do I highlight the region between the point and the mark?

To highlight the region between the point and the mark, use the function transient-mark-mode:

(transient-mark-mode t)

How do I highlight matching parentheses?

To highlight matching parentheses, add the following to your startup file:

(show-paren-mode 1)

How do I cut & paste text with null characters?

Because of the way Emacs currently tries to share the clipboard with other Windows applications, you cannot cut and paste text with null characters embedded in it. David Biesack <sasdjb@unx.sas.com> describes a way to get around this, at least for cutting and pasting text just within Emacs.

How do I change the sound of the Emacs beep?

You can use the function set-message-beep to change the sound that Emacs uses for its beep. Emacs allows you to specify one of the Windows system sounds for the beep. For example, to use the ok system sound, place the following in your startup file:

(set-message-beep 'ok)

Look up help for the function for a complete description of how to use the function and which sounds it recognizes.

When I yank previously copied or killed text into a buffer, it appears garbled. How can I fix this?

`selection-coding-system' is most likely still at it's default of `iso-latin-1-dos'. You can change this to a more appropriate coding system using `set-selection-coding-system' (C-x RET x), or temporarily with `set-next-selection-coding-system' (C-x RET X). If you NEVER cut and paste between Emacs and other programs, you can make Emacs behave for all languages with:

(set-selection-coding-system 'emacs-mule)

To copy between Emacs and other apps, you may need to use the appropriate Windows codepage as your coding system. To do this, you need to set up the codepage first:

(codepage-setup 1251)
(set-selection-coding-system 'cp1251)

FONTS

Fonts in Emacs are named using the standard X Windows format for fonts.

For an explanation of what each element in a font string means and how Emacs on NT uses it, see Andrew's note.

These font names are the names that can be used as arguments on the command line or in lisp functions. To see the font name corresponding to a font chosen using the font selection dialog, execute the following elisp code in the *scratch* buffer:

(insert (prin1-to-string (w32-select-font)))   ; Emacs 20

To see the complete list of fonts that Emacs has access to, execute the following elisp code in the *scratch* buffer:

(insert (prin1-to-string (x-list-fonts "*")))

The font support currently is a little rough around the edges. In particular, italic fonts give Emacs some problems; see below for more info about using italic fonts. Generally it performs as expected, but occasionally you might get unexpected results (e.g., Emacs didn't quite use the font you told it to use). Work is underway to fix these problems, but for now I suggest experimenting if you encounter problems.

Also, X Windows has the luxury of a set of font aliases (such as fixed) that are convenient names for referring to specific fonts. Work is underway to provide an equivalent alias mechanism under Windows so that naming fonts does not have to be as cumbersome as it currently is.

To customize fonts for specific frames, see the section on customizing frames below.

User Interface
To change the default font that Emacs uses, shift click the left mouse button (i.e., [shift-mouse-1]) and a font selection dialog will pop up. Select the font that you would like to use, and click on the OK button to close the dialog and use the selected font. (Note that the dialog only displays fixed-pitch and screen fonts since Emacs cannot handle variable-pitched fonts.)
Command Line
To start Emacs with a particular font, use the the -font X Windows command line option. For example, to start Emacs with the Courier font of size 10 and font style Regular, invoke Emacs using:
emacs -font "-*-Courier-normal-r-*-*-13-*-*-*-c-*-iso8859-1"
Emacs Lisp
To change the default font of Emacs using elisp, use the set-default-font function:
(set-default-font "-*-Courier-normal-r-*-*-13-*-*-*-c-*-*-iso8859-1")

To set the font of a particular face, use the set-face-font function.

Registry
To change the default font of Emacs frames using registry entries, create a value in the key HKEY_CURRENT_USER\Software\GNU\Emacs:
Value Name: Emacs.Font
Value Type: REG_SZ
String: -*-Courier-normal-r-*-*-13-*-*-*-c-*-iso8859-1

Since the font strings are rather cumbersome, I would suggest cutting the font string into the kill-ring (which will place it in the clipboard, too) and pasting it (Ctrl-V) into the regedit dialog. (Note that you shouldn't place quotes around the font string in the registry.)

If you have Emacs frames with specific names, you can also specify a font for that frame. For the Value Name of the entry, use the name of the frame instead of Emacs (e.g., RMAIL.Font for your RMAIL frame).

ITALICS

Emacs currently requires that italic versions of fonts have the same width as the normal version of the font. However, most of the default fonts have italic and italic bold versions whose character widths are larger than the normal version (the only default font that appears to have viable italic and bold versions is Courier New). Because of this, Emacs by default disables the use of italic faces.

You can still enable the use of italic faces with Emacs by setting the variable w32-enable-italics to t in your startup file:

(setq w32-enable-italics t)    ; This must be done before font settings! (Emacs 20.x)
(set-face-font 'italic "-*-Courier New-normal-i-*-*-11-*-*-*-c-*-iso8859-1")
(set-face-font 'bold-italic "-*-Courier New-bold-i-*-*-11-*-*-*-c-*-iso8859-1")

Although this works best with Courier New, there is still one minor glitch: the italics versions are one pixel higher than the other versions, so the line spacing is increased by a pixel when italics are enabled. FONT

Under NT, open the "-" menu. Select "Fonts...", and use the dialog to set the window font to the one you want. Be sure to check the "Save Configuration" checkbox so that your font change will be used in future invocations. Click on "OK", and the window will get resized.

Under Windows 95/98, simply use the popup font menu in the upper left-hand corner of the window. Or click on the font icon in the icon toolbar. Or click on the properties icon in the icon toolbar and go to the "Font" tab and choose the font that you want to use.

Emacs multilingual font support

(Applies to version 20.4 and later)

Is it now possible to display correctly the sample of various scripts and languages accessible from the MULE menu?

If you have a Windows font for the script or language, then you should be able to display it using Emacs 20.4. Emacs 20.4 also supports the bdf fonts that were used with the older MULE for Windows version of Emacs and the more recent Meadow versions (as well as the X Windows versions of Emacs). For details on using the bdf fonts with Emacs, see below .

More about using Windows fonts:

There are a number of languages for which Windows fonts are not yet available, or are not in an appropriate format for Emacs to use, so you will not get every language to display. I also had some problem getting Japanese, Chinese, Cantonese and Korean to display all at once, but this was on Windows 95, and I suspect is a limitation of the OS, rather than a bug in Emacs, as those languages look fine when displayed one at a time (there is a note on the Microsoft language packs that only one may be installed at a time, which I suspect is because of this limitation).

Because some languages can only use proportional fonts, limited support has been added for proportional fonts as the non-ASCII font in fontsets. It should be general enough to work with any font, but it is not full proportional support, so the characters may not appear exactly as you expect. You may need to try several fonts to find one that appears reasonably correct if you wish to use Emacs with languages like Thai which use composition and hence use only proportional Windows fonts.

How do I get Emacs to display characters other than ISO-8859-1 (West European)?

If you are content with the size and style of font that Emacs uses at startup (Courier New 10), you could try using `fontset-standard', which will give you most languages that you have fonts for and Emacs supports. To use `fontset-standard' for all frames, place the following in your startup file:

(setq default-frame-alist
        (append
        '((font . "fontset-startup"))
        default-frame-alist))

or, to change for the current frame only:

(set-frame-font "fontset-startup")

To have more control over which fonts are used in a fontset, you need to specify the fontset manually.

If only one character set is needed, the easiest way to do this is to use `create-fontset-from-ascii-font' whereever you define a font.

(setq default-frame-alist
      (append
       '((font . (create-fontset-from-ascii-font
                  "-*-Andale Mono-normal-r-*-*-13-*-*-*-c-*-iso8859-2")))
       default-frame-alist))

If you require support for a number of languages, you should use `create-fontset-from-fontset-spec'. Note that installing more than one of the East Asian language packs is not supported by Microsoft, and does not work on Windows 95 at least. It is very difficult to get your system stable again after trying, so it is recommended that you only install the one that you will use the most, and use BDF fonts for the other languages:

(create-fontset-from-fontset-spec
 "-*-Courier New-normal-r-*-*-12-*-*-*-c-*-fontset-most,
 latin-iso8859-2:-*-Courier New-normal-r-*-*-12-*-*-*-c-*-iso8859-2,
 latin-iso8859-3:-*-Courier New-normal-r-*-*-12-*-*-*-c-*-iso8859-3,
 latin-iso8859-4:-*-Courier New-normal-r-*-*-12-*-*-*-c-*-iso8859-4,
 cyrillic-iso8859-5:-*-Courier New-normal-r-*-*-12-*-*-*-c-*-iso8859-5,
 greek-iso8859-7:-*-Courier New-normal-r-*-*-12-*-*-*-c-*-iso8859-7,
 latin-iso8859-9:-*-Courier New-normal-r-*-*-12-*-*-*-c-*-iso8859-9,
 japanese-jisx0208:-*-MS Gothic-normal-r-*-*-12-*-*-*-c-*-jisx0208-sjis,
 katakana-jisx0201:-*-MS Gothic-normal-r-*-*-12-*-*-*-c-*-jisx0208-sjis,
 latin-jisx0201:-*-MS Gothic-normal-r-*-*-12-*-*-*-c-*-jisx0208-sjis,
 japanese-jisx0208-1978:-*-MS Gothic-normal-r-*-*-12-*-*-*-c-*-jisx0208-sjis,
 korean-ksc5601:-*-Gulim-normal-r-*-*-12-*-*-*-c-*-ksc5601-*,
 chinese-gb2312:-*-MS Song-normal-r-*-*-12-*-*-*-c-*-gb2312-*,
 chinese-big5-1:-*-MingLiU-normal-r-*-*-12-*-*-*-c-*-big5-*,
 chinese-big5-2:-*-MingLiU-normal-r-*-*-12-*-*-*-c-*-big5-*" t)

If you leave character sets out of the fontset-spec above, a font will be chosen at random (not necessarily matching any of the other fonts in the fontset). The fontset name is used to generate the "default" font, which covers ASCII and iso8859-1.

To get a full list of character-sets use "M-x describe-fontset" to describe `fontset-standard'.

Where can I find fonts for other languages?

MS Windows fonts The Windows installation CDROM contains fonts for most European languages. If you did not install "Multilanguage Support" when you installed Windows, you can install it from the "Add Programs" Control Panel. East Asian Language (Chinese, Japanese, Korean) support for Microsoft Word and Internet Explorer can also be used by Emacs. These are available from http://www.microsoft.com, or on the installation CDROMs. IE5 also has fonts for Thai, Vietnamese and other languages, although it is not known how well these work with Emacs. Fonts for many other languages are available on the WWW; a good starting point is http://babel.uoregon.edu/yamada/guides.html.

X Windows fonts There is a collection of international fonts for use with X Windows, and a set can be found at ftp.gnu.org. They are distributed in the bdf font file format, a format that can be handled by Emacs starting with version 20.3.5.1. For details on how to use these fonts with Emacs, see the section below on using bdf fonts with Emacs.

How do I use third party programs for displaying multibyte characters with Emacs?

Define a fontset ( see above ) listing any font of an appropriate size which works with the third party program for the appropriate character set(s). Change the character set to the character set you want displayed so Emacs knows how to display it. For example:

(create-fontset-from-fontset-spec
 "-*-Courier New-normal-r-*-*-13-*-*-*-c-*-fontset-asian,
 korean-ksc5601:-*-Courier New-normal-r-*-*-13-*-*-*-c-*-ksc5601-*,
 chinese-gb2312:-*-Courier New-normal-r-*-*-13-*-*-*-c-*-gb2312-*,
 chinese-big5-1:-*-Courier New-normal-r-*-*-13-*-*-*-c-*-big5-*,
 chinese-big5-2:-*-Courier New-normal-r-*-*-13-*-*-*-c-*-big5-*,
 japanese-jisx0208:-*-Courier New-normal-r-*-*-13-*-*-*-c-*-jisx0208-sjis,
 katakana-jisx0201:-*-Courier New-normal-r-*-*-13-*-*-*-c-*-jisx0201-sjis,
 latin-jisx0201:-*-Courier New-normal-r-*-*-13-*-*-*-c-*-jisx0201-sjis,
 japanese-jisx0208-1978:-*-Courier New-normal-r-*-*-13-*-*-*-c-*-jisx0208-sjis")

If this doesn't work, you may need to set `w32-enable-unicode-output' to nil.

How do I use a font with a name in my language?

This is most applicable to East Asian users. Others can probably get their fonts working (with a strange looking name), but it is nice to have the names of fonts displayed correctly.

You need to use the function `set-w32-system-coding-system' before the font is specified. If you are setting the font from your .emacs, you will need to make sure the coding-system of your .emacs supports the character set for the font name. An example (for Traditional Chinese) follows:

;; Top line of .emacs: -*- coding: chinese-big-5; -*-
(set-w32-system-coding-system 'chinese-big-5)

For Japanese, you would use japanese-shift-jis; for Simplified Chinese, chinese-iso-8bit; for Korean, korean-iso-8bit.

How can I use bdf fonts with Emacs?

To use bdf fonts with Emacs, you need to tell Emacs where the fonts are located, create fontsets for them, and then use them. We'll use the 16 dot international fonts from ftp.gnu.org/intlfonts as an example put together by Jason Rumney <jasonr@gnu.org>

Download the 16dots.tar.gz file and unpack it; I'll assume that they are in "c:\intlfonts". Then set w32-bdf-filename-alist to the list of fonts returned by using w32-find-bdf-fonts to enumerate all of the font files. It is a good idea to set the variable bdf-directory-list at the same time so ps-print knows where to find the fonts:

(setq bdf-directory-list
      '("c:/intlfonts/Asian" "c:/intlfonts/Chinese" "c:/intlfonts/Chinese-X"
        "c:/intlfonts/Ethiopic" "c:/intlfonts/European" "c:/intlfonts/Japanese"
        "c:/intlfonts/Japanese-X" "c:/intlfonts/Korean-X" "c:/intlfonts/Misc/"))
(setq w32-bdf-filename-alist
      (w32-find-bdf-fonts bdf-directory-list))

Then create fontsets for the BDF fonts:

(create-fontset-from-fontset-spec
 "-*-fixed-medium-r-normal-*-16-*-*-*-c-*-fontset-bdf,
 japanese-jisx0208:-*-*-medium-r-normal-*-16-*-*-*-c-*-jisx0208.1983-*,
 katakana-jisx0201:-*-*-medium-r-normal-*-16-*-*-*-c-*-jisx0201*-*,
 latin-jisx0201:-*-*-medium-r-normal-*-16-*-*-*-c-*-jisx0201*-*,
 japanese-jisx0208-1978:-*-*-medium-r-normal-*-16-*-*-*-c-*-jisx0208.1978-*,
 thai-tis620:-misc-fixed-medium-r-normal--16-160-72-72-m-80-tis620.2529-1,
 lao:-misc-fixed-medium-r-normal--16-160-72-72-m-80-MuleLao-1,
 tibetan-1-column:-TibMdXA-fixed-medium-r-normal--16-160-72-72-m-80-MuleTibetan-1,
 ethiopic:-Admas-Ethiomx16f-Medium-R-Normal--16-150-100-100-M-160-Ethiopic-Unicode,
 tibetan:-TibMdXA-fixed-medium-r-normal--16-160-72-72-m-160-MuleTibetan-0")

Many of the international bdf fonts from gnu.org are type 0, and therefore need to be added to font-encoding-alist:

;; Need to add some fonts to font-encoding-alist since the bdf fonts
;; are type 0 not the default type 1.
(setq font-encoding-alist
      (append '(("MuleTibetan-0" (tibetan . 0))
                ("GB2312"        (chinese-gb2312 . 0))
                ("JISX0208"      (japanese-jisx0208 . 0))
                ("JISX0212"      (japanese-jisx0212 . 0))
                ("VISCII"        (vietnamese-viscii-lower . 0))
                ("KSC5601"       (korean-ksc5601 . 0))
                ("MuleArabic-0"  (arabic-digit . 0))
                ("MuleArabic-1"  (arabic-1-column . 0))
                ("MuleArabic-2"  (arabic-2-column . 0))) font-encoding-alist))

You can now use the Emacs font menu (not the popup dialog; see below ) to select the "bdf: 16-dot medium" fontset, or you can select it by setting the default font:

(set-default-font "fontset-bdf")

Try loading the file etc/HELLO, and you should be able to see the various international fonts displayed (except for Hindi, which is not included in the 16-dot font distribution).

How can I have Emacs use a font menu similar to the one it uses on Unix (with fonts and fontsets listed)?

Place the following in your startup file:

(setq w32-use-w32-font-dialog nil)

The font I want to use is not in the font menu, how can I put it there?

If you have set w32-use-w32-font-dialog to nil, you can add fonts to the font menu by changing `w32-fixed-font-alist'. For example:

(setq w32-fixed-font-alist
      (append w32-fixed-font-alist
              '(("Monotype.com"
   ("8" "-*-Monotype.com-normal-r-*-*-11-*-*-*-c-iso8859-1")
   ("9" "-*-Monotype.com-normal-r-*-*-12-*-*-*-c-iso8859-1")
   ("10" "-*-Monotype.com-normal-r-*-*-13-*-*-*-c-iso8859-1")
   ("11" "-*-Monotype.com-normal-r-*-*-15-*-*-*-c-iso8859-1")))))

How can I control CR/LF translation (e.g., to access UNIX files via NFS)?

There are a number of methods by which you can control automatic CR/LF translation in Emacs, a situation that reflects the fact that the default support isn't very robust. For a discussion of this issue, take a look at this collection of email messages on the topic.

By file extension

The first method is by file extension using the alist file-name-buffer-file-type-alist. This alist contains pairs of regular expressions and booleans that determine whether a file is opened in binary (untranslated) or text (translated) mode. The alist already contains a number of pairs that you can use as examples for creating your own; do a "C-h v" on the variable name to see the help text and the default pairs.

You could add your own pairs to the alist, or change the alist entirely. For example, if you wanted to open every file in binary mode except for batch files, you could add the following to your startup file:

(setq file-name-buffer-file-type-alist '(("\.bat$" . nil) (".*" . t)))

The first pair says anything ending with the .bat extension should be opened in text mode, and the second pair opens everything else that doesn't match the first pair in binary mode.

By file system

A second method for controlling translation is with the functions at the end of untranslate.el. These functions enable you to turn on and off translation on a filesystem basis (e.g., open anything on C: in translated mode, and anything on U: in untranslated mode). If you want to use these functions, download and place untranslate.el in your load-path and have it loaded from your startup file. Then you can place calls to add-untranslated-filesystem to selectively access filesystems in binary mode.

Automatic

A third method for controlling translation is to have Emacs scan files and automatically determine whether they are binary or text by looking at the line breaks in the file (i.e., no line breaks or just linefeeds imply binary, carriage return/linefeed pairs imply text). A group effort by people on the mailing list put together a patch that implements this kind of automatic translation. To use it, place this patch in your startup file.

How do I print from Emacs?

20.4

Please read Andrew's note on how to print from Emacs in 20.4. What you need to do depends upon how you connect your printer to your machine.

Tim Sherrill <sherritp@sagian.com> has a very informative page on 2-up (n-up) printing from Emacs.

Holger Mueller <hmueller@bigfoot.com> has taken over maintaining print-NT.el [V 1.15, 6/29/98] (previously maintained by Brian Gorka <gorkab@cyberpass.net>).

Theodore Jump <tjump@tertius.com> has also written w32-print.el, a relatively complete package for printing from Emacs on Windows systems (Postscript, plain-text, 2- and 4-up, 19.34.X and 20.X, UNC and local device paths, etc.). [V1.11, 12/7/98]

Pascal Obry has a nice example of how to set up some variables to get printing to work on NT.

Jeff Paquette <paquette@mediaone.net> has a version of pr for use with Emacs, and instructions on how to set it up.

Anders Lindgren <andersl@csd.uu.se> has written a lpr.bat batch file that can be subsituted transparently for lpr on NT (Windows 95 batch files don't redirect stdin correctly).

A number of other people have put together packages to print from Emacs. I haven't had the time to go through them and piece everything together, but I recommend that you flip through this collection of messages.

For info on 2-up printing from Emacs, take a look at these messages.

For clever tricks for specific printers, take a look at these messages.

Bill Carpenter on printing in color:

It's relatively easy to set up the ps-print package, which can
generate color PostScript output.  You can then run the results
through Ghostscript if you don't happen to have a color PS printer
laying around.

To try it manually, do something like this:

        (require 'ps-print)
        (ps-spool-buffer-with-faces)

and then look for the buffer "*PostScript*".

You can also turn your font-locked buffers into HTML, and then use a browser to print them out. See the section on htmlize.el.

Printing via Ghostscript

 Alec Clews reports success at using Ghostscript to perform his printing - using gsview version 3.4, and Ghostscript version 6.01

 The configuration is straightforward, here's his settings, (which you should modify to suit).

      (setq ps-lpr-command "c:\\Ghostgum\\gsview\\gsprint.exe")

      ;; THis line causes ghostscript to query which printer to
      ;; use - which you may not need if, for example, you only
      ;; have one printer.
      (setq ps-lpr-switches '("-query"))

      (setq ps-printer-name t)

 The commandline options are documented in the gsprint.htm file which comes with Ghostscript.

How do I print all these languages that Emacs is now displaying?

 Emacs 20.4 has the ability to print non Western languages in two ways. Both use the "Postscript Print" functions, so if you do not have a Postscript printer, you will need to configure Emacs to print through Ghostscript.

  1. Using built-in support in the printer (or in Ghostscript).
  2. Using BDF fonts.

The variable `ps-multibyte-buffer' controls how non-latin characters are printed. If you are using built in support in the printer or Ghostscript, then setting this variable appropriately is all that needs to be done. To use BDF fonts, you will need to tell ps-print where to find them. This is done by setting `bdf-directory-list'. For example:

(setq ps-multibyte-buffer 'bdf-font
      ps-mule-font-info-database ps-mule-font-info-database-bdf
      bdf-directory-list '("c:/intlfonts/European" "c:/intlfonts/Chinese"
                           "c:/intlfonts/Japanese" "c:/intlfonts/Korean-X"))

By default, Emacs uses 24 dot BDF fonts for normal text, 16 dot for bold and italic and 40 dot for some (uncommon) Chinese and Japanese character sets.

Quoting issues

The quoting rules for Windows shells and Cygnus shells have some subtle differences. When Emacs spawns subprocesses, it tries to determine whether the process is a Cygnus program and changes its quoting mechanism appropriately. [Discussion]

Programs reading input hang

Programs that explicitly use a handle to the console ("CON" or "CON:") instead of stdin and stdout cannot be used as subprocesses to Emacs, and they will also not work in shell-mode (the default ftp clients on Windows 95 and NT are examples of such programs - this ftp program is fine for use with ange-ftp, but not for M-x ftp). There is no convenient way for either Emacs or any shell used in shell-mode to redirect the input and output of such processes from the console to input and output pipes. The only workaround is to use a different implementation of the program that does not use the console directly (see the discussion on ange-ftp for a replacement for the default ftp clients).

Buffering in shells

You may notice that some programs, when run in a shell in shell-mode, have their output buffered (e.g., people have found this happening to them with sql-mode). When the program has a lot of output, it overflows the buffering and gets printed to the shell buffer; however, if the program only outputs a small amount of text, it will remain buffered and won't appear in the shell buffer.

Although it may at first seem like the shell is buffering the output from the program, it is actually the program that is buffering output. The C runtime typically decides how to buffer output based upon whether stdout is bound to a handle to a console window or not. If bound to a console window, output is buffered line by line; if bound to a block device, such as a file, output is buffered block by block.

In a shell buffer, stdout is a pipe handle and so is buffered in blocks. If you would like the buffering behavior of your program to behave differently, the program itself is going to have to be changed; you can use setbuf and setvbuf to manipulate the buffering semantics.

Some programs handle this by having an explicit flag to control their buffering behaviour, typically "-i". Other programs manage to detect that they are running under Emacs, by using getenve("emacs") internally.

Perl script buffering.

A handy solution for Perl scripts is to use:

      # Turn all buffering off.
      select((select(STDOUT), $| = 1)[0]);
      select((select(STDERR), $| = 1)[0]);
      select((select(STDIN),  $| = 1)[0]);

DOS subprocesses

You can run DOS subprocesses under Emacs, with either the native command shell, or one of the alternatives, such as bash, tcsh, or 4NT, instead of command.com/cmd.exe; see the section below on other tools for pointers to other sites.

16-bit subprocesses accessing the A: drive.

If you are finding that running 16-bit programs as subprocesses cause your A: drive to be accessed (hanging Emacs until a timeout occurs if no floppy is in the drive), check to see if you have McAfee Virus Shield installed. Users have found that disabling Virus Shield causes the problem to go away. Also, if you have a better fix for this problem, let me know or send mail to the list.

A followup from Bill Carpenter <bill@bubblegum.net>.

Killing subprocesses on Windows 95/98

Emacs cannot guarantee that a subprocess gets killed on Windows 95/98, and is a difficult limitation to work around. For the forseeable future, you should always let subprocesses run to completion, including explicitly exiting interactive shells.

If you find that shutting down Windows 95/98 complains that there is a running cmdproxy even though you've exited all programs and it doesn't show up in the Task Manager until you shutdown, this could be a bad interaction with Norton VirusChecker.

Francis Wright has written a nice little package which tries to automatically tell shell buffer(s) to "exit" if you try to kill them, it is called msdos-shell-fix.el, and can be found at : http://centaur.maths.qmw.ac.uk/Emacs/.

Sending eof to subprocesses in Emacs (e.g., C-c C-d in shell buffers)

When an eof is sent to a subprocess running in an interactive shell via process-send-eof, the shell terminates unexpectedly as if its input were closed. See this description for more info and an example.

How do I use a shell in Emacs?

You can use an interactive subshell in Emacs by typing "M-x shell". Emacs uses the SHELL configuration variable to determine which program to use as the shell. If you installed Emacs using the addpm.exe program, then addpm.exe will associate the value %COMSPEC% with SHELL in the registry. Emacs will then use the value of the COMSPEC environment variable when it starts up, unless the SHELL environment variable is explicitly defined (as when using the emacs.bat batch file).

If you would like to specify a different shell for Emacs to use, then you should do one of two things. You should either explicitly set the environment variable SHELL to be the shell you want to use, or, if you want to have the COMSPEC environment variable determine the shell, then you need to install Emacs using the addpm.exe program and ensure that the SHELL environment variable is not defined when you start up Emacs.

Any replacement shell should follow Unix convention for the -c option, or else be invoked via cmdproxy.exe if it follows the DOS convention.

Note that sh-script.el does not recognize shell names when they have the '.exe' extension on them. If you use sh-script, you should omit the '.exe' extension when specifying the SHELL variable.

Alternatively, if you do not want to mess with the SHELL or COMSPEC variables, you can explicitly place the following in your startup file:

;; For the interactive shell
(setq explicit-shell-file-name "c:/bin/tcsh.exe")

;; For subprocesses invoked via the shell (e.g., "shell -c command")
(setq shell-file-name "c:/bin/tcsh.exe")

bash

You can get a version of bash with the Cygnus tools at http://www.cygnus.com/misc/gnu-win32. To use bash with Emacs, place the following in your startup file:

(defun my-shell-setup ()
  "For Cygwin bash under Emacs 20"
  (setq comint-scroll-show-maximum-output 'this)
  (setq comint-completion-addsuffix t)
  ;; (setq comint-process-echoes t) ;; reported that this is no longer needed
  (setq comint-eol-on-send t)
  (setq w32-quote-process-args ?\")
  (make-variable-buffer-local 'comint-completion-addsuffix))

(setq shell-mode-hook 'my-shell-setup)

Richard M. Heiberger's <rmh@fisher.stat.temple.edu> setup for Cygnus B19.

For more configuration information with bash, take a look at Jonathan Payne's <jpayne@marimba.com> setup.

If you find that you are having trouble with Emacs tracking drive changes with bash, see Mike Fabian's note <mike.fabian@it-mannesmann.de>

The package cygwin32-mount.el teaches Emacs about cygwin32 mount points.

WARNING:The latest version of bash sets and uses the environment variable PID. For some as yet unknown reason, if PID is set and Emacs passes it on to bash subshells, bash croaks (Emacs can inherit the PID variable if it's started from a bash shell). If you clear the PID variable in your startup file, you should be able to continue to use bash as your subshell:

(setenv "PID" nil)

ksh

For a version of ksh by David Korn, take a look at http://www.research.att.com/sw/tools/uwin. I haven't tried this shell with Emacs, but I'm guessing that it works under Emacs and that you need the following for it to work properly:

(setq w32-quote-process-args t)     ; Emacs 20
(setq shell-command-switch "-c")

If you find out otherwise, let me know and I'll update this section.

WARNING: People have reported that UWIN 1.5 ksh doesn't work with Emacs. I do not know why yet. If you figure out why, please send mail to the list.

MKS ksh

To use MKS ksh, place the following in your startup file:

(setq w32-quote-process-args t)   ; Emacs 20
(setq shell-command-switch "-c")

tcsh

You can find tcsh at ftp://ftp.blarg.net/users/amol/tcsh. To use tcsh, place the following in your startup file:

(setenv "SHELL" "tcsh.exe")
(setq w32-quote-process-args t)   ; Emacs 20
(setq shell-command-switch "-cf")

For more configuration information with tcsh, take a look at Chris McMahan's <cmcmahan@surefirev.com> setup.

zsh

You can find zsh at ftp://ftp.blarg.net/users/amol/zsh/

How do I prevent shell commands from being echoed?

Some shells echo the commands that you send to them, and the echoed commands appear in the output buffer. In particular, the default shells, command.com on Windows 95 and cmd.exe on NT, have this behavior.

To prevent echoed commands from being printed, you can place the following in your startup file:

(defun my-comint-init ()
  (setq comint-process-echoes t))
(add-hook 'comint-mode-hook 'my-comint-init)

If shell-mode still is not stripping echoed commands, then you'll have to explicitly tell the shell to not echo commands. You can do this by setting the explicit-SHELL-args variable appropriately, where SHELL is the value of your shell environment variable (do a "M-: (getenv "SHELL")" to see what it is currently set to). Assuming that you are on NT and that your SHELL environment variable is set to cmd.exe, then placing the following in your startup file will tell cmd.exe to not echo commands:

(setq explicit-cmd.exe-args '("/q"))

The comint package will use the value of this variable as an argument to cmd.exe every time it starts up a new shell (as in shell-mode); the /q is the argument to cmd.exe that stops the echoing (in a shell, invoking "cmd /?" will show you all of the command line arguments to cmd.exe).

Note that this variable is case sensitive; if the value of your SHELL environment variable is CMD.EXE instead, then this variable needs to be named explicit-CMD.EXE-args instead.

How do I have Emacs complete directories with / instead of "?

The character appended to directory names when completing in shell-mode is determined by the value of the variable comint-completion-addsuffix. If the value of this variable it t, then a '/' is appended to directory names. If the value of this variable is a cons pair, then the first value of the pair is appended.

When I run programs within a shell I get Incorrect DOS version messages. Why?

This might happen if, for example, you invoke nmake in a shell and it tries to create subshells. The problem is related to the one above where, again, when the shell is initially created, the first argument to the shell is not the directory in which the shell program resides. When this happens, command.com fabricates a value for its COMSPEC environment variable that is incorrect. Then, when other programs go to use COMSPEC to find the shell, they are given the wrong value.

The fix for this is to either prevent any arguments from being sent to the shell when it starts up (in which case command.com will use a default, and correct, value for COMSPEC), or to have the first argument be the directory in which the shell executable resides.

When I do any shell-related commands, nothing happens. What could be wrong?

Chris Boucher <chris@sorted.org> reports that Dr. Solomon's WinGuard prevents any shell related commands from working. He found that turning off "Scan all files" makes it work, though.

How do I use mail with Emacs?

You do not need to do much to use mail with Emacs under Windows, but you do need to be able to communicate with local mail daemons and mail servers (they do most of the work) to both receive and send mail from your system. These daemons and servers are typically running on the machines in your local network that are already handling mail for you and/or other users on other systems.

Outgoing

For outgoing mail, you need to use smtpmail.el, which enables Emacs to talk SMTP with mail daemons (smtpmail.el was originally written by Tomoji Kagatani <kagatani@rbc.ncl.omron.co.jp> and is now included in the Emacs distribution). You also need to add the following to your startup file (be sure to customize for you and your system):

(setq user-full-name "Your full name")
(setq user-mail-address "Your email address")

(setq smtpmail-default-smtp-server "Domain name of machine with SMTP server")
(setq smtpmail-local-domain nil)
(setq send-mail-function 'smtpmail-send-it)

(load-library "smtpmail")

Note that if you want to change the name of the smtp server after you've loaded smtpmail.el, you'll want to change the variable smtpmail-smtp-server.

If you are using GNUS to send mail, then you will also need:

(load-library "message")
(setq message-send-mail-function 'smtpmail-send-it)

If you are experiencing problems with sending large messages, check the value of the variable smtpmail-debug-info. If it is non-nil, you should set it to nil:

(setq smtpmail-debug-info nil)

Outgoing: Queued

If you would like to queue your outgoing mail so that you can then later send it all as a batch (e.g., when you are working disconnected on a laptop), you can use the feedmail package written by Bill Carpenter <bill@bubblegum.net>.

Feedmail comes with Emacs 20.

Fabio Somenzi <Fabio@Colorado.EDU> also sent the following as an example of setting up Feemail:

(setq send-mail-function 'feedmail-send-it)
(autoload 'feedmail-send-it "feedmail")
(autoload 'feedmail-run-the-queue "feedmail")
(setq feedmail-buffer-eating-function 'feedmail-buffer-to-smtpmail)
(setq feedmail-enable-queue t) ; optional
(setq feedmail-queue-chatty nil) ; optional

Fabio also redefined the function make-auto-save-file-name to auto-save files in one local directory ($HOME/.save) and to strip out invalid characters in file names . Note that all files will auto-save to this directory; this allows Emacs to auto-save even when the folder files are on an inaccessible remote machine. Place the following definition of make-auto-save-file-name in your startup file to override the definition in winnt.el.

Lastly, if you would like to protect the primary folder from crashes while it is being written back to disk, then also place the following in your startup file (assuming you use VM):

(add-hook 'vm-mode-hook
          '(lambda ()
             (make-local-variable 'file-precious-flag)
             (setq file-precious-flag t)))

Incoming: RMAIL and POP3

For incoming mail using the RMAIL package and a POP3 mail server, you need only place the following in your startup file (again, be sure to customize):

(setenv "MAILHOST" "Domain name of machine with POP3 server")
(setq rmail-primary-inbox-list
    '("po:Your login") rmail-pop-password-required t)

Note that you will need to customize the Domain name of machine with POP3 server and Your login fields to be the name of your POP server and your login name.

Incoming: VM and POP3

For incoming mail using the VM package and a POP3 mail server, you first need the vm package (check any elisp archive) and then you need to place the following in your .vm configuration file:

(setq vm-spool-files
      (list
       (list "~/INBOX"
             "POP3 server:110:pass:POP user name:*"
             "~/INBOX.CRASH")))

Note that you will need to customize the POP3 server and POP user name fields to be your login name and the name of your POP server. You will also probably want to customize the name of your inbox and crash files (~/INBOX and ~/INBOX.CRASH in the example above.)

Incoming: GNUS

You should be able to use Gnus 5.2 and above as a mail reader. The following was sent as an example by Marc Fleischeuers <Marc.Fleischeuers@kub.nl>:

(load-library "message")

;; For sending mail
(setq message-send-mail-function 'smtpmail-send-it)

;; For reading mail (other backends can be substituted for nnml)
(setq gnus-secondary-select-methods '((nnml "")))
(setq nnmail-spool-file "po:POP user name")
(setq nnmail-pop-password-required t)

Be sure to customize the POP user name field appropriately.

Using GNUS with IMAP

 Setting up Gnus for reading IMAP email.

There are a number of different mail packages available within emacs. Unfortunately, only two of them (Gnus and Vm) currently support IMAP. Of those, only Gnus supports IMAP as intended (leaving the messages on the server so that they can be accessed from multiple clients). Since our decision is made for us, here's how to set up Gnus for reading IMAP mail at LLNL.

    (setq load-path (cons (expand-file-name
      "~/emacs/elisp/gnus-5.8.7/lisp/") load-path))
   ;;
   ;; Gnus for IMAP
   ;;
   ; setup nnimap to read the correct mailspool
   (setq gnus-select-method
         '(nnimap "mail-imap"
             (nnimap-address "YOUR.IMAP.SERVER.HERE")))
   (setq nnimap-list-pattern "INBOX")

   ; I don't read usenet, so don't bother setting up a server for it
   ; If you do read usenet, just move the stuff above to here.
   (setq gnus-secondary-select-methods nil)
   (setq gnus-check-new-newsgroups nil)

   ; configure nnfolder to save sent messages and drafts
   ; in this case it uses folders named ``sent.YEAR'' which
   ; are created and rotated automatically
   (setq nnfolder-active-file (expand-file-name "~/News/archive/active"))
    (setq nnnfolder-directory (expand-file-name "~/News/archive/"))
   (setq gnus-message-archive-method
       '(nnfolder "archive"
           (nnfolder-inhibit-expiry t)))
   (setq gnus-message-archive-group (concat "sent." (format-time-string "%Y")))
   (setq nndraft-directory (expand-file-name "~/News/drafts"))

Sharing with Unix: RMAIL

If you want to share your rmail folders between Unix and Windows NT/95, you'll want to handle all your mail in binary format. This includes mail stored in folders as well as incoming mail. For mail stored in folders, you'll want to treat the directory in which you store your mail as an untranslated file system; see the section on translation below on how to do this.

For incoming mail using RMAIL, you'll need to make a small patch to rmail.el. See Don Erway's <derway@ndc.com> message describing the patch and what else he did to setup sharing between Unix and Windows NT/95.

Mail notification

Mail packages often provide some way to notify you when email has arrived (a la "biff" in Unix), conveniently distracting you from getting any real work done. There are myriad ways to do this, and as people tell me them I will try to mention them here.

Leaving on server: RMAIL

Franklin Lee <lee.franklin@worldnet.att.net> has extended the pop3 package so that you can have your mail left on the server instead of always being downloaded (it also has a biff-mode with international "barks", which can be used whether or not you download or leave your mail on the server). You'll need to download a zip archive containing a patched pop3.el and some additional elisp files:

If you unpack on Unix, be sure to use "unzip -a" to strip any carriage returns.

For instructions on how to install and configure this package so that you can leave your mail on your pop3 servers, see the instructions at the top of the epop3mail.el file.

This should potentially work with other mail packages that rely upon the pop3 elisp code. If you find that it does, or implement the glue necessary to make it work, let me know and I'll update this FAQ entry.

Leaving on server: VM

 vm doesn't use pop3 (it has its own code) and leaving email on the server runs 'out of the box'. use:

	(setq  vm-pop-expunge-after-retrieving nil)

 There's also a vm-pop-auto-expunge-alist variable.

Handling attachments: Metamail

19.34 Metamail is a package that allows you to receive and send MIME attachments using Emacs. For details, see the README file:

Note that this version only works with Emacs 19.34. John Dennis, who originally ported metamail, does not have the time to maintain the current version or upgrade it to Emacs 20. If you have the time and interest to do the upgrade, I encourage you to try. Many users would appreciate your efforts. John lists the following tasks that need to be done to do the upgrade:
* win32 symbols are now w32.  (That is all symbols, and functions that used to have a "win32" prefix now begin with "w32".

* new support for coding systems should be taken advantage of and old
references to binary vs. text for files and processes should be
upgraded to the v20 approach.

* deal with the references to mule and junet which are now wildly out of date.

Handling attachments: MIME with tm

I don't know of any complete ports of tm to the Windows environment, but Fabrice Popineau <popineau@esemetz.ese-metz.fr> has made some modifications to the OS2 version of tm. See his description of what he has done for more info. The support programs mentioned can be found in mm.zip (note that they have only been tested on NT 4.0, though).

Biff tools: POP

Gian Uberto Lauri <lauri@eng.it> has written a win-biff tool for use with pop mail servers. [More Info]

How do I read news with Emacs using Gnus?

To read news with Emacs, you can use the Gnus package. To invoke Gnus, type "M-x gnus" and Emacs will prompt you for a news server to connect to. For more information about using Gnus, take a look at:

How do I authenticate with Gnus?

If you need to connect and post to an authenticated news server, you'll need to give Gnus a password to send along to the server. To have Gnus prompt for a password, add the following to your startup file:

(add-hook 'nntp-server-opened-hook 'nntp-send-authinfo)

For more discussion and other methods of giving Gnus a password, see a discussion on the topic.

How do I use mime with Gnus?

See the "Does Gnus have MIME support?" question from the Gnus FAQ.

How do I save messages in untranslated format?

To save messages untranslated (no carriage returns), you must set the default-buffer-file-type to binary:

(setq default-buffer-file-type t)

How do I read online newspapers with Emacs?

David Finucane <finucane@myri.com> has written an elisp/Java package that makes it easy to read online newspapers through Emacs:

Recent versions of GNUS can also handle reading some web sites as news, Slashdot.org for example.

How do I use the w3 package?

Download the latest version from the W3 homepage, ftp://ftp.xemacs.org/pub/xemacs/emacs-w3/ and follow the directions in the README.NT file.

 You may find helpful information at the w3 homepage : http://www.cs.indiana.edu/elisp/w3/docs.html.

How do I use the browse-url package?

20.4 and later You should be able to use the browse-url package that comes with the Emacs distribution. It uses a new function to replace the external shellex helper program (see `w32-shell-execute' for details.

Package for using browse-url for dictionary, search, etc. functions

Peter Breton <pbreton@i-kinetics.com> wrote a small package for using browse-url to do dictionary lookups, internet word searches, etc. The package is called simple-web.

How do I use Emacs to translate text among languages?

David Finucane <finucane@myri.com> has written an elisp/Java package that uses the AltaVista translation service to translate text among a number of languages.

How do I use FTP, (ange-ftp), within Emacs?

20.3

Emacs 20.3 comes with an ange-ftp.el that can use the standard Windows ftp.exe, so you should not need to download anything to use ange-ftp.

If you are behind a firewall you may have problems, because the native FTP client doesn't support passive mode, if this is the case then you'll need to download ftp-for-win32.zip, and follow the instructions below.

Place the ftp.exe executable in a directory where you keep your local executables. Then be sure that the exec-path variable is set so that, when Emacs runs the ftp.exe program, it runs the one you downloaded (and not the default one). As an example, assuming that you placed ftp.exe in, say, %HOME%\bin, you could set exec-path as follows in your startup file:

(setq exec-path (cons (expand-file-name "~/bin") exec-path))

As another alternative, you can tell ange-ftp exactly which ftp program to use by customizing ange-ftp-ftp-program-name, e.g.:

(setq ange-ftp-ftp-program-name "c:/bin/ftp.exe")

With this method you don't have to worry about the wrong ftp program being picked up through exec-path.

You will also want to customize the temporary directory that ange-ftp uses to cache files:

(setq ange-ftp-tmp-name-template
      (concat (expand-file-name (getenv "TEMP")) "/ange-ftp"))
(setq ange-ftp-gateway-tmp-name-template
      (concat (expand-file-name (getenv "TEMP")) "/ange-ftp"))

How do I use telnet with Emacs?

Before you can use telnet-mode from within Emacs, you need a telnet client other than the one found on the system; the system telnet is a windows app, and cannot be used as a subprocess since it does not use stdio for input and output.

Two possible telnet clients that you can use are:

How do I use TeX with Emacs?

(Note: If you use anti-virus software, see the warnings above.)

You will need to get an implementation of TeX The TeX User's Group (TUG) maintains a list of TeX implementations at:

MiKTeX

 MiKTeX is a native Windows implementation of the TeX document processing system. The MiKTeX project page is at http://www.miktex.org.

 The project page has instructions on where to download the distribution and how to install it.

AUCTeX

AUCTeX is a package for writing LaTeX files in Emacs. The AUCTeX project page is at http://sunsite.auc.dk/auctex, and has links for downloading the distribution and reading the manual. Lars Schmidt-Thieme <lschmidt@ix.urz.uni-heidelberg.de> has written instructions on how to use AucTex with MikTex and Emacs.

FPTeX

FTTex is another port of a TeX system for windows - it is much closer to the Unix TeX, for more details please see : http://www.tug.org/interest.html#free.

Putting it all together

Willem Minten <Willem.Minten@esat.kuleuven.ac.be> has put together a page that has everything you need to get MiKTex, AucTeX, and Emacs working together. If you're starting from scratch, look here first.

How do I perform spell checks, using Ispell?

Ispell version 3 is the latest official supported version of the ispell package for Windows.

Ispeel 3.1 has support for multiple languages, and may be used in flyspell-mode.

The Cygnus port of ispell 3.1 works well with Emacs and the flyspell package. [Details]

Emacs for SGML editing and publishing on Windows

Lennart Staflin has written a mode called PSGML for editing SGML documents. The latest beta release also supports XML. All releases may be found at:

An SGML validator is included in James Clark's DSSSL Engine, Jade.

Markus Hoenicka has prepared an NT-specific installation guide for PSGML, Jade and many related and useful packages at:

Emacs and Encryption, using GPG - or PGP

GNU Privacy Guard is a free replacement for PGP which runs on many Unix systems, and also Windows. GPG can be found at http://www.gnupg.org.

GPG, and PGP can both be used with the version of mail-crypt find mailcrypt at ...

How do I use an Intellimouse with Emacs?

The Emacs 20.3 pretests and above support the Intellimouse on both NT and Win9X. Emacs 19.34.6 supports it on NT, but not on Windows 95.

Clicking the mouse wheel is interpreted as a mouse-2 event, which is normally bound to mouse-yank-at-click (i.e., paste). Since it is easy to accidentally click the mouse wheel, you might find that you inadvertantly paste text as you scroll the wheel. To prevent this from happening, you can disable the mouse-2 binding in your startup file:

(global-unset-key [mouse-2])

Walt Buehring <buehring@i2.com> has extended the implementations of mouse-wheel-scroll-line and mouse-wheel-scroll-screen. To use, download and place in your startup or site-init files.

For more details on interpreting mouse-wheel events in elisp, see Michael Duggan's <md5i@schenley.com> description of the implementation.

Interactions with FlyWheel

Apparently, FlyWheel and Emacs Intellimouse support don't work together. You can selectively disable FlyWheel for Emacs using a registry entry; see the FlyWheel README for how to disable it for a specific application.

Why does Emacs ignore my mouse wheel?

Emacs is incompatible with the latest versions of mouse wheel devices. To get your mouse wheel to work with Emacs, you'll need to select some options in the device setup panels.

How do I use perl-mode with Emacs?

A perl-mode comes with the Emacs distribution, and will be used when you load and edit Perl files.

Users have also recommended an alternate mode named cperl-mode. You can get this from ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl/.

How do I use the perl debugger with Emacs?

From Jay Rogers <jay@rgrs.com>:

There are potentially two problems that cause the perl debugger to hang when started in emacs. One's an emacs problem while the other's a perl problem.

First, get Emacs 19.34.4 or later for Windows 95/NT. It contains a fix that allows emacs to read all ASCII characters from the perl debugger, including the dreaded ^Z (aka EOF in DOS). It also groks the "drive:path" filename notation.

Second, some versions of the perl debugger itself need to be patched to work with emacs. They are perl versions 5.001 and less, and version 5.004_01. To fix, locate and change the code similar to the following code in lib/perl5db.pl

    if (-e "/dev/tty") {
        $console = "/dev/tty";
        $rcfile=".perldb";
    }
    elsif (-e "con") {
        $console = "";                 <---- change "con" to ""
        $rcfile="perldb.ini";
    }
    else {
        $console = "sys\$command";
        $rcfile="perldb.ini";
    }

Doug Campbell <soup@ampersand.com> also has some suggestions for improving the interaction of perldb and Emacs.

How do I use python-mode with Emacs?

The python-mode shipped with Python 1.5 requires a new custom.el before it can be used with Emacs 19.34. For more information, see the description of python-mode at http://www.python.org/emacs/python-mode/.

How do I use grep with Emacs?

To use grep with Emacs, you first need to obtain a version of grep. Many of the packages listed in the section below on Unix Tools come with a version of grep (and cousins egrep and fgrep). Once you have grep, be sure that it is in your system path or in Emacs' exec-path. Then you should be able grep from within Emacs using "M-x grep".

If you can't get access to grep, then you can use the findstr program that comes with Windows NT and Windows 95 instead. It is much more limited in its searching ability, but if you have simple needs it may be adequate. Peter Breton <pbreton@i-kinetics.com> shows you how to do this.

Some users find the igrep package to be a more useful package for using grep (for example, it supports recursive greps directly). Here are some pointers from other users on what you need to do to get igrep working on your system. You can download igrep from the elisp archive at ftp://ftp.cis.ohio-state.edu/pub/emacs/emacs-lisp/misc/igrep.el.gz.

How do I do a recursive grep?

To do a recursive grep, you need the help of some other utilities. Probably included in the same package that has grep will be find, a program that can recursively traverse directories and invoke programs on the files it finds. To do a recursive grep with find, invoke "M-x grep" and run the following command:

find . -name pattern -exec grep -n string NUL {} ;
(Note that find is not the same program as the find that comes with Windows, rather a port of the GNU Findutils component).

The pattern argument determines which files are matched (e.g., "*.c" for all .c files). The string argument specifies the string that you are searching for. And the NUL argument is a standard way to ensure that grep reports filenames in the matches (grep reports filenames when it is invoked on more than one file, and the NUL device is simply another file that will never contain matches; on Unix, you would use /dev/null).

If you also have the xargs program, than you can make the recursive grep more efficient. Instead of the above command, use:

find . -name pattern -print | xargs grep -n string NUL

The xargs command collects lines from its input and concentates them together as one list of arguments, and invokes the specified program with the argument list (breaking the arguments up into multiple lists and invocations if necessary). The above command first uses find to print out the set of filenames that match pattern, which then gets passed to xargs. xargs concatenates the lines of filenames into lists of arguments and invokes grep on them.

How do I use the EDT emulation mode in Emacs?

To use the EDT emulation package distributed with Emacs, place the following in your startup file:

(setenv "TERM" "pc")
(setq term-setup-hook 'edt-emulation-on)

You might want to also browse through the EDT emulation documentation in etc/edt-user.doc. It describes which keys are emulated, how they are mapped onto the keypad and function keys, etc.

How do I do desktop saving with Emacs?

Desktop saving refers to the ability to save and restore editing sessions (state of frames and buffers) between uses of Emacs. Kevin Greiner <kgreiner@geosys.com > has collected some elisp for using the desktop saving features of Emacs that should prove useful for others interested in the feature.

Jari Aalto <jari.aalto@poboxes.com> also has collected references to packages that save Emacs state and screen and window position.

Chuck Siska <chuck.siska@conexant.com> wrote his own desktop frame window layout save and restore package called desktop-frame.el.

How Do I Use Emacs with Microsoft Visual C++

VisEmacs

For a close coupling of Emacs and MSVC, Christopher Payne <payneca@sagian.com> wrote a Visual Studio add-in that makes Emacs the default text editor. See http://www.rose-hulman.edu/~payneca/emacs/VisEmacs.html for more info on what it can do and how it works. For information on how to customize your general development environment to use Emacs with MSVC, read Charles Curley's text below. For VisEmacs alpha executables, download this VisEmacs.zip distribution.

Jeff Paquette <paquette@mediaone.net> made a small addition to VisEmacs to disable it during a debugging session. See http://atnetsend.ne.mediaone.net/programming.html#Visemacs for info and files.

VC5/VC6 issues.

Emacs and MSVC

Written by Charles Curley with a lot of help from: David Biesack, Caleb T. Deupree, John Huxoll Gardner, Anders Lindgren, and John Yates.

This is an app note on how to use Microsoft Visual C++ with Emacs. The experiments done below were done with Emacs 19.34.1 on Windows 95, using Visual C++ 4.0 Standard Edition. Your mileage may vary.

This writeup assumes minimal knowledge of Emacs hacking on the part of the reader.

VC++ Environmental Variables

First, Emacs requires any environmental variables to be set at boot time, in autoexec.bat (for Windows 95). This includes variables such as HOME. So if you haven't already done so, set the environment up so that Emacs' compile mode will correctly run VC++. There is a batch file in your VC++ installation's bin directory called "vcvars32.bat". Call it from your autoexec.bat file. Make sure you use the "call" keyword, or execution never returns from the called batch file. Here is what the relevant portion of my autoexec.bat looks like:

rem set up for MS C++ 4.0
call d:\msdevstd\bin\vcvars32.bat

Under NT, you can set the HOME and other environment variables in the System applet of the Control Panel.

John Huxoll Gardner writes that

These environment variables can be set through the control panel.

Control Panel->System->Environment tab

set include to d:\msdev\include;d:\msdev\mfc\include (or whatever)
set lib to d:\msdev\lib;d:\msdev\mfc\lib (or whatever)
set MSDevDir to d:\msdev

You should now be able to compile from Emacs. Load a source file from a VC++ project. Type M-X compile. Replace the proposed command line with:

nmake -f MyProject.mak

You will find that this defaults to a win 32 debug build. You can change it to a release build with:

nmake -f MyProject.mak CFG="MyProject - Win32 Release"

By the way, you can scroll in the M-X command buffer with up and down arrows. You can also scroll in the compile command buffer with the up and down arrows. Both seem to be fully editable as well.

Setting the Default Command Line

Now set up the default value for the compile command line. Add the following to your .Emacs:

; Set up for Visual C++ compiling
(setq compile-command '("nmake -f .mak " . 10))

If you work on the same project extensively, toss that in to the default string. You can always override it when you work on another project.

By the way, many if not all Microsoft command line programs now accept a dash (-) as a switch specifier as well as a slash (/). This was true as long ago as Mess-DOS 6.0, I believe. I use it because that eliminates one area where I have to remember which OS I am using. :-)

David Biesack suggests that perhaps it's easy to define Makefile in the project directory which does

PROJECT=MyProject
all: debug
debug: FORCE
        nmake /f $(PROJECT).mak CFG="$(PROJECT) - Win32 Debug"
release: FORCE
        nmake /f $(PROJECT).mak CFG="$(PROJECT) - Win32 Release"
FORCE:

and then you can simply change compile-command to "nmake".

Caleb T. Deupree reports that on VC++ 5.0 and up, "You can also set an option on Options/Build to export a makefile every time the project is saved, which you can then use to compile with 'nmake -f project.mak'." VC++ 4.0 builds the make file every time, and there is no option.

Handling Compile Time Errors

Those of you who never get compile time errors can skip this section.

One of the things that compile.el provides is the ability to scan the output from a compile session, and move from error message to error message. This facility depends on a series of regular expressions ("regexes") which are applied to search the compiler output. Normally, you shouldn't have to do anything. However, if you have problems with this facility, you can comment out the regexes you don't need and recompile. Search the file for "compilation-error-regexp-alist" and comment out as needed.

To recompile, make the file the active buffer. Emacs will recognize it as an elisp file, and add a pull-down menu for elisp functions. One is for compiling, the other will compile and then load.

By the way, the best (and so far, only :-) book I've seen on regular expressions is Jeffrey E. F. Friedl, *Mastering Regular Expressions*, O'Reilly & Assoc, Inc, 1997. It covers regex syntax and usage for Emacs, perl and other tools that regexes.

Reverting Buffers

Then there is the problem that sometimes you modify the source from Microsoft's IDE. Here's some help for that.

Occasionally, you need to add a new function or variable from the Visual C++ IDE. This means that the copy of the file in your Emacs buffer is now obsolete. The simplest thing to is a two part manual effort. First, before you leave Emacs for VC++, make sure you save all your buffers (C-X S). When you return, you can revert buffers you know have been changed with M-X revert-buffer. If you try to modify a file that has been changed from outside Emacs (say, by VC++), Emacs will warn you and offer you the chance to revert the buffer, so you can safely try modifying files after making a change from VC++.

However, this depends on the user remembering to do something, always a hazard. The obvious way to handle the problem is to automate it, which Anders Lindgren has already done. He writes:

This feature will be present in the next version of Emacs.  There will be
two modes, `global-auto-revert-mode' that applies to all buffers while
`auto-revert-mode' can be activated for individual buffers.

You can get the latest version from:

    http://www.csd.uu.se/~andersl/emacs.shtml

Please note that this feature comes with a prize: Normally Emacs acts like
an extra backup system, keeping a copy of the files you are editing.
Should some external program mess up a file, you can always save the copy
you're editing.  When using Auto-Revert mode Emacs will happily load the
corrupt file, perhaps ruining you last chance to restore the original file
content!

        -- Anders

;; .signature -- File added to the end of mail, containing joke or info.
(defvar me '((profession . "Compiler Designer") (company . "IAR Systems")
  (age . 27) (country . "Sweden") (hair . "Long") (water-skier . t)))
;; .signature ends here.

(Now, *that* is an elisp hacker's sig line! :-)

The next version of Emacs to which Anders refers is, I believe, 20. I don't know when it will be released.

If you can't wait, you can scarf the source for autorevert.el in from Anders' web page. However, it is dependent on another Emacs package, Custom, which is not in the version of Emacs I have (19.34.1). Custom is available at http://www.dina.kvl.dk/~abraham/custom/. Installing the Custom package is beyond my meager elisp hacking skills, so you are on your own there. The next release will also include Custom.

Caleb T. Deupree also writes, "You might also mention a package mode-compile.el, which is a wrapper around compile mode and is available from the Emacs lisp archive or from http://www.cenatls.cena.dgac.fr/~boubaker/Emacs/index.html. It detects makefiles in directories and parses them for valid targets, performing many of the same tasks which you do in your hooks."

Exporting a File to Emacs

You can also set up VC++ to import a file into Emacs for you, all ready for editing. You will need the Gnuclient package, which is used to associate file extensions with Emacs. In VC++, go to the Tools pulldown menu, and click on Customize.... In the Tools tab, click on Add. Use Browse to locate your gnuclientw.exe file, and select it. For arguments, use +$(CurLine) "$(FilePath)" and for the directory use the $(WkspDir) (the quotes around FilePath handle paths with spaces in them). Set the Menu Text to say "Em&acs". The "+$(CurLine)" will set point in Emacs to the same line as the cursor position in VC++. The ampersand in the word "Em&acs" allows you to select emacs from the keyboard. (E is already used for the OLE control test container.)

You should now be able to go to any source file in your project. Then, use the pull-down menu Tools->Emacs. The active file in your VC++ ide should now be front and center in Emacs, all ready to edit as you wish. If you use keystrokes to work the menus, try <alt>T A to move the file into Emacs. Binding this tool to a keystroke will be left as an exercise for the student.

If you have the option of saving files before running tools, make sure this option is set. (I don't see it on VC++ 4.0.)

Emacs and Borland C++ Builder

Jonathan Arnold's <jdarnold@buddydog.org> EmacsEdit "expert" for interfacing C++ Builder and Emacs.

Java

How do I get imenu to work with Java?

Howard Melman <howard@silverstream.com> has put together some elisp to get imenu working with Java.

Creating TAGS files for Java source

To create TAGS files for Java source files, use Paul's JDE below.

Java Development Environment

Paul Kinnucan <paulk@mathworks.com> has also implemented a Java Development Environment:

The JDE is an Emacs Lisp package that provides a highly configurable Emacs wrapper for command-line Java development tools, such as those provided in JavaSoft's JDK. The JDE provides menu access to a Java compiler, debugger, and API doc.

The JDE can be found at http://sunsite.auc.dk/jde/ (also mirrored at http://www.geocities.com/SiliconValley/Lakes/1506/).

Since NT Emacs version 20.3.1: Support for jdb has been added to gud.el package.

The Jacob class browser and project manager

Jacob is a Java class browser and project manager for Emacs written by Clemens Lahme <Clemens.Lahme@gmd.de>. For details about Jacob, see http://home.pages.de/~kclee/clemens/jacob/.

Example instructions for installing Emacs/JDE/JDK

David Fellows' <fellows@roo.cs.unb.ca> recipe for installing Emacs, JDE, and the Sun JDK: http://www.cs.unb.ca/courses/gen/getit-iz.html.

It provides emacs-19.34-6/jde-2.0.9/jdk-1.1{6,7}/rcs-5.7 plus some customizatins we feel are suitable for java begginners. Installation is supposed to be a "no-brainer"; most times it is.

A caveat: Sun has just released jdk1.1.7 (and withdrawn 1.1.6) so the install file takehome.bat needs to be revised accordingly - the comments should make it obvious what to change. I will be updating the distribution to reflect this no later than this weekend.

How do I use revision/source control with Emacs?

Is there a version of RCS for Win32?

There are a number of RCS x86 executables floating about. There is an "official" port of GNU RCS available, but it has the semantics that files are managed in CR/LF format. This causes problems if your files are shared with programs on Unix hosts (for more info, see Kai Rommel's message). The version of RCS in the Reed Kotler toolset, on the other hand, does not change the line format. Your call.

The "official" port of GNU RCS can be found in the following places:

DOS, Win95/NT and OS/2 32-bit executables (including diff), as well as formatted documentation files:

ComponentSoftware CS-RCS is a Windows front end to GNU RCS. Single user use of their software is free, and they even have directions on how to use it with Emacs:

David Matyas <davidm@ComponentSoftware.com> By default, CS-RCS check-out files using the Windows line-break conventions (<cr><lf>), as this mode is reasonable for most of the users. A "UNIX-Style" mode is available as well. (This mode is used mainly by users uses the Windows workstation as an X-Terminal.)

The Reed Kotler toolset can be found at http://www.reedkotler.com.

Note: If the version of RCS you are using does not append the traditional ",v" to RCS files, try setting the environment variable "RCSINIT" to "-x,v" ("set RCSINIT=-x,v").

Is there a version of CVS for Win32?

You can find a free port of CVS from Cyclic Software.

If you use the pcl-cvs package, you'll need to fix a couple of things in the elisp to make it work on NT; Michael M. Schmitz <ms@ley.de> has some instructions describing what you need to do. John D. Amidon <jda@jhk.com> gives an example of what he used to set up pcl-cvs in his .emacs.

What do I need to do to get vc-mode (version control) working?

If you are having trouble getting vc-mode working with RCS or CVS, take a look at Peter Cherna's <peter.cherna@scala.com> problem description and fix.

vc-mode and Clearcase

Andy Eskilsson <andy.eskilsson@telelogic.se> has modified vc-mode to work with Clearcase, and it reportedly works very well; see http://www.fukt.hk-r.se/~flognat/vc/

Jari Aalto <jari.aalto@poboxes.com> has a page about using Clearcase software with Emacs. See "9.8 Clearcase software" at ftp://cs.uta.fi/pub/ssjaaa/emacs-elisp.html.

How do I use perl-mode with Emacs?

A perl-mode comes with the Emacs distribution, and will be used when you load and edit Perl files.

Users have also recommended an alternate mode named cperl-mode. You can get this from ftp://ftp.math.ohio-state.edu/pub/users/ilya/perl/.

How do I use the perl debugger with Emacs?

From Jay Rogers <jay@rgrs.com>:

There are potentially two problems that cause the perl debugger to hang when started in emacs. One's an emacs problem while the other's a perl problem.

First, get Emacs 19.34.4 or later for Windows 95/98/NT. It contains a fix that allows emacs to read all ASCII characters from the perl debugger, including the dreaded ^Z (aka EOF in DOS). It also groks the "drive:path" filename notation.

Second, some versions of the perl debugger itself need to be patched to work with emacs. They are perl versions 5.001 and less, and version 5.004_01. To fix, locate and change the code similar to the following code in lib/perl5db.pl

    if (-e "/dev/tty") {
        $console = "/dev/tty";
        $rcfile=".perldb";
    }
    elsif (-e "con") {
        $console = "";                 <---- change "con" to ""
        $rcfile="perldb.ini";
    }
    else {
        $console = "sys\$command";
        $rcfile="perldb.ini";
    }

Doug Campbell <soup@ampersand.com> also has some suggestions for improving the interaction of perldb and Emacs.

How do I use python-mode with Emacs?

The python-mode shipped with Python 1.5 requires a new custom.el before it can be used with Emacs 19.34. For more information, see the description of python-mode at http://www.python.org/emacs/python-mode/.

Where can I get general information about Emacs?

If you have general questions about Emacs, the best places to start looking are the Emacs manual and the standard Emacs FAQ. If you already have Emacs, you can browse the manual using Info by typing "C-h i m Emacs RET", and you can view the FAQ by typing "C-h F". Or you can browse both of them online:

NTEmacs Mailing List

NTEmacs has a vibrant and helpfull mailing list, for people to report problems, and suggest improvements.

The name of the NT Emacs mailing list is ntemacs-users@cs.washington.edu. It's a majordomo administered list, so, if you would like to subscribe to the mailing list, send a message to ntemacs-users-request@cs.washington.edu with the word "subscribe" in the body of the message.

To unsubscribe from the list, send a message to ntemacs-users-request@cs.washington.edu with the word "unsubscribe" in the body of the message. Please do not send the unsubscribe message to the list itself, but to the request alias instead. Sending the message to the list does not unsubscribe you from it, and it tends to be annoying to people on the list.

If you are trying to unsubscribe from the list but are encountering problems, send me mail directly and I will manually remove you from the list. Again, do not send mail to the list complaining that you cannot unsubscribe from it.

Extra information about MULE

There are several sites that may be of interest to users of MULE: ftp://ftp.etl.go.jp/", and ftp://ftp.scphys.kyoto-u.ac.jp/ both contains papers written by the original developers of Mule., and http://www.m17.org/ is another site with Multilingual info.

I've recently discovered that there are also two MULE mailing lists, one in Japanese and another one in English. The English list is low traffic but alive. To subscribe, send

subscribe

to mule-ctl@m17n.org.

Where can I find more Lisp packages?

The best place to start looking is in the newsgroup gnu.emacs.sources, this can be searched online via Deja.com

After that the Emacs Lisp List, which is maintained by Stephen Eglen <stephen@anc.ed.ac.uk> , is another good starting point, this lists several hundred lisp files, and a brief description, and thanks to ell.el can be used from within Emacs.

Many people maintain small pages of packages that they have written, or maintain - the best way to

Reading MAN pages without Man, (WoMan)

WoMan allows Unix MAN pages to be browsed within Emacs, this lisp package requires no external programs.

Find it here; http://centaur.maths.qmw.ac.uk/Emacs/WoMan/.

Where can I find a port of the diff program (e.g, for ediff)?

You'll need a port of diff before you can use the ediff package in Emacs. Each of the GNU-Win32, UWIN, and Reed-Kotler toolsets have a port of diff that you can use with Emacs; see the Unix tools port section below. If you just want diff and aren't in the mood for switching to a new toolset environment, then you can download the RK toolset and use the diff from there in isolation.

Where can I find a port of the patch program?

Patch 2.5 based upon mods by Tim Smith <tzs@halcyon.com> and a few by Andrew Innes <andrewi@harlequin.co.uk>:

What other Unix tools have been ported to NT and/or Windows 95/98?

Probably the first place you should look for more GNU tools is at Cygwin toolset. The toolset is a port of the GNU tools to the Windows API, as well as a set of libraries that allow Unix programs to compile to Windows with little or no modification. The project is at http://sourceware.cygnus.com/cygwin/

Michael Main <main@cs.colorado.edy> has collected together ports of various Unix programming environments and languages to Windows for classes that he teaches. See http://www.cs.colorado.edu/~main/plcd.html for an overview; e.g., a version of the mingw32 port of Unix tools is at http://www.cs.colorado.edu/~main/mingw32/.

There is also a directory of GNU software which has been ported to the Windows platform, which is available at http://www.gnusoftware.com/. This directory also contains several patches for Emacs running on Windows, to give extra functionality, see here for details.

The UWIN project at AT&T Research is another project whose goal is to enable UNIX applications to build and run with little or no modification on Windows NT/95. Part of the UWIN project includes a port of ksh done by David Korn. For more information, see http://www.research.att.com/sw/tools/uwin.

An older set of the GNU tools that I have seen offered on ftp sites for NT and Windows 95 have been based on the Congruent tools (I have heard mixed reviews of these ports, so use with your own discretion). An ftp site that seems to offer the full set of these tools is ftp.cc.utexas.edu/microlib/nt/gnu.

Microsoft also has a collection of tools for use with NT, including Unix tools such as cron, ps, kill, and nice, as well as a number of NT specific tools. A list of these tools is at http://www.microsoft.com/ntserver/nts/exec/vendors/freeshare/maintnce.asp.

If you're a perl user, then you probably want the port of perl to Windows. You can download a perl distribution from any of the CPAN mirror sites, such as ftp://ftp.cdrom.com/pub/perl/CPAN/ports/win32/Standard/. For a complete list of CPAN mirrors, see ftp://ftp.cdrom.com/pub/perl/CPAN/SITES.html.

David Wihl is maintaining a FAQ about porting Unix applications to NT. It can be found at http://www.nentug.org/unix-to-nt.

Chris Szurgot is also collecting and implementing Unix style tools for Windows 95 (and presumably NT). See http://www.itribe.net/virtunix.

Jeff Paquette <paquette@mediaone.net> has a collection of the GNU text utilities for Windows. See http://atnetsend.ne.mediaone.net/~paquette/WinProgramming.html.

Reed Kotler <reed@reedkotler.com> and Budi Sutardja have created a toolset of Unix tools (shells, bin and text utils, and one of his packages even includes a precompiled version of Emacs). See http://www.reedkotler.com.

NTWare.com collects free software for NT (Win9X?).


Combined Document | Split Document
Steve Kemp, FAQ Maintainer
<skx@tardis.ed.ac.uk>
Translate this page into