GNU Emacs on Windows NT and Windows 95/98

The latest release is 20.4.1 (July 23, 1999) [More Info][Download]

Emacs occasionally hanging InstallShield? See troubleshooting below.

Shells and subprocesses don't work? Using anti-virus software? See anti-virus problems below.

Using bash from Cygwin-b19? See bash below.

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.

It is also being mirrored directly at:
cs.washington.edu in Washington, USA
ic.uva.nl in Netherlands
(Split into sections)
http://www.tardis.ed.ac.uk/~skx/win/NTEmacs.html

Last modified: July 20, 1999

Table of Contents

(The date after an entry denotes the date of last edit.)

  1. What is Emacs?
  2. Which versions of NT and Win95/98 are supported?
    Related ports: MSDOS and Windows 3.11, MULE, XEmacs, MacOS
  3. Where can I get more information about Emacs? (9/18/98)
  4. Emacs 20.4 (7/24/99)
  5. Emacs 20.3 (8/28/98)
    Upgrading from 19.34.6 to 20.3 (10/5/98)
    command.com shell on Win95/98 (8/31/98)
    speedbar (8/31/98)
    sending mail generates the warning "unknown extension size ..." (9/1/98)
    printing (9/3/98)
    which-func-mode (9/23/98)
    runemacs.exe does not run, and temacs.exe does not dump (9/15/98)
    AUCTeX fails with buffer read-only (9/28/98)
    igrep 2.82 (10/5/98)
    lazy-lock (10/5/98)
  6. How do I get an Emacs distribution?
    Where can I get the source distribution?
    Where can I get precompiled versions?
    How do I unpack the distributions?
    What do I do if Emacs does not work?
  7. I don't want the precompiled version. How do I compile Emacs myself?
    How do I use a debugger on Emacs? (9/3/98)
  8. How do I install Emacs?
  9. How do I run Emacs?
  10. How do I uninstall Emacs?
  11. When I run Emacs, nothing happens. What's the deal?
    Emacs used to work fine. But now it won't start, and I didn't change anything in Emacs:
    HeapAgent
    Starfish Internet Monitor
    Aventail AutoSOCKS
    InstallShield (9/3/98)
    I just upgraded the operating system, and Emacs no longer works.
  12. I use anti-virus software. What problems can this cause? (1/6/98)
    Dr. Solomon's
    McAfee (2/9/98)
  13. Why does Emacs seem to perform slowly under certain conditions?
    Menu bar updates
    Transient mark mode
  14. How does Emacs determine the name of my computer? (3/20/98)
  15. Why does Emacs ask me to connect to my dialup service when it starts up?
  16. When I run Emacs, a console window pops up. How do I make it go away?
  17. Why does Emacs overwrite the same file using different filenames?
  18. Where do I put my .emacs (or _emacs) file?
    Samples (9/15/97)
  19. How can I modify Windows to be more like the X Windows System?
    How do I swap CapsLock and Control? (1/21/98)
    How do I get tab file completion with cmd.exe? (7/25/97)
    How can I have focus follow the mouse?
    How can I have menus popup immediately?
    Unix window managers and other tidbits (3/31/99)
  20. How can I modify Emacs to be more like a Windows app? (6/11/97)
    Keypad keys, highlighting selections, etc. (6/11/97)
    Window operations (maximize, minimize, etc.) (6/11/97)
    Standard Windows application keymaps (C-c, C-v, C-x, etc.) (3/8/98)
    Open File dialog box (10/5/98)
  21. How do I change the size, position, font, and color attributes of Emacs?
    Windows Interface: Size, Position, Fonts, and Colors.
    Customizing frame appearances.
    Determining screen resolution. (6/19/97)
    Information on italic fonts.
    Console Interface: Size, Position, Fonts, and Colors.
  22. How do I enable color syntax highlighting in Emacs (font-lock)? (7/17/97)
    Converting font-lock buffers into HTML markup (4/29/98)
  23. How do I change the format of the mode line? (10/8/97)
    How do I change the mode line EOL character mnemonics? (10/8/97)
  24. What do I do if I have problems with Emacs and my mouse buttons?
    How do I use Emacs with a two-button mouse?
    How do I get Emacs to recognize the third button on my mouse? (1/17/98)
    Strange two-button mouse behavior on Windows 95.
  25. How do I run Emacs in console mode?
    Emacs in console mode goes beyond the window size. What do I do?
  26. How do I highlight the region between the point and the mark?
  27. How do I highlight matching parentheses?
  28. How do I cut & paste text with null characters? (3/10/98)
  29. How do I change the sound of the Emacs beep?
  30. Emacs multilingual font support (updated 7/24/98)
    Is it now possible to display correctly the sample of various scripts and languages accessible from the MULE menu?
    How do I get Emacs to display characters other than ISO-8859-1 (West European)? (updated 7/24/99)
    Where can I find fonts for other languages? (updated 7/24/99)
    How do I use third party programs for displaying multibyte characters with Emacs? (12/2/98)
    How do I use a font with a name in my language? (4/28/99)
    When I yank previously copied or killed text into a buffer, it appears garbled. How can I fix this? (updated 7/24/99)
    How do I get Emacs to display Smartquotes, the Euro symbol and other Microsoft additions to the ISO-8859 character sets?
    How do I print all these languages that Emacs is now displaying? (7/24/99)
  31. How do I use bdf fonts with Emacs? (1/22/99)
  32. How can I have Emacs use a font menu similar to the one it uses on Unix (with fonts and fontsets listed)?
    The font I want to use is not in the font menu, how can I put it there?
  33. How do I use leim with Emacs? (10/5/98)
  34. How do I display different character sets with Emacs?
    ISO 8859/1 (Latin 1) using an OEM (MSDOS) font (2/12/98)
    Displaying multibyte character sets (10/14/98)
  35. Subprocesses under Emacs
    Quoting issues
    Programs reading input hang
    Buffering in shells
    DOS subprocesses
    16-bit subprocesses accessing the A: drive (7/11/97)
    Killing subprocesses on Win95/98
    Interrupting subprocesses in Emacs (e.g., C-c C-c in shell buffers)
    Sending eof to subprocesses in Emacs (e.g., C-c C-d in shell buffers)
  36. How do I use a shell in Emacs?
    bash ksh MKS ksh tcsh zsh
    What do I do about the "No match 2 in highlight..." error I get from sh-script.el? (6/19/97)
    How do I prevent ctrl-m's from being printed in the shell?
    How do I prevent shell commands from being echoed?
    How do I have Emacs complete directories with "/" instead of "\"?
    Why is a "Specified COMMAND search directory bad" message printed?
    Within a shell, when I run programs I get "Incorrect DOS version" messages. Why?
    When a do any shell-related commands, nothing happens. What could be wrong?
  37. How do I use mail with Emacs?
    Outgoing: Standard, Queued
    Incoming: RMAIL and POP3, VM and POP3, GNUS.
    Mail notification. (1/16/98)
    Leaving on server: RMAIL. (9/28/98)
    Sharing with Unix: RMAIL.
    Handling attachments: Metamail, MIME with tm, (9/16/97)
    Biff tools: POP (6/25/99)
    Obscure problems: Win95.
  38. How do I read news with Emacs using Gnus?
    How do I authenticate with Gnus?
    How do I use mime with Gnus?
    How do I save messages in untranslated format?
  39. How do I read online newspapers with Emacs? (10/8/98)
  40. How do I use TeX with Emacs? (7/25/97)
    MiKTeX.
    AUCTeX.
    Putting it all together. (9/20/97)
  41. Emacs for SGML editing and publishing on Windows (2/6/98)
  42. How do I use Emacs to translate text among languages? (5/21/98)
  43. Emacs and PGP (3/8/98)
  44. How Do I Use Emacs with Microsoft Visual C++ (7/30/97)
    VisEmacs (9/13/97)
    VC++ Environmental Variables
    Setting the Default Command Line
    Handling Compile Time Errors
    Reverting Buffers
    Exporting a File to Emacs
  45. Emacs and Borland C++ Builder (9/28/98)
  46. How do I use an Intellimouse with Emacs? (7/23/97)
    Interactions with FlyWheel (8/29/97)
    Why does Emacs ignore my mouse wheel? (10/13/97)
  47. How do I use perl-mode with Emacs? (4/22/98)
    How do I use the perl debugger with Emacs? (7/17/97)
  48. How do I use hexl-mode with Emacs?
  49. How do I use python-mode with Emacs? (12/3/97)
  50. How do I use ange-ftp with Emacs?
  51. How do I use telnet with Emacs? (9/13/97)
  52. How do I use grep with Emacs?
    How do I do a recursive grep?
  53. How do I use crypt++ with Emacs?
  54. How do I use the w3 package? (10/5/98)
  55. How do I use the browse-url package?
    Package for using browse-url for dictionary, search, etc. functions (9/25/97)
  56. How do I launch Windows applications on files from Emacs? (2/10/98)
  57. How do I print from Emacs? (7/26/99)
  58. How do I use outline mode in Emacs?
  59. How do I use EDT emulation mode in Emacs?
  60. How do I do "desktop saving" with Emacs? (2/23/99)
  61. How do I associate files with Emacs (i.e., use Emacs as a server with gnuserv/gnuclient)? (6/12/97)
    Controlling the use of frames
    For use with Internet Explorer
    For use with Netscape
    For use with Opera (2/18/99)
    PIF file for gnuserv (10/5/98)
  62. How can I have Emacs prompt me before closing? (10/6/98)
  63. How do I send data via DDE from Emacs to other apps? (2/2/98)
  64. How do I use find-file to load files that are on the desktop?
  65. How can I control CR/LF translation (e.g., to access UNIX files via NFS)?
    By file extension
    By file system
    Automatic
  66. Keyboard customization
    How do I use the Alt key really as Alt and not as Meta?
    How do I use the keypad number keys to enter prefix arguments? (10/27/98)
    How do I use the keypad number keys as if they were the number keys? (10/29/98)
  67. Miscellaneous mods to various modes
    Bracket (<>) matching for templates in C++ (6/8/99)
  68. How do I use Emacs with DragonDictate? (7/17/98)
  69. Emacs and the visually impaired (9/25/97)
  70. How do I turn off the *Messages* buffer?
  71. How do I read man or help pages?
    Unix man pages (9/14/98)
    WinHelp documents (2/10/98)
  72. How do I profile Emacs Lisp code? (10/6/98)
  73. Is there a package for editing Windows specific files (.bat, .ini, .inf, etc.)?
  74. Java
    Is there a mode with font-lock settings for Java source?
    How do I get imenu to work with Java?
    Creating TAGS files for Java source
    Java Development Environment (JDE) (3/31/98)
    The Jacob class browser and project manager (2/2/98)
    Example instructions for installing Emacs/JDE/JDK (10/5/98)
  75. Where can I get the latest VHDL mode? (9/10/98)
  76. Is there a mode for editing Visual Basic source? (2/9/99)
  77. Is there a mode for using SourceSafe? (9/22/98)
  78. Is there a mode for editing Delphi source? (5/13/98)
  79. Is there a mode for editing CSS style-sheets? (6/10/98)
  80. Is there a mode for editing Cold Fusion source? (6/17/98)
  81. Is there a mode for editing Matlab source? (10/6/98)
  82. Is there a mode for editing 4Test source? (10/8/98)
  83. Is there a version of RCS and CVS for Win32?
  84. What do I need to do to get vc-mode (version control) working?
    vc-mode and Clearcase (3/8/98)
  85. Is there a version of ispell for Win32?
  86. Where can I find a port of the diff program (e.g., for ediff)? (4/21/98)
  87. Where can I find a port of the patch program? (4/16/98)
  88. Where can I find a folding mode? (8/15/97)
  89. Where can I find an sql-mode? (2/21/98)
  90. Is there undelete support?
  91. Is Emacs Year 2000 compliant?
  92. The keypad
  93. BUGS
  94. I get these strange error messages. What's wrong?
    M-x shell, etc., fails with 'Invalid read syntax: "."'
    M-x shell, etc., fails with 'Symbol's value as variable is void: ll\.'
    Symbol's value as variable is void: pressions\.
    C-z produces Can't spawn ...
  95. Win95 Specific Problems
    I get these "Out of environment space" messages. Why?
  96. Patches
    19.34.2
    19.30.1
    19.30.0
  97. What other Unix tools have been ported to NT and/or Windows 95?
  98. What's the name of the NT Emacs mailing list?
    Where are there archives for ntemacs-users?

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 NT and Win95/98 are supported?

This port is known to run on all versions of NT up to 4.0 (including with the beta Win95 shell) on all NT hardware platforms, and on Windows 95 beta version 347 and later versions. This port is built using the Win32 API and supports most of the features of the Unix version. (Note that this port does not work with Win32s, and I do not know enough about Win32s to know whether it is either possible or even worth trying.)

MSDOS and Windows 3.11

Eli Zaretskii <[email protected]> maintains the port of GNU Emacs for MSDOS and MS Windows. You can download precompiled versions with the latest DJGPP archives:
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/emacs.README
ftp://ftp.simtel.net/pub/simtelnet/gnu/djgpp/v2gnu/

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 95 only) 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 <[email protected]> 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.

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:
Emacs 20.3 by Andrew Choi
Emacs 18.59 by Marc Parmet
XEmacs 19.14 by Pitt Jarvis (based on Parmet port)

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:
General Emacs Web Site
Emacs FAQ [HTML]
Emacs Manual [A4 Postscript 19.34] [HTML 20.3] [A4 Postscript] [FSF site, many formats, 20.3]
Elisp manual [A4 Postscript 19.34] [HTML 20.2.5] [Info 20.2.5] [FSF site, many formats, 20.2.5]
Intro to Elisp manual [A4 Postscript 19.34] [FSF site, many formats, 1.05]

Emacs 20.4

20.4.1 is the latest release of Emacs on NT and Windows95/98. All future development will be done under Emacs 20, and I recommend that new users download this version. Users upgrading from Emacs 19 should also read the notes about 20.3. For Windows, 20.4 contains the usual fixes for bugs in 20.3, plus some new extensive changes, some of which are detailed below.
A rewrite of the keyboard handling by Andrew to better support the windows and app keys, the lock keys, hot-keys, etc. For details, see the section below on keyboard customization.
Windows support for fontsets and much better multilingual font support by Jason Rumney, including for support BDF fonts. For details, see the section below on multibyte font support, and the section on BDF fonfs.
Emacs' heap is now dumped into a separate proper executable section, and Emacs no longer requires the dumped heap to be contiguous with its runtime heap. When a dumped Emacs starts up, it now tries to allocate the largest runtime heap that it can, even in the face of DLLs that have been loaded into its address space.
More changes to printing. See the NEWS file (C-h n) for details.
Rob Davenport's icons are now distributed with Emacs. The full set lives in etc/icons. I've changed the resource file so that Emacs now uses the etc/icons/gnu2a32.ico icon by default. The original icon is in etc/icons/sink.ico.

Changes to font names

The font specification string has been changed slightly to pass the tests that the fontset code puts it through. The dash on the end is no longer there, and the charset registry field now includes the first part of the charset (eg `iso8859'). `iso8859-1' replaces `ansi' as that is what the fontset code expects for latin1 fontsm and many more character sets are recognised. Every effort has been made to keep backwards compatibility, but it has not been possible in some places, so if you have any font related problems after upgrading to 20.4, you should update the font string (see the fonts section for details about how to find out the new font string).

For details on general changes to Emacs for 20.4, please see the NEWS file.

20.3 workarounds no longer required

The following code should be removed from your startup files if present:

(setq process-coding-system-alist
      '(("cmdproxy" . (raw-text-dos . raw-text-dos))))

Emacs 20.3

Emacs 20.3.1 contains a significant number of bug fixes and features not found in the 19.34.6 release, and is relatively stable (especially compared with the Emacs 20.2.1 release).

A significant change between 19.34.6 and 20 is the way in which end-of-line characters are handled. Emacs 20 has a general mechanism for detecting code systems used in files, and part of this mechanism detects end-of-line characters. I expect there to be unexpected surprises in the interaction between assumptions made by older packages and the new mechanism, so be aware.

I also highly recommend reading the help text for the function find-buffer-file-type-coding-system. Since this will be utterly impenetrable, I then suggest reading the Info pages on coding systems and end-of-line detection, and then taking a peak at f-b-f-t-c-s again.

Another very noticeable change between Emacs 19 and Emacs 20 is that all identifiers prefixed with "win32" have been changed to "w32". You should change references to these identifiers in your startup file and other lisp code to match this change.

VM

Unfortunately, VM has not been ported to Emacs 20 yet. If you are considering whether to move to Emacs 20 and you use VM, you will probably want to stick with 19.34.6 until VM has moved forward. (Bill Carpenter <[email protected]> on the question of VM and Emacs 20.)

c-mode-map and c-mode-base-map

The variable c-mode-map changed to c-mode-base-map from version 19.34 to version 20.1.

Upgrading from 19.34.6 to 20.3

Erwin Achermann <[email protected]> has graciously collected user experiences related to upgrading from 19.34.6 to 20.3.

Charles Curley <[email protected]> thoroughly reports the process he went through.

command.com shell on Win95/98

The latest end-of-line handling code in Emacs prevents command.com from being used as the interactive shell on Win95 out of the box. To use command.com as your shell, place the following in your startup file:

(setq process-coding-system-alist
      '(("cmdproxy" . (raw-text-dos . raw-text-dos))))

speedbar

The version of speedbar shipped with Emacs 20.3.1 has a bug preventing it from being used. If you have the JDE, you can use the version of speedbar.elc from there (either by modifying your load-path or copying it over into your lisp directory). If you don't have the JDE, the following version should work:

ftp://www.ultranet.com/pub/zappo/speedbar-0.8.tar.gz

sending mail generates the warning "unknown extension size ..."

Some versions of sendmail give a limit when reporting the SIZE extension, and this confuses the version of smtpmail shipped with 20.3.1. The warning is completely harmless, but if it annoys you then you can apply the following patch to lisp\mail\smtpmail.el or download a patched smtpmail.el (be sure to place it in the right directory and byte compile it):
smtpmail-20.3.1.el.diff
smtpmail-20.3.1.el

printing

If you are having difficulty printing from Emacs 20.3.1, see Andrew's note.

which-func-mode

If you set which-func-mode-global via customize, which-func-mode will not turn on automatically. You need to add the following to your startup file before the call to custom-set-variables:

(which-func-mode 1)

More from Cristian Ionescu-Idbohrn <[email protected]> on which-func-mode.

runemacs.exe does not run, and temacs.exe does not dump

If you install the binary distribution and runemacs.exe does not run, and then you try the undump distribution or compiling from source and temacs.exe fails to dump correctly, then download the source distribution, apply this patch to src/w32heap.c, and recompile.

AUCTeX fails with buffer read-only

If AUCTeX fails with an error that the TeX output buffer is read-only, then you will want to apply this patch posted to dejanews.

igrep 2.82

igrep 2.82 needs to have the variable grep-null-device defined; add the following to your startup file:

(defvar grep-null-device null-device)

lazy-lock

Emacs 20.3 has a bug in window-end which crops up in various places. One of them is in the lazy-lock package. If you use lazy-lock with Emacs 20.3 and are experiencing problems, try adding the following to your startup file before it loads lazy-lock:

(when (and (= emacs-major-version 20) (= emacs-minor-version 3))
  (let ((emacs-minor-version 2))
    (require 'lazy-lock)))

David Koppelman <[email protected]> found that the above patch does not work for him, but he does find that setting lazy-lock-defer-on-scrolling to "t" does prevent the crashes.

Richard Stallman sent out this patch that fixes the bug in the C source. If you have the source, you can apply the patch and rebuild Emacs.

How do I get an Emacs distribution?

Emacs is distributed in two different forms. You can get the full source distribution of Emacs, or you can get an installed distribution of Emacs with all executables precompiled.

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>".

Where can I get precompiled versions?

Starting with Emacs 20.4, precompiled distributions are being hosted at ftp://ftp.gnu.org/. Distributions for the latest version are at:
ftp://ftp.gnu.org/gnu/windows/emacs (top level directory)
ftp://ftp.gnu.org/gnu/windows/emacs/latest (latest distributions)

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:
West Coast, USA:
ftp://ftp.cs.washington.edu/pub/ntemacs (all)
Australia:
http://www.plugged.net.au/gnu/ntemacs (i386)
Germany:
http://www.fachdid.fu-berlin.de/SE3/Service/Emacs
Ireland:
ftp://ftp.ucc.ie/pub/emacs (all)
East Coast, USA:
http://www.itribe.net/virtunix/emacs (i386)
Sweden:
ftp://ftp.sunet.se/pub/os/Win32/ntEmacs (all, including this FAQ)
UK:
http://www.paradiso.freeserve.co.uk/gnu/ (i386, including this FAQ)
UK:
http://sunsite.org.uk/packages/ntemacs/ [FTP](no FAQ yet)
Netherlands:
http://paddington.ic.uva.nl/mirror/ntemacs (all, including this FAQ)

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 ([email protected]) 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 <[email protected]> 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.

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 pkunzip will 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).

WARNING: Some utilities that handle tar files can incorrectly untar the distributions when using the default settings. If you encounter problems with Emacs, see the section below on troubleshooting these problems.

Now what?

Once you have unpacked a precompiled version of Emacs, it should have the subdirectories:

bin
etc
info
lisp
lock
site-lisp

If your utility failed to create the lock directory, then you can simply create it by hand (it is initially empty).

See below for information on where to place the .emacs startup file.

You should also find a file named README as a part of the distribution. Be sure to read this file for information on installing Emacs, as well as reading the section below on installing Emacs.

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.

I don't 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 Win32 application compiled and linked using MSVC, and it can be debugged using Win32 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).

Before you run it in the debugger, though, you will need to have the Emacs environment variables set in your shell so that the Emacs process uses the lisp and data files of the development tree instead of an installed version of Emacs. You can either set these variables by hand, or you can use the debug.bat batch file created in the nt subdirectory and installed in the bin directory. This batch file will set the appropriate environment variables and run msdev on the emacs.exe executable installed in the bin directory.

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.
Tips from Marc Fleischeuers <[email protected]> on how to use Emacs functions to interpret the data stored in lisp variables.
Debugging GC problems.

How do I install Emacs?

Below are two methods for installing Emacs. If the instructions below seem a bit confusing, Charles Curley <[email protected]> has also written a tutorial on installing Emacs that you might find useful.

Precompiled distribution
Preferred method:

Let's assume that the directory in which you have unpacked Emacs is c:\emacs (note that it can be anything you want it to be; I just want to be able to refer to something concrete at this point). First, you will want to run the program bin\addpm.exe with the Emacs directory as an argument. In this example you would invoke it as:

c:\emacs\bin\addpm.exe c:\emacs

Invoking addpm.exe will do two things. First, it will create a set of registry keys that tell Emacs where to find its support files (lisp, info, etc.). Second, it will create a folder containing an icon linked to runemacs.exe (a wrapper program for invoking Emacs).

Now, to run Emacs, simply click on the icon in the newly created folder or invoke runemacs.exe from a command prompt.

Alternate method:

Another alternative for running Emacs is to use the emacs.bat batch file in the bin directory (this is now the old method of invoking Emacs). Edit the emacs.bat file to change the emacs_dir environment variable to point to the Emacs installation directory and invoke the emacs.bat file to run Emacs. (If you use bash as your shell, you can use an equivalent bash script to emacs.bat.)

Note that, on Win95, you are likely to get "Out of environment space" messages when invoking the emacs.bat batch file. The problem is that the console process in which the script is executed runs out of memory in which to set the Emacs environment variables. To get around this problem, create a shortcut icon to the emacs.bat script. Then right click on the icon and select Properties. In the dialog box that pops up, select the Memory tab and then change the Environment memory allocation from "Auto" to "1024". Close the dialog box and then double click on the icon to start Emacs.

Source distribution
You have two options for installing Emacs with the source distribution. You can install it over the source directory, or you can install it in a completely separate directory. Emacs works the same with either installation option. One advantage of installing it over the source directory is that it takes up far less disk space (primarly because the lisp files don't have to be copied). One advantage of installing Emacs in a separate directory is that Emacs can now be managed as a single unit that can be moved and copied independently of the source code.

The INSTALL_DIR macro in the nt\makefile.def makefile determines where Emacs will get installed from the source distribution. If you want to install Emacs in the same directory as the source tree (say, c:\src\emacs), then simply set INSTALL_DIR appropriately:

INSTALL_DIR = c:\src\emacs

If you want to install Emacs in a different directory (say, c:\emacs), then set INSTALL_DIR to this directory:

INSTALL_DIR = c:\emacs

As compared with the installation process for the precompiled version, the installation process will automatically create a bin\emacs.bat file in the installation tree with the emacs_dir variable set appropriately.

How do I run Emacs?

You can run Emacs in a number of ways. If you installed Emacs using addpm, then you can run Emacs via the Start Menu using the "Programs->Gnu Emacs->Emacs" menu command. From the command line, you can use the program runemacs.exe.

If you didn't install Emacs using addpm, then you can run Emacs using the emacs.bat batch file in the Emacs bin directory. See the install section above for instructions on how to do this.

Note: Starting with version 19.34.6, Emacs is linked with setargv.obj. This gives Emacs DOS-style wildcard expansion of its command-line arguments, which should handle the common use of wildcards. To suppress expansion by setarg.obj, enclose the argument in double quotes. Embedded double-quotes will have to be escaped using a backslash.

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. What's 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. If you are using 19.31 on a machine that uses dialup networking, then it is also possible that Emacs is trying to resolve your machine's domain name as winsock.dll is being loaded.

See the next section for more info on working around this problem; 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 been told that some utilities (WinZip again?) don't create the lock subdirectory. The lock subdirectory needs to be created.
  4. I've also had reports that the gnu-win32 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 you feel certain that you have unpacked the distribution correctly, then you should check to make sure that the emacs_dir variable in the emacs.bat file is set correctly. If it is and you are still having trouble, make sure that it is an absolute path that includes the drive letter (or is in UNC format).

If Emacs produces an access violation when you run it, then it might be a problem with Emacs unsuccessfully interacting with other software such as HeapAgent and Starfish Internet Monitor. See the section below describing this problem and how to work around it.

If it is still not working, send me mail or send mail to the list.

Emacs used to work fine. But now it won't start, and I didn't change anything in Emacs.

1. HeapAgent

The typical behavior people are encountering with this problem is that they invoke Emacs but either nothing happens or it produces an access violation, and yet they have changed nothing in their Emacs installation, and Emacs used to work fine before this point. Most likely, the problem is due to an interaction between Emacs and some new piece of software you have just installed (the most popular culprit seems to be HeapAgent). Due to the nature in which Emacs is designed and built, Emacs is fundamentally non-relocatable: it uses an initialized heap segment that needs to be mapped in at a particular virtual address at startup time before Emacs will work correctly. It appears that programs like HeapAgent install DLLs that intrude upon Emacs' virtual address space, preventing Emacs to load its initialized heap.

If you have HeapAgent, then you can work around the problem in three ways. You can download the source and recompile, as described below. Or, you can download a version that has already been precompiled to avoid conflicts with HeapAgent (compliments of Andrew Bishop <[email protected]>). Or, you can use editbin to change the base address at which the haloader.dll dll will be loaded (this is the dll that gets loaded into every application's address space on startup):

editbin /rebase:base=0x20000000 haloader.dll

Otherwise, the only other workaround is to recompile Emacs on your machine so that Emacs creates and initializes its heap at a virtual address that does not conflict with software such as HeapAgent. To do this, you will need to download the source, #define the macro NTHEAP_PROBE_BASE inside the procedure src\ntheap.c:allocate_heap(), and rebuild.

2. Starfish Internet Monitor

Apparently, Starfish Internet Monitor interferes with Emacs' loading of the dumped heap in a manner similar to HeapAgent. See the discussion on HeapAgent above on how to work around this.

3. Aventail AutoSOCKS

Ditto with AutoSOCKS.

4. InstallShield

Starting around June, 1999, there have been reports that InstallShield occasionally hangs when Emacs is running. Currently, the cause is unknown, but Andrew is looking into it. If you have ideas, we would appreciate hearing them. [More Info]

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 Emacs.

Dr. Solomon's

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 <[email protected]>.

Why does Emacs seem to perform slowly under certain conditions?

In some situations, Emacs performance can degrade. The following sections discuss these situations, why they come about, and what you can do about them.

Menu bar updates

In 19.34 the menu bar is updated more often than it needs to be, and each update can be a time consuming process. If you are using a single frame, you will likely not notice this behavior; if you are using a number of frames, you might notice slow redisplay performance. Currently the only way of fixing this is to turn menu-bar-mode off (e.g., typing "M-x menu-bar-mode", or invoking (menu-bar-mode nil)).

For more background, see Andrew's messages on the topic.

Transient mark mode

The use of transient mark mode can trigger the slow menu bar update performance described above. When the mark is set in transient mark mode, the menu bar is updated after every keystroke and command. Again, turning off menu-bar-mode is the only way to prevent the slow performance without recompiling Emacs with patches.

Kim Storm <[email protected]> tracked down the bug in the core redisplay code that causes the performance problem with transient-mark-mode enabled. See the patches section below for his patch.

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.

Why does Emacs ask me to connect to my dialup service when it starts up?

For some users, when Emacs starts up it pops up the dialog for connecting to their dialup service, or sometimes appears to hang for a few minutes and suddenly appear.

The reason for this is that Emacs now has networking support built in. When Emacs starts, the winsock DLL automatically gets loaded and tries to resolve the fully qualified domain name for your machine under the name "localhost". If the system doesn't have this name mapped, it will try to query a nameserver on the internet, which is typically some host within your ISP and subsequently prompts to connect to your dialup service so that it can ask a name server for the domain name of your machine. As you know, this is very unfortunate, and was not anticipated when the networking support was added.

This problem will be fixed when 19.32 comes out, but you can work around the problem by giving the dialup support another method for figuring out the domain name of your machine. To do this, you need to edit the hosts file for your system (located in %windir%\hosts on Win95 and %windir%\system32\drivers\etc\hosts on NT) so that localhost becomes an alias for your machine name. If your system doesn't have a hosts file yet, you can easily create one by copying the sample hosts file in the same directory, hosts.sam.

For example, if my machine were named banana-fish.cs.washington.edu, then I would edit the hosts file from:

127.0.0.1 localhost

to

127.0.0.1 banana-fish.cs.washington.edu localhost

The hostname should be the value of invoking (system-name) in the Emacs *scratch* buffer, i.e., the fully qualified domain name for your system. Note that you may also have to tell the system to look in the hosts file as well as using DNS.

If this doesn't work for you, there are some other options (I have not tried these):
Turn off the auto-dial option of PPP under the Control Panel Dialup Networking icon. However, this would mean that you would have to manually connect to your dialup service whenever you wanted to use a network applicaton.
Use a dummy winsock.dll. Cristian Ionescu-Idbohrn <[email protected]> has provided one called mozock.dll. Download the zip file, unzip it, move the mozock.dll file to the bin directory where emacs.exe resides, and then rename the mozock.dll file to wsock32.dll. When Emacs loads, it will load this wsock32.dll instead of the system one.

For networking support, you can use the external nttcp.exe program. Download nttcp.exe and place it in your Emacs bin directory. Also download this version of tcp.el, byte-compile it, and place it in your lisp directory. Then add the following to your .emacs:

(load-library "tcp")
(setq tcp-program-name "nttcp")
Edit the emacs.exe executable to remove the reference to wsock32.dll in the import table. Copy emacs.exe to a backup file, and then start up Emacs (you might have to connect to your service provider to do this), load emacs.exe into a buffer, search for wsock32.dll, turn on overwrite mode, and then change wsock32.dll to xsock32.dll by changing the 'w' to an 'x'. Now save the modified emacs.exe. Now, to get networking support again, follow the directions in the previous item.
Delete all DNS nameservers listed in the TCP/IP propoerties of the network control panel dialog. This is a rather drastic approach, since you will want DNS nameservers when running other applications (and even the networking ones inside of Emace).

When I run Emacs, a console window pops up. How do I make it go away?

This is annoying, I know, and you shouldn't have to be dealing with this. But please bear with me for now. If it isn't there already, prepend "start" to the last line of the .bat file (the line that invokes the emacs.exe executable). Then create a shortcut icon to the emacs.bat file, and edit the Properties of the shortcut (right click on the icon). On the Program tab, select Run: to be Minimized and make sure the Close on exit checkbox is checked. Double click on the icon, and Emacs should start up cleanly.

Reportedly, invoking emacs.exe with gnuclientw also prevents it from popping up its console window. gnuclientw is a part of the gnuserv package.

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 <[email protected]> describes a way to get around this, at least for cutting and pasting text just within Emacs.

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 Emacs batch 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.
SIZE

To customize the size of specific frames, including the initial frame, see the section on customizing frames below.

User Interface
To resize an Emacs window, drag on a border with the mouse.
Command Line
To have Emacs start up with a particular size, invoke it with the X Windows -geometry command line argument. For example, to start Emacs with a window 40 lines by 80 columns in size, use the following:
emacs -g 80x40

Note that the geometry command can be combined with the position command, as described below.

Emacs Lisp
To change the size of an Emacs frame using elisp, you can use the two functions set-frame-width and set-frame-height. For example, to resize Emacs to display 40 lines by 80 columns, you could use:
(set-frame-height (selected-frame) 40)

(set-frame-width (selected-frame) 80)
POSITION

To customize the position of specific frames, including the initial frame, see the section on customizing frames below.

User Interface
To reposition a running Emacs, click on its title bar and drag the window.
Command Line
To start Emacs at a particular position, invoke it with the X Windows -geometry command line argument. For example, to start Emacs at pixel offset (10, 30) from the top left corner:
emacs -g +10+30

To combine the size with position, first specify the size and then the position. The two examples above can be combined as follows:

emacs -g 80x40+10+30

Note that you can also specify position offsets from any of the corners of the screen. See the GEOMETRY SPECIFICATIONS section of the X man page for complete details on the geometry command.

Emacs Lisp
To reposition an Emacs frame using elisp, you can use the set-frame-position function. For example, to move the current frame to the offset (10, 30), you could use:
(set-frame-position (selected-frame) 10 30)
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 (win32-select-font))) ; Emacs 19
(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 Win32 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).

COLORS

As with other windowing attributes, Emacs uses the X Windows color names for specifying colors on the command line and in elisp. One set of these names is a set of abstract color names, e.g., red, green, and blue. These names are the ones you will typically use as arguments on the command line or in elisp functions. Emacs also supports the use of numeric color names; see the COLOR NAMES section of the X man page for complete details on how to specify numeric color names and their color spaces.

To see the abstract color names that Emacs understands and the colors that they map to, use the menu command Edit->Text Properties->Display Colors, or invoke the list-colors-display function in the *scratch* buffer:

(list-colors-display)

If you would like to change the mapping of color names to RGB values, or to add new color names to Emacs, then you will want to modify the alist w32-color-map (win32-color-map in Emacs 19). To make changes, you can simply cons new mappings onto the head of the alist:

(setq win32-color-map (cons '("snow" . 16448255) win32-color-map)) ; Emacs 19
(setq w32-color-map   (cons '("snow" . 16448255) w32-color-map))   ; Emacs 20

The number in the element is the logical OR of three values for the red, green, and blue components: (B << 16 | G << 8 | R). In the example above, red is 255, green is 250, and blue is 250. At some point there will be support for reading in files with color mappings to make this process a little easier.

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

To customize colors for color syntax highlighting, see the section on font-lock.

User Interface
To change the foreground or background color in Emacs through the windowing interface, you can use the menu commands Foreground Color->Other and Background Color->Other in the Edit->Text Properties menu.
Command Line
To change the foreground or background color in Emacs on the command line, you can use the -fg and -bg command line arguments. For example, to start Emacs with yellow text on a black background, invoke Emacs using:
emacs -fg yellow -bg black
Emacs Lisp
You can use elisp functions to change the colors of any of the Emacs faces. For example, to change the foreground or background color of Emacs, you can use the set-foreground-color and set-background-color functions. To change the color of an arbitrary face, use the set-face-foreground and set-face-background functions. To change the color of the cursor, use the set-cursor-color function.

This elisp changes the background color to black:

(set-background-color "black")

The following elisp changes the mode line foreground to firebrick:

(set-face-foreground 'modeline "firebrick")

The following elisp changes the cursor color to purple:

(set-cursor-color "purple")
FRAMES

Emacs uses two alists to determine the default appearances of frames, default-frame-alist and initial-frame-alist. The default-frame-alist variable sets the basic defaults of all frames. Since it is a common Emacs usage to have the initial frame have slightly different properties than other frames (e.g., its position), you can use the initial-frame-alist variable to override properties in default-frame-alist specially for the initial frame. You should definitely read the help text for these variables (C-h v) for more details on the differences between them and how they interact with each other.

Below is an example of using default-frame-alist and initial-frame-alist to configure the appearances of the initial frame and all other frames (you would place this code in your startup file). With default-frame-alist, we set the top left corner of new frames to be at pixel offset +200+400, the width and height to be 80x40, the cursor to be white, the foreground to be yellow, the background to be black, and the font to be Courier 10. With initial-frame-alist, we override the top left corner of the initial frame to be at pixel offset +10+30, and inherit the remaining properties for the initial frame from default-frame-alist.

(setq default-frame-alist
      '((top . 200) (left . 400)
        (width . 80) (height . 40)
        (cursor-color . "white")
        (cursor-type . box)
        (foreground-color . "yellow")
        (background-color . "black")
        (font . "-*-Courier-normal-r-*-*-13-*-*-*-c-*-iso8859-1")))

(setq initial-frame-alist '((top . 10) (left . 30)))
SCREEN RESOLUTION

You can use the functions x-display-pixel-width and x-display-pixel-height to determine the resolution of your screen. For example:

(and window-system
     (setq screen-width (x-display-pixel-width)
        screen-height (x-display-pixel-height)))
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 (win32-enable-italics in Emacs 19) to t in your startup file:

(setq win32-enable-italics t)  ; This must be done before font settings! (Emacs 19)
(setq w32-enable-italics t)    ; This must be done before font settings! (Emacs 20)
(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.

Console Interface

Emacs can also run inside a console window. Simply invoke Emacs with the -nw command line option to do so. Although you cannot change the size, font, or color of the window from within Emacs, you can use the window's menu to do so. (If no icon has been created to invoke the Emacs batch file, then you'll have to create one to change these attributes.)

SIZE

Under NT, go to the upper left hand corner and open the "-" menu of the console window. Select "Screen Size and Position...", and use the dialog to set the window to the size you want. Be sure to check the "Save Window Size and Position" checkbox so that future invocations will retain the new window size. After closing the dialog box, resize the window itself by dragging on the edges.

Under Win95, click on the properties icon in the icon toolbar at the top of the window. Go to the "Screen" tab and select the desired window size in the "Usage" panel. Click on "OK".

POSITION

To reposition Emacs, click on the title bar of the console window and drag it.

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 Win95, 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.

COLOR

Under the NT interface, open the "-" menu. Select "Screen Colors...", and use the dialog to choose the colors you want to use for the window. Be sure to check the "Save Configuration" checkbox so that the colors are used in future invocations. Click on "OK". Unfortunately, the colors are not immediately used, but the changes have been made. To use the new colors, simply close the window and use the icon to start Emacs again. Emacs will then come up using the colors you chose before.

I'm not exactly sure how to change the colors on a per-console-window basis under Win95.

Why does Emacs overwrite the same file using different filenames?

Older versions of Windows 95 had a bug where different filenames with a particular structure would wind up with the same short filename, and hence the different filenames would point to the same file on disk. For example, "foo.mak" and "foo.mak~" will map to the same file. Early versions of Emacs suffered from this bug, but later versions (19.34.1 and above at least) work around it.

However, disabling the registry entry HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\FileSystem\NameNumericTail in Windows 95/98 (by setting it to 0) will still cause these filename conflicts. According to Microsoft, this entry should never be set to 0 for Windows 95 and 98 (see MS KnowledgeBase articles Q148594 and Q179370), but if you must have it set to 0 then you should change how backup files are created. You can do this by setting the variable backup-by-copying to t in your startup file, or by redefining the function

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. Also, if you have a version of Emacs older than 19.31, Emacs will only recognize _emacs as the startup file.

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:
Environment variable: Emacs will always first check to see if you have an environment variable named HOME set and use that value as your home directory. Under Win95, you can set the HOME environment variable in your autoexec.bat file (you will need to reboot); under NT, you can set the HOME environment variable in the System panel of the Control Panel. (Note that if you set HOME as an environment variable in the System panel it will only take effect in new processes created after you've closed the System panel; if it still does not appear to be working, then you might try rebooting.)
Registry: If Emacs doesn't find an environment variable named HOME, it will check the registry for a value named HOME and use that value as your home directory. Emacs first checks the key "HKEY_CURRENT_USER\\SOFTWARE\\GNU\\Emacs", and then the key "HKEY_LOCAL_MACHINE\\SOFTWARE\\GNU\\Emacs" (although the use of the latter key is discouraged since HOME should be set on a per-user basis, not on a per-machine basis). Note that the value of HOME is not set by the addpm.exe program that initializes the registry with the other Emacs configuration variables.

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.

Samples

Below is a list of sample .emacs files from various people. Eventually a single sample .emacs file will be shipped with the binary distributions, but until that happens you can browse these to see what people use already.
Dave Gallucci <[email protected]>
Sarir Khamsi <[email protected]>
Wojciech Komornicki <[email protected]>
Andrey A. Kulaga <[email protected]>
Greg Munger <[email protected]>
Robert Praetorius <[email protected]>
Jack Repenning <[email protected]>
Karel Sprenger <[email protected]>
Mike Strock <[email protected]>

How can I modify Windows to be more like the X Windows System?

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 (Win95) or Input Locales (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:
Check out swapcapslock.zip (note that this site seems to have intermittent connectivity problems).
You can also play games with the registry:
From Chris McMahon <[email protected]>: Download caps-as-ctrl.reg to make CapsLock a Control key (leaving your original control keys as they were), or caps-ctrl-swap.reg to swap CapsLock and the left Control key. Once you've downloaded them, double-click on the .reg files in Explorer or "run" them from a command prompt to have them update your registry.
Chris McMahon <[email protected]> gives explicit step-by-step instructions on modifying the registry.
Shane Holder <[email protected]> gives some background on how "Scancode Map" is being used by the system.
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.
README
keyswap.tar
Win95: Microsoft has placed a keyboard remapping program for Win95 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.)
README
source
ctrl2cap.vxd.tar

Win98: I've been told that the Win95 keyremap utility also works on Win98, despite the warnings on the web page.

How do I get tab file completion with cmd.exe?

To get tab file completion in cmd.exe, use regedt32 to set the following registry entry to 0x9 (using the Edit->DWORD menu command):

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\CompletionChar

It has been reported that this feature can randomly crash cmd.exe on occasion.

How can I have the focus follow the mouse?

1) Xmouse

Microsoft distributes a utility called Xmouse, part of a package of utilities called PowerToys, that lets you change the focus handling so that the focus follows the mouse. The PowerToys package can be found at http://www.microsoft.com/windows/downloads/default.asp?CustArea=pers&Site=95&Product=Windows+95&Category=&x=15&y=10.

Note that not all of these utilities written on Windows 95 work on NT; reportedly, if you are on NT 4.0 you have to use the TweakUI utility to enable follow focus. Also, if you use TweakUI, reportedly it is best to set the popup delay to 0ms for focus follow to work well with Emacs.

For more info, you can flip through a collection of email messages discussing these utilities.

2) Registry

Steve Yegge <[email protected]> reports that there is an NT registry setting that enables mouse tracking (it's unknown whether this works on versions less than 4.0). Set the following key to 0x1:

HKEY_CURRENT_USER\Control Panel\Mouse\ActiveWindowTracking: 0x1

Steve also says:

  The two "bugs" I've found are:

        - some applications (notably Netscape and Microsoft Developer
          Studio) autoraise when they get the focus.

        - the mouse doesn't move into the new window when you use
          alt+TAB switching, so if a vibration bumps the mouse, you
          may suddenly find yourself typing in the wrong window.

How can I have menus popup immediately?

You can use TweakUI, another utility from the PowerToys package, to change the delay that popup menus wait between the mouse click and actually popping up. Again, the PowerToys package can be found at http://www.microsoft.com/windows/software/powertoy.htm.

Unix window managers and other tidbits

See http://floach.pimpin.net/

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

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.

Window operations (maximize, minimize, etc.)

Theodore Jump <[email protected]> has written a utility called EMWINMSG that enables elisp code to invoke a window operation on an Emacs frame (via the Windows API routine "ShowWindow"):
README
emwinmsg_1.1.zip

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 Storm's <[email protected]> CUA-mode.el.

Open File dialog box

Binu Jose Philip <[email protected]> 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.

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://ftp.gnu.org/gnu/intlfonts. 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.

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)

How do I get Emacs to display Smartquotes, the Euro symbol and other Microsoft additions to the ISO-8859 character sets?

There are two ways to do this: The "correct" way, using Emacs's built-in multilingual support, and the "easy" way, bypassing the multilingual support.

The correct way requires an additional elisp package ms-latn-ex.el, which defines a new character-set called `latin-extra'. After loading ms-latn-ex, you need to explicitly tell Emacs to use `latin-extra' via the set-buffer-file-coding-system, or set-default-coding-systems functions.

The easy way may cause problems with the display of some languages, so you can use the following in your .emacs at your own risk:

(standard-display-8bit 128 159)

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.

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://ftp.gnu.org/gnu/intlfonts as an example put together by Jason Rumney.

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 do I use leim with Emacs?

First you will need to download the leim package from ftp://ftp.gnu.org/pub/gnu/. Then follow these instructions by Jason Rumney <[email protected]>.

Erik Peterson <[email protected]> has compiled all of the leim input methods for 20.3.1. You can download them from:
http://www.mandarintools.com/download/win-leim.zip

To install them, follow Erik's instructions.

How do I display different character sets with Emacs?

You can change standard-display-table to have extended characters displayed as themselves in Emacs. Emacs has a function standard-display-european that changes standard-display-table approprialely for displaying Latin-1 (ISO 8859) characters. To use it, invoke the function with a positive argument:

(standard-display-european 1)
(require 'latin-1)

Andrew Innes <[email protected]> also has suggestions for displaying characters sets other than Latin-1.

If you would like to display particular characters that show up in Emacs in octal form, see another suggestion by Andrew.

ISO 8859/1 (Latin 1) using an OEM (MSDOS) font

Anders Lindgren <[email protected]> has written a package that will display a buffer written using a ISO 8859/1 character set using an OEM (ms-dos) font. See http://www.csd.uu.se/~andersl/emacs.shtml to get the package.

Displaying multibyte character sets

Emacs 20.3 does not display multibyte character sets correctly, although the situation should be better for 20.4. If you are using a package that enables multibyte, you will want to turn it off (likely in the package hook):

(set-buffer-multibyte nil)

[More Info]

Subprocesses under Emacs

Emacs on NT and Win95 can utilize subprocesses just like Unix Emacs. However, the behavior of subprocesses with Emacs may be unintuitive in some situations. This section discusses these situations, and how you might work around them.

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 Win95 and NT are examples of such programs). 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.

DOS subprocesses

You can run DOS subprocesses under Emacs, but with the limitation that you run only one at a time. The implication of this is that, if you use command.com under Win95 as your shell, then you can only run one shell process at a time (command.com is still a DOS process even under Win95). You can use other shells, such as bash, tcsh, or 4NT, instead of command.com; see the section below on other tools for pointers to other sites.

Andrew Innes is working on removing this limitation. If all goes well, it should be available in 19.35.

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 <[email protected]>.

Killing subprocesses on Win95/98

Emacs cannot guarantee that a subprocess gets killed on Win95/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 Win95/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.

Interrupting subprocesses in Emacs (e.g., C-c C-c in shell buffers)

19.34.4 Previously, Ctrl-C would generate a CTRL_BREAK_EVENT (SIGQUIT) in subprocesses. Now Ctrl-C generates a CTRL_C_EVENT (SIGINT). This behavior is more accurate, but may still causes problems; see Andrew's note.

19.34.1 For applications that handle Ctrl-C and Ctrl-Break events, you might notice that typing Ctrl-C in Emacs when those applications are run as subprocesses does not trigger their Ctrl-C handlers but instead triggers the Ctrl-Break handlers. Here is what is going on. Emacs in general tries to interrupt subprocesses using Unix-style kill and SIGINT. Ideally, on Win32 the kill emulation code can translate the SIGINT into a GenerateConsoleCtrlEvent with a CTRL_C_EVENT. However, doing so does not seem to propagate the CTRL_C_EVENT to the subprocess; as far as I can tell, nothing happens. So, instead of using a CTRL_C_EVENT for SIGINT, the emulation code uses a CTRL_BREAK_EVENT, which is propagated correctly to subprocesses.

If you need to handle Ctrl-C events propagated from Emacs, you'll need to use a Ctrl-Break handler for now. Andrew describes how all of this going to be handled in the future.

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.

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:

Emacs 19.34

(setq win32-quote-process-args ?\")
(setq shell-command-switch "-c")
(load "comint")
(fset 'original-comint-exec-1 (symbol-function 'comint-exec-1))
(defun comint-exec-1 (name buffer command switches)
  (let ((binary-process-input t)
        (binary-process-output nil))
    (original-comint-exec-1 name buffer command switches)))

Emacs 20

(defun my-shell-setup ()
  "For bash (cygwin 18) 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)

(setq process-coding-system-alist (cons '("bash" . raw-text-unix)
                                        process-coding-system-alist))

Richard M. Heiberger's <[email protected]> setup for Cygnus B19.

For more configuration information with bash, take a look at Jonathan Payne's <[email protected]> setup.

If you find that you are having trouble with Emacs tracking drive changes with bash, see Mike Fabian's note <[email protected]>

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: (12/18/97)

(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 win32-quote-process-args t)   ; Emacs 19
(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 win32-quote-process-args t) ; Emacs 19
(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 win32-quote-process-args t) ; Emacs 19
(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 <[email protected]> setup.

zsh

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

What do I do about the "No match 2 in highlight..." error I get from sh-script.el?

Apparently the sh-script package isn't finding the shell program correctly. Peter Breton <[email protected]> says that adding a call to sh-set-shell in sh-mode-hook will fix the problem:

  (add-hook 'sh-mode-hook
    (defun my-sh-mode-hook-set-shell ()
      ;; Use whatever shell is most appropriate, it doesn't matter
      ;; if the actual /bin/ksh file exists on the system or not
      (sh-set-shell "/bin/ksh")))

How do I prevent ctrl-m's from being printed in the shell?

If you are getting ctrl-m's printed in the shell buffer, try adding the following to your startup file:

(add-hook 'comint-output-filter-functions 'shell-strip-ctrl-m nil t)

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 Win95 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.

In 19.34, lisp\winnt.el initializes comint-completion-addsuffix to the cons pair '("\\" . " ") using shell-mode-hook. This means that, by default, a "\" is appended to directory names during completion in shell mode. To override this behavior, you need to change the value of comint-completion-addsuffix. You can do this by resetting it in your startup file to t or by explicitly setting it to a cons pair with "/" in it:

(add-hook 'shell-mode-hook
          '(lambda () (setq comint-completion-addsuffix '("/" . "")))
          t)

or

(add-hook 'shell-mode-hook
          '(lambda () (setq comint-completion-addsuffix t))
          t)

In 19.35, the default will be to append "/". If Emacs detects that you are using command.com or cmd.exe, then it will it use "\" instead.

Why is a "Specified COMMAND search directory bad" message printed?

The function shell in shell.el automatically invokes the shell program with the argument "-i", and parses this as the directory in which the shell program resides (which, of course, is invalid). To prevent this message from being printed, you can create a variable named according to the form specified in the help message of shell (to look at the help message, type "C-h f shell"). For the default shells, then, you could place the following in your startup file to prevent this message (these will eventually get into winnt.el so you don't have to do this):

(setq explicit-command.com-args nil)
(setq explicit-COMMAND.COM-args nil)
(setq explicit-cmd.exe-args nil)
(setq explicit-CMD.EXE-args nil)

Multiple lines for each shell are given since variable names are case sensitive and shell names can be any case (so this only handles the most common situations). If you have an entirely different shell that also complains about being given the "-i" switch, you can initialize a similarly named variable to prevent the "-i" switch from being sent to the shell.

Note that, if you would like to always pass arguments to an interactive shell when it starts up, you would change the nil value in the appropriate assignment above to the list of arguments you would like to use with your shell. For example, if you would like to invoke command.com and tell it which directory its executable resides, you could place something like the following in your startup file:

;; Determine the directory containing the shell program, explicitly making
;; certain that the directory separator is a backslash when doing so.
(let ((directory-sep-char ?\\))
  (setq shell-directory (file-name-directory (getenv "SHELL"))))

(setq explicit-command.com-args (list shell-directory))
(setq explicit-COMMAND.COM-args (list shell-directory))

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. Examples of how to do both of these are in shown in the previous subsection.

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

Chris Boucher <[email protected]> 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 Win32, 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.

I've only tested the outgoing and incoming RMAIL setups. If you find that the suggested code for any of the other incoming mail configurations is inaccurate, please let me know.

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 <[email protected]> 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 <[email protected]>.

Feedmail comes with Emacs 20. If you're using 19.34, download the package from Bill's site, byte-compile it, and place it in your load path. You'll then need to customize it in your startup file; see Bill's setup for one example.

Fabio Somenzi <[email protected]> also sent the following as an example:

(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 (this bug should be fixed in 19.35). 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 <[email protected]>:

(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.

Sharing with Unix: RMAIL

If you want to share your rmail folders between Unix and 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 <[email protected]> message describing the patch and what else he did to setup sharing between Unix and 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.
Franklin Lee's epop3mail package.

Leaving on server: RMAIL

Franklin Lee <[email protected]> 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:
ep3m-098.zip (8/13/99)
README.TXT (8/13/99)

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.

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:
README
mm_win32.zip
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

* 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 Win32 environment, but Fabrice Popineau <[email protected]> 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 <[email protected]> has written a win-biff tool for use with pop mail servers. [More Info]
source.zip, disk1.zip, disk2.zip

Obscure problems: Win95

Bill Carpenter <[email protected]> has encountered some problems with the use of vm-pop and smtpmail on Win95. Occasionally, Win95 would crash due, apparently, to a large number of TCP connections waiting to timeout due to a race condition in connection shutdown. In addition, he found that using vm-pop to download a large message (~1.5 MB) crashed Emacs because "process space was exhausted." If you think you are suffering from similar problems, you might want to read his descriptions and thoughts on the problems.

The latest version of VM works around the problems in vm-pop, but smtpmail requires a small patch. If you are encountering similar problems, then you should modify the end of smtpmail-via-smtp in smtpmail.el as follows:

;(delete-process process)
(run-at-time 3 nil 'delete-process process))))))

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:
The info files describing the package ("M-x info").
The FAQ at http://www.ccs.neu.edu/software/contrib/gnus/.
The news group gnu.emacs.gnus.
The mailing list archive at http://www.miranova.com/gnus-list.
And more at http://www.miranova.com/~steve/gnus-local.html....

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 <[email protected]> has written an elisp/Java package that makes it easy to read online newspapers through Emacs:
Netscoop 2000

How do I use TeX with Emacs?

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

MiKTeX

MiKTeX is a native Win32 implementation of the TeX document processing system. The MiKTeX project page is at http://www.snafu.de/~cschenk/miktex. 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 <[email protected]> has written instructions on how to use AucTex with MikTex and Emacs.

Putting it all together

Willem Minten <[email protected]> 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.
Directions
Files

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:
http://www.lysator.liu.se/projects/about_psgml.html

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:
http://ourworld.compuserve.com/homepages/hoenicka_markus/ntsgml.html

How do I use Emacs to translate text among languages?

David Finucane <[email protected]> has written an elisp/Java package that uses the AltaVista translation service to translate text among a number of languages.
trans

Emacs and PGP

Jari Aalto <[email protected]> is porting PGP from Unix to NT as a package called TinyPgp for use with Emacs on NT:
Announcement
Manual and distribution info

Feel free to send bug reports to Jari or to the ntemacs-users list. Also, if you would like to get updates directly from Jari, let Jari know that you are using TinyPgp by sending him email.

How Do I Use Emacs with Microsoft Visual C++

VisEmacs

For a close coupling of Emacs and MSVC, Christopher Payne <[email protected]> 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.

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.) [Image of Customize dialog]

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 <[email protected]> EmacsEdit "expert" for interfacing C++ Builder and Emacs.

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 Win95.

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 <[email protected]> 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 <[email protected]> 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.
Intellimouse: To use the wheel as a middle button, select "Standard behavior" and "Paste on one click". To use the wheel, disable "Universal Scrolling".
MouseMan: Select "Use Office 97 Compatible Scroll Only".

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 <[email protected]>:

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 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 <[email protected]> also has some suggestions for improving the interaction of perldb and Emacs.

How do I use hexl-mode with Emacs?

On NT, you should be able to use hexl-mode as you would on Unix (e.g., M-x hexl-mode and you're off to the races). On Windows 95, however, you won't be able to use hexl-mode if you use command.com as your shell because it doesn't accept input from stdin. Instead, you will have to use one of the non-system shells (see the section below on shells for more info on some shells you can use). You might also have to explicitly set hexlify-command and dehexlify-command; for more info from users who have gotten it to work on their system, take a look at these suggestions.

If you are having trouble with hexl-mode and bash, see Andrew's comments on the topic.

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/.

<a name="