Fix single-quoting style in PDF manuals
[emacs.git] / doc / misc / efaq-w32.texi
blobf8a188dba6b1eae5cf130930dccf7ea3bfd3b309
1 \input texinfo    @c -*-coding:utf-8 -*-
2 @setfilename ../../info/efaq-w32.info
3 @settitle GNU Emacs FAQ For MS Windows
4 @include docstyle.texi
5 @setchapternewpage odd
6 @syncodeindex pg cp
7 @syncodeindex ky cp
8 @syncodeindex tp cp
9 @syncodeindex vr fn
11 @documentdescription
12 Answers to Frequently asked Questions about using Emacs on Microsoft Windows.
13 @end documentdescription
15 @include emacsver.texi
17 @copying
18 Copyright @copyright{} 2008, 2010-2015 Free Software Foundation, Inc.
20 @quotation
21 This list of frequently asked questions about GNU Emacs on MS Windows
22 with answers (``FAQ'') may be translated into other languages,
23 transformed into other formats (e.g., Texinfo, Info, WWW), and updated
24 with new information.
26 The same conditions apply to any derivative of the FAQ as apply to the FAQ
27 itself.  Every copy of the FAQ must include this notice or an approved
28 translation, information on who is currently maintaining the FAQ and how to
29 contact them (including their e-mail address), and information on where the
30 latest version of the FAQ is archived (including FTP information).
32 The FAQ may be copied and redistributed under these conditions, except that
33 the FAQ may not be embedded in a larger literary work unless that work
34 itself allows free copying and redistribution.
35 @end quotation
36 @end copying
38 @dircategory Emacs
39 @direntry
40 * Emacs W32 FAQ: (efaq-w32).    FAQs about Emacs on MS Windows.
41 @end direntry
43 @c The @titlepage stuff only appears in the printed version
44 @titlepage
45 @sp 10
46 @center @titlefont{GNU Emacs FAQ for MS Windows}
48 @c The following two commands start the copyright page.
49 @page
50 @vskip 0pt plus 1filll
51 @insertcopying
52 @end titlepage
54 @footnotestyle end
56 @node Top
57 @top GNU Emacs FAQ for MS Windows
59 This is the FAQ for using GNU Emacs on MS Windows, as distributed with
60 Emacs @value{EMACSVER}.
62 This FAQ is maintained by the developers and users of Emacs on MS Windows.
63 If you find any errors, or have any suggestions, please send them to
64 the @url{http://lists.gnu.org/mailman/listinfo/help-emacs-windows,
65 help-emacs-windows} mailing list.
67 At time of writing, the latest version of GNU Emacs is version @value{EMACSVER}.
69 @c Links to ftp.gnu.org are given as http links, since Windows ftp clients
70 @c are notoriously bad at handling firewalls etc.
72 @ifnottex
73 @insertcopying
74 @end ifnottex
76 @contents
78 @menu
79 * Introduction::
80 * Getting Emacs::
81 * Installing Emacs::
82 * Display Settings::
83 * Fonts and text translation::
84 * Printing::
85 * Sub-processes::
86 * Network access::
87 * Text and Utility modes::
88 * Developing with Emacs::
89 * Other useful ports::
90 * Further information::
91 * Indexes::
92 @end menu
94 @c ------------------------------------------------------------
95 @node Introduction
96 @chapter Introduction
97 @cindex scope of FAQ
99 This FAQ covers questions that are specific to running GNU Emacs on Windows.
100 For more general information, see the other Emacs manuals.
101 @xref{Further information}.
103 @menu
104 * Why Emacs on Windows::
105 * Which versions of Windows::
106 * Other versions of Emacs::
107 @end menu
109 @node Why Emacs on Windows
110 @section Why support GNU Emacs on Windows?
111 @cindex Why Windows
113 It is not our goal to ``help Windows users'' by making text editing
114 on Windows more convenient.  We aim to replace proprietary software,
115 not to enhance it.  So why support GNU Emacs on Windows?
117 We hope that the experience of using GNU Emacs on Windows will give
118 programmers a taste of freedom, and that this will later inspire them
119 to move to a free operating system such as GNU/Linux.  That is the
120 main valid reason to support free applications on nonfree operating
121 systems.
123 @node Which versions of Windows
124 @section Which versions of Windows are supported?
125 @cindex Windows, versions
126 @cindex supported versions of Windows
128 Emacs @value{EMACSVER} is known to run on all versions of Windows from
129 Windows 98 and Windows NT 4.0 through to Windows 8.1.  The Windows
130 port is built using the Win32 API and supports most features of the X
131 version, including variable width fonts, images and tooltips.
133 Emacs on Windows can be compiled as either a 32-bit or a 64-bit
134 executable, using the MinGW GCC compiler and development tools.
136 @node Other versions of Emacs
137 @section What other versions of Emacs run on Windows?
138 @cindex other ports of Emacs
140 @xref{Cygwin}.
142 @cindex DOS port
143 @cindex Windows 3.11 port
144 Emacs can also be compiled for MSDOS.  When run on recent MS Windows,
145 it supports long file names, and uses the Windows clipboard.
146 See the @file{msdos} directory in the Emacs sources for building
147 instructions (requires DJGPP).
149 @c ------------------------------------------------------------
150 @node Getting Emacs
151 @chapter Getting Emacs
153 @menu
154 * Downloading::
155 * Compiling::
156 * Debugging::
157 @end menu
159 @node Downloading
160 @section Where can I download Emacs?
162 @cindex precompiled binaries
163 @cindex where to get Emacs binaries
164 Pre-compiled versions are distributed from
165 @uref{http://ftpmirror.gnu.org/emacs/windows/, ftp.gnu.org mirrors}.
166 Emacs binaries are distributed as zip files, digitally signed by the
167 developer who built them.  Generally most users will want the file
168 @file{emacs-@value{EMACSVER}-bin-i686-pc-mingw.zip} for the 32-bit
169 build, and @file{emacs-@value{EMACSVER}-bin-x86_64-w64-mingw32.zip}
170 for the 64-bit build.  The zip archive contains everything you need to
171 get started.
173 @cindex where to get sources
174 @cindex Emacs source code
175 @cindex source for Emacs
176 The latest source is available from
177 @uref{http://ftpmirror.gnu.org/emacs/, ftp.gnu.org mirrors}.  It is
178 distributed as a compressed tar file, digitally signed by the maintainer
179 who made the release.
181 @cindex getting Emacs
182 @cindex latest development version of Emacs
183 @cindex Emacs Development
184 The development version of Emacs is available from
185 @uref{http://savannah.gnu.org/projects/emacs, Savannah}, the GNU
186 development site.
188 @node Compiling
189 @section How can I compile Emacs myself?
190 @cindex compiling Emacs
192 To compile Emacs on Windows, you will need the MinGW port of GCC and
193 Binutils, the MinGW runtime and development environment, and the MSYS
194 suite of tools.  For the details, see the file @file{nt/INSTALL} in
195 the Emacs source distribution.
197 Support for displaying images, as well as XML/HTML rendering and TLS
198 networking requires external libraries, the headers and import
199 libraries for which will need to be installed where your compiler can
200 find them.  Again, the details, including URLs of sites where you can
201 download these libraries are in @file{nt/INSTALL}.  @xref{Other useful
202 ports}, for auxiliary tools you may wish to install and use in
203 conjunction with Emacs.
205 After unpacking the source, or checking out of the repository, be sure
206 to read the instructions in @file{nt/README} and @file{nt/INSTALL}.
208 @node Debugging
209 @section How do I use a debugger on Emacs?
210 @cindex debugging Emacs
211 @cindex bugs in Emacs, how to debug
212 @cindex Emacs debugging
214 By default, Emacs is compiled with debugging on, and optimizations enabled.
215 The optimizations may interfere with some types of debugging; the debugger
216 may not show clearly where it is, or may not be able to inspect certain
217 variables.  If this is the case, reconfigure with @kbd{CFLAGS='-O0 -g3'}
219 The file @file{etc/DEBUG} contains general debugging hints, as well as
220 specific notes about debugging Emacs.
222 @cindex debugging Emacs with GDB
223 GDB is the GNU debugger, which can be used to debug Emacs when it has
224 been compiled with MinGW GCC.  The best results will be obtained if
225 you start gdb from the @file{src} directory as @kbd{gdb ./emacs.exe}.
226 This will load the init file @file{.gdbinit}@footnote{
227 Latest versions of GDB might refuse to load the init file for security
228 reasons, unless you customize GDB; alternatively, use an explicit
229 @kbd{source ./gdbinit} command after entering GDB.
230 } in that directory, to define some extra commands for working with
231 lisp while debugging, and set up breakpoints to catch abnormal
232 aborts.
234 A Windows port of GDB can be found on MinGW download sites and on some
235 others.
237 @c ------------------------------------------------------------
238 @node Installing Emacs
239 @chapter Installing Emacs
241 @menu
242 * Unpacking::
243 * Installing binaries::
244 * Image support::
245 * Init file::
246 * Location of init file::
247 * Troubleshooting init file::
248 * Associate files with Emacs::
249 * Find-file and the Desktop::
250 * Make Windows more like X::
251 * Make Emacs like a Windows app::
252 * Window operations::
253 * Uninstall::
254 * Does not run::
255 * Virus::
256 * Anti-virus::
257 @end menu
259 @node Unpacking
260 @section How do I unpack the distributions?
261 @cindex unpacking Emacs distribution
262 @cindex extracting Emacs distribution
263 @cindex unzipping Emacs distribution
264 @cindex untarring Emacs distribution
265 @cindex zip files, how to unpack Emacs binaries
266 @cindex tar.gz files, how to unpack Emacs sources
268 The binary distributions are distributed as zip files, which are handled
269 natively by Windows XP and later.  For earlier versions, there are many
270 tools that can handle the zip format, from InfoZip's command line unzip
271 tool, to 7zip's multi-format graphical archive explorer.  (Although
272 popular, WinZip has caused problems with line-ends in the past, and is not
273 Free software, so we do not recommend it.)
275 Source distributions are distributed as @file{.tar.gz} or
276 @file{.tar.xz} files.  7zip and similar multi-format graphical tools
277 can handle these, or you can get Windows ports of the command line
278 gzip and tar tools from multiple sources, or use @command{bsdtar}.
279 @xref{Other useful ports}.
281 The command to unpack a source distribution from the command line is:
283 @example
284 tar xzf emacs-@value{EMACSVER}.tar.gz
285 @end example
287 If this does not work with the versions of tar and gzip that you have,
288 you may need to try a two step process:
290 @example
291 gzip -dc emacs-@value{EMACSVER}.tar.gz | tar xf -
292 @end example
294 You may see many messages from tar complaining about being unable to change
295 the modification time on directories, and from gzip complaining about a
296 broken pipe.  These messages are usually harmless, caused by incomplete ports
297 that are not fully aware of the limitations of Windows.
299 And here's an example of using @command{bsdtar} (from the
300 @samp{libarchive} package) to unpack a @file{.tar.xz} archive:
302 @example
303 bsdtar -xf emacs-@value{EMACSVER}.tar.xz
304 @end example
306 Expect @command{bsdtar} to unpack the whole distribution without any
307 complaints.
309 Once you unpack the source distribution, look in @file{nt/INSTALL}
310 file for build instructions.
312 @node Installing binaries
313 @section How do I install Emacs after unpacking the binary zip?
314 @cindex installing Emacs
315 @pindex addpm
316 @cindex Start Menu, creating icons for Emacs
318 You can run Emacs without any extra steps, but if you want icons in your
319 Start Menu, or for Emacs to detect the image libraries that are already
320 installed on your system as part of GTK, then you should run the program
321 @file{addpm.exe}, which is usually installed into the same @file{bin}
322 directory with @file{emacs.exe}.
324 @node Image support
325 @section How do I get image support?
326 @cindex images, installing libraries for
327 @cindex jpeg, installing image support in Emacs
328 @cindex png, installing image support in Emacs
329 @cindex gif, installing image support in Emacs
330 @cindex tiff, installing image support in Emacs
331 @cindex xpm, installing image support in Emacs
332 @cindex rsvg, installing image support in Emacs
333 @cindex toolbar, installing color icons in
334 @cindex color images, installing support for images in Emacs
335 @cindex monochrome images, getting color images in Emacs
336 @cindex black and white images, getting color images in Emacs
338 Emacs has built in support for XBM and PBM/PGM/PPM images.  This is
339 sufficient to see the monochrome splash screen and tool-bar icons.
340 Since v22.2, the official precompiled binaries for Windows have bundled
341 libXpm, which is required to display the color versions of those images.
343 Emacs is compiled to recognize JPEG, PNG, GIF, TIFF, and RSVG images
344 also, but displaying these image types require external DLLs which are
345 not bundled with Emacs.  @xref{Other useful ports}.
347 @node Init file
348 @section What is my init file?
349 @cindex .emacs
350 @cindex init file
352 When Emacs starts up, it attempts to load and execute the contents of
353 a file commonly called @file{.emacs} (though it may have other names,
354 @pxref{Location of init file,,Where do I put my init file?}) which
355 contains any customizations you have made.  You can manually add lisp
356 code to your .emacs, or you can use the Customization interface
357 accessible from the @emph{Options} menu.  If the file does not exist,
358 Emacs will start with the default settings.
360 @node Location of init file
361 @section Where do I put my init file?
362 @cindex HOME directory
363 @cindex .emacs.d
364 @cindex _emacs
365 @cindex init.el
366 @cindex registry, setting the HOME directory in
368 On Windows, the @file{.emacs} file may be called @file{_emacs} for
369 backward compatibility with DOS and FAT filesystems where filenames
370 could not start with a dot.  Some users prefer to continue using such
371 a name due to historical problems various Windows tools had in the
372 past with file names that begin with a dot.  In Emacs 22 and later,
373 the init file may also be called @file{.emacs.d/init.el}.  Many of the
374 other files that are created by lisp packages are now stored in the
375 @file{.emacs.d} directory too, so this keeps all your Emacs related
376 files in one place.
378 All the files mentioned above should go in your @env{HOME} directory.
379 The @env{HOME} directory is determined by following the steps below:
381 @enumerate
382 @item
383 If the environment variable @env{HOME} is set, use the directory it indicates.
384 @item
385 If the registry entry @code{HKCU\SOFTWARE\GNU\Emacs\HOME} is set, use the
386 directory it indicates.
387 @item
388 If the registry entry @code{HKLM\SOFTWARE\GNU\Emacs\HOME} is set, use the
389 directory it indicates.  Not recommended, as it results in users sharing
390 the same HOME directory.
391 @item
392 If @file{C:\.emacs} exists, then use @file{C:/}.  This is for
393 backward compatibility, as previous versions defaulted to @file{C:/}
394 if @env{HOME} was not set.
395 @item
396 Use the user's AppData directory, usually a directory called
397 @file{AppData} under the user's profile directory, the location
398 of which varies according to Windows version and whether the computer is
399 part of a domain.
400 @end enumerate
402 Within Emacs, @key{~} at the beginning of a file name is expanded to your
403 @env{HOME} directory, so you can always find your @file{.emacs} file
404 by typing the command @kbd{C-x C-f ~/.emacs}.
406 @node Troubleshooting init file
407 @section Troubleshooting init file problems
408 @cindex troubleshooting init problems
409 @cindex debugging init problems
410 @cindex checking that HOME is set correctly
412 If you've set @env{HOME} to a directory using one of the above
413 methods, and Emacs still doesn't load your init file, the first
414 thing you should do is check to see what Emacs thinks @env{HOME} is set
415 to.  You can do this by evaluating the following expression in the
416 @file{*scratch*} buffer using @kbd{C-x C-e}:
418 @example
419 (getenv "HOME")
420 @end example
422 Look carefully at what is printed in the echo area, and make sure the
423 value is valid.  For example, if the value has trailing whitespace,
424 Emacs won't be able to find the directory.  Also, be sure that the
425 value isn't a relative drive letter (e.g., @file{d:} without a
426 backslash or a forward slash after the colon); if it is, then
427 @env{HOME} is going to be whatever the current directory on that drive
428 is, which is likely not what you want to happen.
430 @node Associate files with Emacs
431 @section How do I associate files with Emacs?
432 @cindex Explorer, associating Emacs with files in
433 @cindex emacsclient, associating files with
434 @cindex file associations
435 @cindex associating files with Emacs
436 @cindex ALTERNATE_EDITOR
437 @findex server-start
439 The recommended way to associate files is to associate them with
440 @command{emacsclientw.exe}.  In order for this to work when Emacs is
441 not yet started, you will also need to set the environment variable
442 @env{ALTERNATE_EDITOR} to @command{runemacs.exe}.  To open files
443 in a running instance of Emacs, you will need to add the following
444 to your init file:
445 @example
446 (server-start)
447 @end example
449 @menu
450 * Using with Explorer::
451 @end menu
453 @node Using with Explorer
454 @subsection For use with Internet Explorer
455 @cindex Internet Explorer, view source in Emacs
456 @cindex mailto urls, associating with Emacs
457 @cindex news urls, associating with Emacs
458 @cindex URLs, associating mail and news URLs with Emacs
460 You can use Emacs as the editor for composing mail for
461 @indicateurl{mailto:} links, reading usenet for @indicateurl{news:}
462 links, and viewing source.  The following registry entries control
463 this:
465 @itemize @w{}
466 @item
467 Mail
468 @itemize
469 @item @strong{Key:} HKCR\mailto\shell\open\command\(Default)
470 @item @strong{Value:} emacsclientw -e "(message-mail (substring \"%1\" 7))"
471 @end itemize
473 @item
474 News
475 @itemize
476 @item @strong{Key:} HKCR\news\shell\open\command\(Default)
477 @item @strong{Value:} emacsclientw -e "(gnus-fetch-group (substring \"%1\" 5)"
478 @end itemize
480 @item
481 View Source
482 @itemize
483 @item @strong{Key:} HKCR\htmlfile\shell\edit\command\(Default)
484 @item @strong{Value:} emacsclientw "%1"
485 @end itemize
487 @end itemize
489 Thanks to Jason Rumney and Sigbjorn Finne for these tips.
491 @node Find-file and the Desktop
492 @section How do I use find-file to open files that are on the Desktop?
493 @cindex Desktop, finding where it is
494 @cindex finding the Desktop
495 @cindex locating files on the Desktop
497 The location of the Desktop varies between different versions of
498 Windows, and in a corporate environment can be moved around by the
499 network administrator.  On latest Windows versions, you can use the
500 value of the @env{USERPROFILE} environment variable to find where the
501 desktop might be:
503 @example
504 @kbd{C-x C-f $USERPROFILE/Desktop}
505 @end example
507 If this doesn't work, then you probably have to forgo the keyboard
508 just this once, and either drag a file onto the Emacs frame from the
509 desktop, or use the file dialog (displayed when you use the toolbar or
510 menu by default).  Once you have a file from the Desktop inside Emacs,
511 @kbd{C-x C-f} will quickly reveal where your desktop is kept.
513 @node Make Windows more like X
514 @section How can I modify Windows to act more like X?
515 @cindex X, making Windows behave like
517 @menu
518 * Focus follows mouse::
519 * Swap CapsLock and Control::
520 @end menu
522 @node Focus follows mouse
523 @subsection How do I make the active window follow the mouse?
524 @vindex focus-follows-mouse
525 @cindex point to focus
526 @cindex mouse over to focus
528 Customize the variables @code{focus-follows-mouse} and
529 @code{mouse-autoselect-window}.  The former can be used to mislead
530 Emacs into giving focus to other frames when the mouse is over them,
531 even though Windows has a click to focus policy by default (there is
532 software available to change that though).  The latter can be used to
533 make Emacs use a focus-follow-mouse policy within its own frames.
535 You can also change the Windows click-to-focus policy by changing
536 settings in the Registry.  The details vary according to your Windows
537 version; look on the Internet for instructions to enable ``active
538 window tracking'' for your version of Windows.
540 @node Swap CapsLock and Control
541 @subsection How do I swap CapsLock and Control?
542 @cindex scan codes, modifying
543 @cindex key layout, customizing
544 @cindex caps-lock, swapping with control key
545 @cindex control key, swapping with caps-lock
546 @cindex windows key, use as alt
547 @cindex alt key, using windows keys as additional
549 This cannot be done within Emacs, but you can modify the scan code
550 mappings in the registry or define a new keyboard layout to swap the
551 keys on a system wide basis.
553 @menu
554 * Swap Caps NT::
555 * Swap Caps 98::
556 @end menu
558 @node Swap Caps NT
559 @subsubsection Windows NT/2000/XP/Vista?
561 @itemize
562 @item
563 From Chris McMahon.  To make CapsLock a Control key (leaving your
564 original control keys as they were), use this registry file:
565 @example
566 REGEDIT4
568 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
569 "Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
570 @end example
571 To swap CapsLock and the left Control key, use:
572 @example
573 REGEDIT4
575 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
576 "Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,1d,00,3a,00,3a,00,1d,00,00,00,00,00
577 @end example
578 Save these as files with a @file{.reg} extension, and double-click on
579 them in Explorer, or ``run'' them from a command prompt to have them
580 update your registry (you may need to reboot).
581 @item
582 Shane Holder gives some background on how "Scancode Map" is used
583 by the system:
584 @ignore
585 http://ftp.gnu.org/old-gnu/emacs/windows/docs/ntemacs/contrib/caps-ctrl-registry.txt
586 From: Shane Holder <holder@@mordor.rsn.hp.com>
587 To: ntemacs-users@@cs.washington.edu
588 Date: 04 Dec 1996 14:36:21 -0600
589 Message-ID: <fawg21mm4hm.fsf@@mordor.rsn.hp.com>
590 Subject: Re: Re[2]: problem with caps/ctrl swap on NT 4.0
591 @end ignore
592 @smallexample
593 It's a binary value that lets you map keystrokes in the low-level keyboard
594 drivers in NT.  As a result you don't have to worry about applications
595 bypassing mappings that you've done at a higher level (i.e., it just works).
597 Here's the format of the value:
599         DWORD:  0x00000000      header
600         DWORD:  0x00000000      header
601         DWORD:  length (in DWORDs) of remaining data, including terminating DWORD
602         DWORD:  mapping 1
603         ...
604         DWORD:  mapping n
605         DWORD:  0x00000000      terminating null DWORD
607 Each mapping DWORD  has two parts: the input scancode, and an output
608 scancode.  To map scancode 0x1d (left control) to scancode 0x3a (caps
609 lock), you want a value of 0x003a001d.  Note that this does not swap the
610 keys.  Using just this mapping value, both the left control and the caps
611 lock key will behave as caps-lock.  To swap, you also need to map 0x3a to
612 0x1d, using 0x001d003a.
614 This registry value is system wide, and can't be made user-specific.  It
615 also only takes affect on reboot.
616 @end smallexample
617 @item
618 Ulfar Erlingsson has provided a registry file that sets the CapsLock key
619 to be a Control key and the Windows key to be an Alt key:
620 @example
621 REGEDIT4
623 [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
624 "Scancode Map"=hex:00,00,00,00,00,00,00,00,03,00,00,00,1d,00,3a,00,38,00,5b,e0,00,00,00,00
625 @end example
626 @end itemize
628 @node Swap Caps 98
629 @subsubsection Windows 95/98/ME
631 Microsoft has a tool called keyremap that is part of their Kernel Toys add ons
632 for Windows 95.  The tool has also been confirmed to work on Windows 98.
634 @node Make Emacs like a Windows app
635 @section How can I modify Emacs to act more like a Windows app?
636 @cindex Windows, making Emacs act more like
637 @cindex UI, making Emacs more like other Windows apps
639 Many beginning users find Emacs difficult to use because its user
640 interface is different in many ways.  Emacs predates most UI
641 standards, and experienced Emacs users are used to the way things are,
642 so changing the defaults is difficult.  Most of the ``standard''
643 behavior can be approximated in Emacs after some configuring though.
645 @menu
646 * Highlight selection::
647 * CUA::
648 @end menu
650 @node Highlight selection
651 @subsection Highlighting the selection
652 @cindex transient-mark-mode
653 @cindex selection, highlighting
654 @cindex region, highlighting
655 @cindex highlighting the selected region
656 @cindex marked region, highlighting
657 @cindex point and mark, highlighting the region between
658 @cindex delete-selection-mode
659 @cindex overwriting the selected region
661 Emacs has a concept of a mark and point that is similar to selections
662 in other programs.  But the mark in Emacs is used for more than just
663 defining the selected region, it lives on while you continue to edit
664 and move around the buffer so it can also be a kind of bookmark.  The
665 history of marks is saved so you can pop previous marks back to the
666 top of the stack to go back to somewhere you were some time ago.
667 Because of this dual purpose, the region between mark and point is not
668 highlighted by default unless you select a region by clicking and
669 dragging the mouse.
671 The minor mode @code{transient-mark-mode} changes the behavior of
672 the mark in two ways.  First, it distinguishes between an active mark
673 that has just been defined or reactivated, and an inactive mark.  When
674 the mark is active, some commands that normally act on lines, words,
675 buffers, etc., will instead act on the region.  An inactive mark needs
676 to be reactivated to operate on it, unless @code{mark-even-if-inactive}
677 is set.  Secondly, @code{transient-mark-mode} also highlights the
678 region when it is active, providing the same visual clue that you get
679 in other programs.  This mode is turned on by default in latest
680 versions of Emacs.
682 In addition to seeing the highlighting, new Emacs users often expect
683 editing commands to replace the region when it is active.  This behavior
684 can be obtained with @code{delete-selection-mode}, but see the following
685 question also.
687 @node CUA
688 @subsection Standard Windows key bindings
689 @findex cua-mode
690 @cindex CUA keybindings
691 @cindex shift key, selecting with
692 @cindex standard Windows keybindings
693 @cindex paste with C-v
694 @cindex cut with C-x
695 @cindex copy with C-c
696 @cindex C-c to copy
697 @cindex C-x to cut
698 @cindex C-v to paste
700 The keybindings of Emacs predate modern GUIs, and the keys that were
701 chosen by later GUIs for cut and copy were given important functions
702 as extended keymaps in Emacs.  CUA mode attempts to let both bindings
703 co-exist by defining C-x and C-c as @code{kill-region} and
704 @code{copy-region-as-kill} when the region is active, and letting
705 them have their normal Emacs bindings when the region is not active.
706 Many people find this to be an acceptable compromise.  CUA mode also
707 defines a number of other keys (C-v, Shift selection), and can be turned
708 on from the @emph{Options} menu.
710 @node Window operations
711 @section Window operations
712 @cindex maximize frames from lisp
713 @cindex minimize frames from lisp
714 @cindex WM_SYSCOMMAND, sending system commands from lisp
715 @cindex system menu, simulating from lisp
717 The function @code{w32-send-sys-command} can be used to simulate
718 choosing commands from the system menu (in the top left corner of the
719 Window) and a few other system wide functions.  It takes an integer
720 argument, the value of which should be a valid @code{WM_SYSCOMMAND}
721 message as documented in Microsoft's API documentation.
723 @node Uninstall
724 @section How do I uninstall Emacs?
725 @cindex uninstall Emacs
726 @cindex remove Emacs
727 @cindex clean Emacs registry settings
728 @cindex registry, cleaning the Emacs settings
729 @cindex Start Menu, removing Emacs from
730 @cindex upgrading Emacs
731 @cindex delete Emacs directory
733 Emacs does not come with an uninstall program.  No files are installed
734 outside of the directories you find in the binary zip archive, so
735 deleting those directories is sufficient to clean away the files.  If
736 you ran @command{addpm}, you'll need to delete the Start Menu group
737 too.  The registry entries inserted by @command{addpm} will not cause
738 any problems if you leave them there, but for the sake of
739 completeness, you can use @command{regedit} to remove the keys under
740 @code{HKEY_LOCAL_MACHINE} or @code{HKEY_CURRENT_USER}:
741 @code{SOFTWARE\GNU\Emacs}, and the key
742 @code{HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App
743 Paths\emacs.exe} if it exists.
745 @node Does not run
746 @section When I run Emacs nothing happens
747 @cindex troubleshooting installation problems
748 @cindex window not appearing, Emacs
749 @cindex failure to run, Emacs
750 @cindex 8.3 filenames, problems caused
752 Emacs could have failed to run for a number of reasons.  The most
753 common symptom is that, when Emacs is started, the cursor changes for
754 a second but nothing happens.  If this happens to you, it is quite
755 likely that the distribution was unpacked incorrectly.
757 Check for the following to see if there was a problem during unpacking:
758 @enumerate
759 @item
760 Be sure to disable the CR/LF translation or the executables will be
761 unusable.  Older versions of WinZipNT would enable this translation by
762 default.  If you are using WinZipNT, disable it.
763 @item
764 Check that filenames were not truncated to 8.3.  For example, there
765 should be a file CONTRIBUTE in the top level directory; if this has
766 been truncated to CONTRIBU or CONTRI~1, your distribution has been
767 corrupted while unpacking and Emacs will not start.
768 @end enumerate
770 If it is still not working, send mail to the
771 @email{help-gnu-emacs@@gnu.org} mailing list, describing what you've
772 done, and what you are seeing. (The more information you send the more
773 likely it is that you'll receive a helpful response.)
775 @node Virus
776 @section Does Emacs contain a virus?
777 @cindex virus reported in Emacs
778 @cindex anti-virus software reporting a virus in Emacs
780 There have been reports in the past that some virus scanners claim
781 that the Emacs distribution has a virus.  This is extremely unlikely if
782 you have downloaded Emacs from the GNU FTP site or one of its mirrors
783 and the GPG signature for it is valid and listed in the GNU keyring,
784 unless perhaps it is a new release made in the last few days, in which
785 case you should exercise more caution and report the problem.  Past
786 problems seem to have been caused by virus checkers running into a
787 buffer size limit when unpacking large tar.gz files for scanning, and
788 reporting the failure as an ``unknown virus''.
790 @node Anti-virus
791 @section What known problems are there with anti-virus software?
792 @cindex anti-virus software, bad interaction with
793 @cindex virus software, bad interaction with
794 @cindex firewall, bad interaction with
795 @cindex scan all files, anti-virus option causing problems
796 @cindex auto protect, anti-virus option causing problems
797 @cindex shell, interacting badly with anti-virus
798 @cindex subprocesses, interacting badly with anti-virus
800 Anti-virus and firewall software can block Emacs from starting subprocesses
801 and opening network connections.  Most such products have an Advanced
802 mode where they will prompt you rather than silently blocking.  In some cases
803 the ``scan all files'' or ``auto protect'' option of anti-virus programs
804 has caused failures running shell related commands within Emacs.
805 @xref{Sub-processes,,Why is nothing happening when I enter shell commands?}.
807 @c ------------------------------------------------------------
808 @node Display Settings
809 @chapter Display Settings
811 @menu
812 * Console window size::
813 * Mouse trouble::
814 * Cut and paste NUL::
815 * Garbled clipboard::
816 * Beep sound::
817 @end menu
819 @node Console window size
820 @section Emacs in console mode goes beyond the window size
821 @cindex console, window size
822 @cindex telnet, display size problems running emacs over
823 @cindex -nw, window size
824 @vindex w32-use-full-screen-buffer
826 The variable @code{w32-use-full-screen-buffer} controls whether Emacs uses
827 the window size or buffer size to determine the number of lines on screen.
828 Normally the window size is correct, but when running Emacs over some
829 telnet servers, the buffer size needs to be used.  Emacs tries to guess
830 the correct value at startup, but if it guesses wrong, you can customize
831 that variable yourself.
833 @node Mouse trouble
834 @section What do I do if I have problems with my mouse buttons?
835 @cindex mouse buttons, problems with
836 @cindex 2 button mouse
837 @cindex two button mouse
838 @cindex third mouse button, simulating
839 @cindex middle mouse button, simulating
840 @cindex simulating three button mouse with two buttons
841 @cindex swap right and middle mouse buttons
842 @cindex exchange mouse-2 and mouse-3 buttons
843 @vindex w32-mouse-button-tolerance
844 @vindex w32-num-mouse-buttons
845 @vindex w32-swap-mouse-buttons
847 Emacs assigns bindings assuming a three button mouse.  On Windows, if
848 a two button mouse is detected, a hack is enabled which lets you
849 simulate the third button by pressing both mouse buttons
850 simultaneously.  @code{w32-mouse-button-tolerance} defines the timeout
851 for what is considered ``simultaneous''.  You can check how many
852 buttons Emacs thinks your mouse has with @kbd{C-h v}
853 @code{w32-num-mouse-buttons}.
855 If you find yourself needing the mouse-3 bindings more often than mouse-2,
856 you can swap the buttons with the following code in your init file:
857 @example
858 (setq w32-swap-mouse-buttons t)
859 @end example
861 @node Cut and paste NUL
862 @section How do I cut and paste text with NUL characters?
863 @cindex clipboard, NUL characters
865 If you attempt to cut and paste text with NUL characters embedded in it,
866 then the text will be truncated at the first NUL character.  This is a
867 limitation of the Windows clipboard, and does not affect killing and yanking
868 from the kill-ring within Emacs.
870 @node Garbled clipboard
871 @section How can I fix garbled text yanked from the clipboard?
872 @cindex clipboard, corruption of
873 @cindex garbage on the clipboard
874 @cindex clipboard encoding
875 @cindex encoding, clipboard
876 @findex set-selection-coding-system
878 You can try @code{set-selection-coding-system}, but generally such
879 corruption is a thing of the past, as Emacs uses Unicode for the clipboard
880 by default now.
882 @node Beep sound
883 @section How do I change the sound of the Emacs beep?
884 @cindex beep, changing the sound
885 @cindex sound, changing the beep
886 @findex set-message-beep
888 You can use the function @code{set-message-beep} to change the sound
889 that Emacs uses for its beep.  This affects both console and GUI frames.
890 The doc string contains a list of the system sounds you can use.
892 @c ------------------------------------------------------------
893 @node Fonts and text translation
894 @chapter Fonts and text translation
896 @menu
897 * Font names::
898 * Bold and italic::
899 * Multilingual fonts::
900 * Font menu::
901 * Line ends::
902 @end menu
904 @node Font names
905 @section Font names
906 @cindex XLFD font names
907 @cindex font XLFD name format
908 @cindex fontconfig font names in Emacs 23
909 @cindex font dialog, using to find font names
910 @findex w32-select-font
911 @findex x-list-fonts
913 Fonts in Emacs 22 and earlier are named using the X Logical Font
914 Description (XLFD) format.  Emacs on Windows ignores many of the
915 fields, and populates them with * when listing fonts.  Former
916 maintainer Andrew Innes wrote
917 @uref{http://www.gnu.org/software/emacs/windows/ntemacs/discuss/x-font-details,
918 this explanation} of what each field in the font string means and how
919 Emacs treated them back in 19.34.  Since then, multilingual support and
920 a redisplay overhaul to support variable width fonts have changed things
921 slightly; more character sets are recognized (and the old pseudo character
922 sets are deprecated), and the resolution fields are used to calculate the
923 difference between point and pixel sizes, but normally you should leave
924 these at the system default.  The foundry field is also populated with
925 an indication of whether the font is outline (.TTF, .ATM) or raster (.FON)
926 based when fonts are listed, which may let you differentiate between two
927 fonts with the same name and different technologies.
929 Starting with Emacs 23, the preferred font name format will be moving
930 to the simpler and more flexible fontconfig format.  XLFD names will
931 continue to be supported for backward compatibility.
933 @example
934 XLFD: -*-Courier New-normal-r-*-*-13-*-*-*-c-*-iso8859-1
935 Fontconfig: Courier New-13
936 @end example
938 To find the XFLD name for a font, you can execute the following in the
939 @file{*scratch*} buffer by pressing C-j at the end of the line:
940 @example
941 (w32-select-font nil t)
942 @end example
944 To see a complete list of fonts, execute the following in the
945 @file{*scratch*} buffer by pressing C-x C-e at the end of the line:
946 @example
947 (insert (prin1-to-string (x-list-fonts "*")))
948 @end example
950 The command line options and frame-parameters for changing the default font
951 in Emacs are documented in the manual.  Fonts can also be used when defining
952 faces, though family and size are generally specified individually there.
953 In addition, Emacs on Windows reads the registry to find X Resources.  This
954 is also documented in the manual.
956 @node Bold and italic
957 @section How can I get bold and italic fonts to work?
958 @cindex italic fonts
959 @cindex synthesized italic and bold fonts
960 @cindex bold fonts, synthesized
961 @findex set-face-font
962 @vindex w32-enable-synthesized-fonts
964 Emacs will only use the italic (and bold) versions of a font automatically
965 if it has the same width as the normal version.  Many fonts have italic
966 and bold versions that are slightly wider.  It will also only use real
967 bold and italic fonts by default, where other applications may use
968 synthesized variations that are derived from the normal font.  To enable
969 more italic and bold fonts to be displayed, you can enable synthesized fonts
970 and manually set the font for italic, bold and bold-italic as follows:
972 @example
973 (setq w32-enable-synthesized-fonts t)
974 (set-face-font 'italic "-*-Courier New-normal-i-*-*-11-*-*-*-c-*-iso8859-1")
975 (set-face-font 'bold-italic "-*-Courier New-bold-i-*-*-11-*-*-*-c-*-iso8859-1")
976 @end example
978 The @code{w32-enable-synthesized-fonts} variable is obsolete starting
979 from Emacs 24.4, as Emacs no longer has this limitation.
981 @node Multilingual fonts
982 @section Multilingual font support
983 @cindex multilingual display, fonts
984 @cindex MULE, fonts
986 @menu
987 * Language display::
988 * Non-latin display::
989 * International fonts::
990 * Third-party multibyte::
991 * Localized fonts::
992 @end menu
994 @node Language display
995 @subsection Is it possible to display all the supported languages?
996 @cindex HELLO file, displaying all
997 @cindex language support, fonts
998 @cindex GNU intlfonts, for displaying all languages
999 @cindex intlfonts, for displaying all languages
1001 To display all the languages that Emacs is capable of displaying, you will
1002 require the BDF fonts from the GNU intlfonts package.
1003 @xref{Fonts and text translation,,How do I use bdf fonts with Emacs?}.
1005 For many languages, native truetype fonts are sufficient, and in Emacs
1006 23 the need for BDF fonts will disappear for almost all languages.  At
1007 the time of writing, all supported characters are able to be displayed
1008 with appropriate truetype or opentype fonts.
1010 @node Non-latin display
1011 @subsection How do I get Emacs to display non-latin characters?
1012 @cindex fontsets, defining
1013 @cindex language support, forcing Emacs to use specific fonts
1014 @cindex MULE, fontsets
1015 @cindex multilingual display, fontsets
1016 @findex create-fontset-from-ascii-font
1017 @findex create-fontset-from-fontset-spec
1019 Recent versions of Emacs display a large range of characters out of
1020 the box, but if you are having problems with a particular character
1021 set which you know you have fonts for, you can try defining a
1022 new fontset with @code{create-fontset-from-ascii-font} or
1023 @code{create-fontset-from-fontset-spec}.
1025 @example
1026 (create-fontset-from-fontset-spec
1027  "-*-Courier New-normal-r-*-*-12-*-*-*-c-*-fontset-most,
1028  latin-iso8859-2:-*-Courier New-normal-r-*-*-12-*-*-*-c-*-iso8859-2,
1029  latin-iso8859-3:-*-Courier New-normal-r-*-*-12-*-*-*-c-*-iso8859-3,
1030  latin-iso8859-4:-*-Courier New-normal-r-*-*-12-*-*-*-c-*-iso8859-4,
1031  cyrillic-iso8859-5:-*-Courier New-normal-r-*-*-12-*-*-*-c-*-iso8859-5,
1032  greek-iso8859-7:-*-Courier New-normal-r-*-*-12-*-*-*-c-*-iso8859-7,
1033  latin-iso8859-9:-*-Courier New-normal-r-*-*-12-*-*-*-c-*-iso8859-9,
1034  japanese-jisx0208:-*-MS Gothic-normal-r-*-*-12-*-*-*-c-*-jisx0208-sjis,
1035  katakana-jisx0201:-*-MS Gothic-normal-r-*-*-12-*-*-*-c-*-jisx0208-sjis,
1036  latin-jisx0201:-*-MS Gothic-normal-r-*-*-12-*-*-*-c-*-jisx0208-sjis,
1037  japanese-jisx0208-1978:-*-MS Gothic-normal-r-*-*-12-*-*-*-c-*-jisx0208-sjis,
1038  korean-ksc5601:-*-Gulim-normal-r-*-*-12-*-*-*-c-*-ksc5601-*,
1039  chinese-gb2312:-*-MS Song-normal-r-*-*-12-*-*-*-c-*-gb2312-*,
1040  chinese-big5-1:-*-MingLiU-normal-r-*-*-12-*-*-*-c-*-big5-*,
1041  chinese-big5-2:-*-MingLiU-normal-r-*-*-12-*-*-*-c-*-big5-*" t)
1042 @end example
1044 Alternatively, you can augment the default fontset with information of
1045 which fonts to use for certain ranges of characters or for specific
1046 scripts/character sets.  @xref{Modifying Fontsets,, Modifying
1047 Fontsets, emacs, The GNU Emacs Manual}, for details and some useful
1048 examples.
1050 @node International fonts
1051 @subsection Where can I find fonts for other languages?
1052 @cindex language support, finding fonts
1053 @cindex fonts, where to find
1054 @cindex MULE, finding fonts
1055 @cindex multilingual display, finding fonts
1056 @cindex GNU intlfonts, where to get
1057 @cindex intlfonts, where to get
1059 In addition to the wide range of fonts that come with the language
1060 support packages of various components of Windows itself, GNU/Linux
1061 distributions these days come with a number of Free truetype fonts
1062 that cover a wide range of languages.  The GNU Unifont project
1063 contains glyphs for most of the Unicode codespace, and can be
1064 downloaded from @uref{http://ftpmirror.gnu.org/unifont, ftp.gnu.org
1065 mirrors}.
1067 @node Third-party multibyte
1068 @subsection How do I use third party programs to display multibyte characters?
1069 @cindex multilingual display, third party programs on Windows 9x/ME
1070 @cindex language support, third party programs on Windows 9x/ME
1071 @vindex w32-enable-unicode-output
1073 You probably only need to do this on the non-Unicode versions of Windows
1074 (95, 98 and ME), and even then, various Windows and Internet Explorer
1075 updates have made third party software unnecessary in most cases.
1076 If you are having trouble displaying text, try defining a fontset
1077 with the font for the languages that the third party software handles
1078 set to what that software expects (which may not be an appropriate font
1079 for that language, but the third party software is intercepting it
1080 and using a different font behind the scenes).
1081 @xref{Non-latin display}.
1083 @node Localized fonts
1084 @subsection Can I use a font with a name in my language?
1085 @cindex fonts, localized font names
1086 @vindex locale-coding-system
1088 Normally Emacs should initialize @code{locale-coding-system} appropriately
1089 based on your locale, which will let Emacs use font names in your local
1090 language successfully.
1092 @c This feature disappeared in Emacs 23, and was resurrected in 25.1.
1093 @node Font menu
1094 @section How can I have Emacs use a font menu like on X?
1095 @cindex fonts, displaying a menu
1096 @cindex fontsets, displaying a menu
1097 @cindex font dialog, using a menu instead
1098 @vindex w32-use-w32-font-dialog
1100 Place the following in your init file:
1102 @example
1103 (setq w32-use-w32-font-dialog nil)
1104 @end example
1106 @menu
1107 * Add fonts to menu::
1108 @end menu
1110 @c This variable had no effect between v23 and v25.1, where
1111 @c w32-use-w32-font-dialog support was resurrected, see above.
1112 @node Add fonts to menu
1113 @subsection How can I add my font to the font menu?
1114 @cindex font menu, adding fonts
1115 @vindex w32-fixed-font-alist
1117 If you have set w32-use-w32-font-dialog to @code{nil}, you can add fonts to
1118 the font menu by changing @code{w32-fixed-font-alist}.  For example:
1120 @example
1121 (setq w32-fixed-font-alist
1122    (append w32-fixed-font-alist
1123       '(("Monotype.com"
1124          ("8" "-*-Monotype.com-normal-r-*-*-11-*-*-*-c-iso8859-1")
1125          ("9" "-*-Monotype.com-normal-r-*-*-12-*-*-*-c-iso8859-1")
1126          ("10" "-*-Monotype.com-normal-r-*-*-13-*-*-*-c-iso8859-1")
1127          ("11" "-*-Monotype.com-normal-r-*-*-15-*-*-*-c-iso8859-1")))))
1128 @end example
1130 @node Line ends
1131 @section How can I control CR/LF translation?
1132 @cindex DOS line ends
1133 @cindex Unix line ends
1134 @cindex Mac line ends
1136 There are a number of methods by which you can control automatic CR/LF
1137 translation in Emacs, a situation that reflects the fact that the
1138 default support was not very robust in the past.  For a discussion of
1139 this issue, take a look at
1140 @uref{http://www.gnu.org/software/emacs/windows/ntemacs/todo/translate,
1141 this collection of email messages} on the topic.
1143 @menu
1144 * Automatic line ends::
1145 * Line ends by file system::
1146 @end menu
1148 @node Automatic line ends
1149 @subsection Automatic CR/LF translation
1150 @cindex line ends, automatic detection
1152 For existing files, Emacs scans the file to determine the line ending
1153 convention as part of the same scan it does to determine the file
1154 encoding.  Embedded Ctrl-M (ASCII 13) characters and inconsistent line
1155 ends can confuse the automatic scanning, and Emacs will present the
1156 file in Unix (LF) mode with the Ctrl-M characters displayed as @samp{^M}.
1157 It does this to be safe, as no data loss will occur if the file is really
1158 binary and the Ctrl-M characters are significant.
1160 @node Line ends by file system
1161 @subsection CR/LF translation by file system
1162 @cindex line ends, determining by filesystem
1163 @cindex binary files, determining by filesystem
1164 @vindex untranslated-filesystem-list
1165 @findex add-untranslated-filesystem
1166 @findex remove-untranslated-filesystem
1168 The variable @code{untranslated-filesystem-list} defines whole
1169 directory trees that should not have CR/LF autodetection performed on
1170 them.  The list can be manipulated with the functions
1171 @code{add-untranslated-filesystem} and
1172 @code{remove-untranslated-filesystem}.  With auto-detection in
1173 recent versions of Emacs, this is seldom useful for existing files,
1174 but can still be used to influence the choice of line ends for newly
1175 created files.
1177 @c ------------------------------------------------------------
1178 @node Printing
1179 @chapter Printing
1180 @cindex printing
1182 A lot of effort has gone into making it easier to print from Emacs on
1183 MS Windows, but this has still been insufficient to keep up with
1184 changes in printing technology from text and postscript based printers
1185 connected via ports that can be accessed directly, to graphical
1186 printers that are only accessible via USB.  For details, see
1187 @uref{http://www.emacswiki.org/emacs/PrintingFromEmacs, Emacs
1188 Wiki}, @uref{http://www.emacswiki.org/emacs/PrintWithWebBrowser}, and
1189 @uref{http://www.emacswiki.org/emacs/PrintFromWindowsExplorer}.
1191 @c ------------------------------------------------------------
1192 @node Sub-processes
1193 @chapter Subprocesses
1194 @cindex subprocesses
1196 @menu
1197 * Quoting issues::
1198 * Subprocess hang::
1199 * Subprocess buffering::
1200 * Subprocesses and floppy drive::
1201 * Killing subprocesses::
1202 * Subprocess EOF::
1203 * Using shell::
1204 * Cygwin paths::
1205 * Dired ls::
1206 * Shell echo::
1207 * Shell completion forward slash::
1208 * Incorrect DOS version::
1209 * Shell commands do nothing::
1210 @end menu
1212 @node Quoting issues
1213 @section Quoting issues
1214 @cindex quoting arguments to subprocesses
1215 @cindex sub-processes, quoting arguments to
1216 @cindex cygwin, quoting arguments
1218 The quoting rules for native Windows shells and Cygwin shells have
1219 some subtle differences.  When Emacs spawns subprocesses, it tries to
1220 determine whether the process is a Cygwin program and changes its
1221 quoting mechanism appropriately.
1223 @node Subprocess hang
1224 @section Programs reading input hang
1225 @cindex subprocesses, hanging when reading input
1226 @cindex full-screen console programs, as subprocesses
1227 @cindex ftp, client hanging
1228 @findex ftp
1230 Programs that explicitly use a handle to the console (@file{CON} or
1231 @file{CON:}) instead of stdin and stdout cannot be used as
1232 subprocesses to Emacs, and they will also not work in shell-mode.  The
1233 default ftp client on Windows is an example of such a program - this
1234 ftp program is mostly fine for use with @code{ange-ftp} or
1235 @code{tramp}, but not for @kbd{M-x ftp} (@pxref{Network access,,How do
1236 I use FTP within Emacs}).  There is no convenient way for either Emacs
1237 or any shell used in @code{shell-mode} to redirect the input and
1238 output of such processes from the console to input and output pipes.
1239 The only workaround is to use a different implementation of the
1240 program that does not use the console directly.  Microsoft's new
1241 PowerShell appears to be another such program, so that cannot be used
1242 as a replacement shell for Emacs.
1244 @node Subprocess buffering
1245 @section Buffering in shells and subprocesses
1246 @cindex subprocesses, buffering output
1247 @cindex output not displaying, subprocesses
1248 @cindex SQL subprocess hanging
1249 @cindex cvs hanging when login needed
1250 @cindex ssh, password prompt not appearing when using with cvs
1251 @findex sql-mode
1252 @findex shell-mode
1253 @cindex setbuf, using in subprocesses to prevent buffering
1254 @cindex setvbuf, using in subprocesses to prevent buffering
1256 You may notice that some programs, when run in a shell in
1257 @code{shell-mode},
1258 have their output buffered (e.g., people have found this happening to
1259 them with @code{sql-mode}).  When the program has a lot of output, it
1260 overflows the buffering and gets printed to the shell buffer; however,
1261 if the program only outputs a small amount of text, it will remain
1262 buffered and won't appear in the shell buffer.  The same can happen
1263 in other subprocesses that themselves run other programs as
1264 subprocesses, for example when using @command{cvs} from Emacs, which
1265 is itself configured to use @command{ssh}, password prompts fail to
1266 appear when expected, and @command{cvs} appears to hang.
1268 Although it may at first seem like the shell is buffering the output
1269 from the program, it is actually the program that is buffering
1270 output.  The C runtime typically decides how to buffer output based
1271 upon whether stdout is bound to a handle to a console window or
1272 not.  If bound to a console window, output is buffered line by line; if
1273 bound to a block device, such as a file, output is buffered block by
1274 block.
1276 In a shell buffer, stdout is a pipe handle and so is buffered in
1277 blocks.  If you would like the buffering behavior of your program to
1278 behave differently, the program itself is going to have to be changed;
1279 you can use @code{setbuf} and @code{setvbuf} to manipulate
1280 the buffering semantics.
1282 Some programs handle this by having an explicit flag to control their
1283 buffering behavior, typically @option{-i} for interactive, or by a
1284 special environment variable.  Other programs manage to detect that
1285 they are running under Emacs, by using @samp{getenv("emacs")}
1286 internally.  Look in the program's documentation for the way around
1287 this issue.
1289 @menu
1290 * Perl script buffering::
1291 @end menu
1293 @node Perl script buffering
1294 @subsection Perl script buffering
1295 @cindex perl, avoiding buffering when used as a subprocess of Emacs
1297 A handy solution for Perl scripts to the above problem is to use:
1299 @example
1300 # Turn all buffering off.
1301 select((select(STDOUT), $| = 1)[0]);
1302 select((select(STDERR), $| = 1)[0]);
1303 select((select(STDIN), $| = 1)[0]);
1304 @end example
1306 @node Subprocesses and floppy drive
1307 @section 16-bit subprocesses accessing the floppy drive
1308 @cindex floppy drive, access when subprocesses started
1309 @cindex subprocess starting causes floppy drive access
1311 If you are finding the 16 bit DOS subprocesses cause your A: drive to
1312 be accessed, hanging Emacs until the read times out if there is no
1313 floppy in the drive, check to see if your virus software is causing
1314 the problem.
1316 @node Killing subprocesses
1317 @section Killing subprocesses on Windows 95/98/Me
1318 @cindex subprocess, killing on Windows 95/98/ME
1319 @cindex killing subprocesses, Windows 95/98/ME
1320 @cindex shutdown, complaints about cmdproxy.exe running
1322 Emacs cannot guarantee that a subprocess gets killed on Windows 95 and
1323 its descendants, and it is a difficult limitation to work around.  To
1324 avoid problems on these systems, you should let subprocesses run to
1325 completion including explicitly exiting shells before killing the
1326 associated buffer.
1328 If you find that while shutting down, Windows complains that there is
1329 a running @command{cmdproxy.exe} even though you carefully exited all
1330 shells and none were showing in Task Manager before the shutdown, this
1331 could be due to buggy interaction with your virus scanner.
1333 @node Subprocess EOF
1334 @section Sending EOF to subprocesses
1335 @cindex EOF, sending to subprocesses
1336 @cindex shell terminates when EOF sent to subprocess
1337 @findex process-send-eof
1339 When an EOF is sent to a subprocess running in an interactive shell
1340 with @code{process-send-eof}, the shell terminates unexpectedly as
1341 if its input was closed.  This affects the use of @kbd{C-c C-d} in
1342 shell buffers.  See
1343 @uref{http://www.gnu.org/software/emacs/windows/ntemacs/todo/shell-ctrl-d,
1344 this discussion} for more details.
1346 @node Using shell
1347 @section How do I use a shell in Emacs?
1348 @cindex interactive shell, using
1349 @cindex shell within emacs, using
1350 @findex shell
1351 @findex  shell-command
1352 @vindex shell-file-name
1353 @vindex explicit-shell-file-name
1355 You can start an interactive shell in Emacs by typing @kbd{M-x shell}.
1356 By default, this will start the standard Windows shell @file{cmd.exe}.
1357 Emacs uses the @env{SHELL} environment variable to determine which
1358 program to use as the shell.  To instruct Emacs to use a non-default
1359 shell, you can either set this environment variable, or customize
1360 @code{explicit-shell-file-name}.  You can also customize
1361 @code{shell-file-name} to change the shell that will be used by
1362 subprocesses that are started with @code{shell-command} and
1363 related non-interactive shell commands.
1365 @menu
1366 * Bash::
1367 @end menu
1369 @node Bash
1370 @subsection bash
1371 @cindex cygwin bash as shell within Emacs
1372 @cindex shell, using cygwin bash within Emacs
1373 @cindex bash, using cygwin shell within Emacs
1374 @vindex comint-scroll-show-maximum-output
1375 @vindex comint-completion-addsuffix
1376 @vindex comint-eol-on-send
1377 @vindex w32-quote-process-args
1378 @vindex shell-mode-hook
1380 Cygwin bash is a popular shell for use with Emacs.  To use bash as the
1381 default shell in Emacs, you can place the following in your init file:
1383 @example
1384 (defun my-shell-setup ()
1385   "For Cygwin bash under Emacs 20"
1386   (setq comint-scroll-show-maximum-output 'this)
1387   (make-variable-buffer-local 'comint-completion-addsuffix))
1388   (setq comint-completion-addsuffix t)
1389   ;; (setq comint-process-echoes t) ;; reported that this is no longer needed
1390   (setq comint-eol-on-send t)
1391   (setq w32-quote-process-args ?\")
1393 (add-hook 'shell-mode-hook 'my-shell-setup)
1394 @end example
1396 WARNING: Some versions of bash set and use the environment variable
1397 PID.  For some as yet unknown reason, if @env{PID} is set and Emacs
1398 passes it on to bash subshells, bash dies (Emacs can inherit the
1399 @env{PID} variable if it's started from a bash shell).  If you clear
1400 the @env{PID} variable in your init file, you should be able to
1401 continue to use bash as your subshell:
1402 @example
1403     (setenv "PID" nil)
1404 @end example
1406 @node Cygwin paths
1407 @section How do I use Cygwin style paths in Emacs?
1408 @cindex cygwin paths, using within Emacs
1409 @cindex mount points, cygwin
1410 @cindex cygwin mount points, using within Emacs
1412 The package
1413 @uref{http://www.emacswiki.org/emacs/cygwin-mount.el,
1414 cygwin-mount.el} teaches Emacs about Cygwin mount points.
1416 @node Dired ls
1417 @section How do I make dired use my ls program?
1418 @cindex dired, using an external ls program
1419 @cindex dired, interpreting symlinks the same way as cygwin
1420 @cindex symlinks in dired, interpreting the same way as cygwin
1421 @cindex cygwin symlinks in dired
1422 @vindex ls-lisp-use-insert-directory-program
1423 @vindex insert-directory-program
1425 Dired uses an internal lisp implementation of @command{ls} by default
1426 on Windows.  For consistent display of symbolic links and other
1427 information with other programs (eg Cygwin) and performance reasons,
1428 you may want to use a Windows port of @command{ls} instead.
1430 @example
1431 (setq ls-lisp-use-insert-directory-program t)      ;; use external ls
1432 (setq insert-directory-program "c:/cygwin/bin/ls") ;; ls program name
1433 @end example
1435 @node Shell echo
1436 @section How do I prevent shell commands from being echoed?
1437 @cindex echo, suppressing for shell input
1438 @cindex shell commands, suppressing echo
1439 @vindex comint-process-echoes
1440 @vindex comint-mode-hook
1441 @vindex explicit-cmd.exe-args
1442 @vindex explicit-cmdproxy.exe-args
1443 @vindex explicit-bash.exe-args
1444 @vindex explicit-bash-args
1445 @cindex shell specific arguments
1447 Some shells echo the commands that you send to them, and the echoed
1448 commands appear in the output buffer.  In particular, the default
1449 shells, @command{command.com} and @command{cmd.exe}, have this behavior.
1451 To prevent echoed commands from being printed, you can place the
1452 following in your init file:
1454 @example
1455     (defun my-comint-init ()
1456       (setq comint-process-echoes t))
1457     (add-hook 'comint-mode-hook 'my-comint-init)
1458 @end example
1460 If @code{shell-mode} still is not stripping echoed commands, then
1461 you'll have to explicitly tell the shell to not echo commands.  You can
1462 do this by setting the @code{explicit-@var{SHELL}-args} variable
1463 appropriately; where @var{SHELL} is the value of your @env{SHELL}
1464 environment variable (do a @kbd{M-: (getenv "SHELL")} to see what it
1465 is currently set to).  Assuming that you are on NT and that your
1466 @env{SHELL} environment variable is set to @command{cmd.exe},
1467 then placing the following in your init file will tell
1468 @command{cmd.exe} to not echo commands:
1470 @example
1471     (setq explicit-cmd.exe-args '("/q"))
1472 @end example
1474 The comint package will use the value of this variable as an argument
1475 to @command{cmd.exe} every time it starts up a new shell; the
1476 @option{/q} is the argument to @command{cmd.exe} that stops the
1477 echoing (invoking @samp{cmd /?} in a shell will show you all of the
1478 command line arguments to @command{cmd.exe}).
1480 Note that this variable is case sensitive; if the value of your
1481 @env{SHELL} environment variable is @command{CMD.EXE} instead, then
1482 this variable needs to be named @code{explicit-CMD.EXE-args} instead.
1484 @node Shell completion forward slash
1485 @section How can I make shell completion use forward slashes?
1486 @cindex completion, using forward slashes in shell buffers
1487 @cindex forward slashes for completion in shell buffers
1488 @vindex comint-completion-addsuffix
1490 The character appended to directory names when completing in a shell
1491 buffer is controlled by the variable @code{comint-completion-addsuffix}.
1492 See its documentation (with @kbd{C-h v}) for details.
1494 @node Incorrect DOS version
1495 @section Why do I get incorrect DOS version messages?
1496 @cindex nmake, Incorrect DOS version messages
1497 @cindex shell, Incorrect DOS version messages
1498 @cindex COMSPEC, effect on subprocesses of subprocesses
1500 This might happen if, for example, you invoke @command{nmake} in a
1501 shell and it tries to create sub-shells.  The problem happens because
1502 when the shell is initially created, the first argument to the shell
1503 is not the directory in which the shell program resides.  When this
1504 happens, @command{command.com} fabricates a value for its
1505 @env{COMSPEC} environment variable that is incorrect.  Then, when
1506 other programs go to use @env{COMSPEC} to find the shell, they are
1507 given the wrong value.
1509 The fix for this is to either prevent any arguments from being sent to
1510 the shell when it starts up (in which case @command{command.com} will
1511 use a default, and correct, value for @env{COMSPEC}), or to have the
1512 first argument be the directory in which the shell executable resides.
1514 @node Shell commands do nothing
1515 @section Why is nothing happening when I enter shell commands?
1516 @cindex shell commands not working
1517 @cindex anti-virus software, bad interaction with
1518 @cindex virus software, bad interaction with
1519 @cindex firewall, bad interaction with
1520 @cindex scan all files, anti-virus option causing problems
1521 @cindex auto protect, anti-virus option causing problems
1522 @cindex shell, interacting badly with anti-virus
1524 Some anti-virus software has been reported to cause problems with
1525 shells in the past.  Try turning off options such as ``Scan all
1526 files''.  @xref{Installing Emacs,,What known problems are there with anti-virus software?}.
1528 @c ------------------------------------------------------------
1529 @node Network access
1530 @chapter Network access
1532 @menu
1533 * Mail::
1534 * Attachments with Gnus::
1535 * Using FTP::
1536 * Tramp ssh::
1537 * telnet::
1538 @end menu
1540 @node Mail
1541 @section How do I use mail in Emacs?
1543 Emacs comes with several options for reading and writing mail.  These
1544 are documented in the manual, and the choice of which method to use
1545 depends on personal taste.  There are some issues specific to Windows
1546 however, related to the fact that Windows machines do not have the
1547 mail infrastructure that is commonly installed on other platforms, so
1548 mail will not work without some configuration.
1550 @menu
1551 * Outgoing mail::
1552 * Incoming mail with Rmail::
1553 * Incoming mail with Gnus::
1554 * Incoming mail other::
1555 @end menu
1557 @node Outgoing mail
1558 @subsection Outgoing mail
1559 @cindex mail, outgoing
1560 @cindex smtp server
1561 @vindex user-full-name
1562 @vindex user-mail-address
1563 @vindex smtpmail-default-smtp-server
1564 @vindex smtpmail-smtp-server
1565 @vindex send-mail-command
1566 @vindex message-send-mail-function
1567 @findex smtpmail-send-it
1568 @vindex smtpmail-debug-info
1570 For outgoing mail, you will need to use @file{smtpmail.el} which
1571 allows Emacs to talk directly to SMTP mail servers.  This is included
1572 with Emacs, and can be set up as follows:
1574 @example
1575 (setq user-full-name "@var{Your full name}")
1576 (setq user-mail-address "@var{Your@@email.address}")
1577 (setq smtpmail-default-smtp-server "@var{domain.name.of.your.smtp.server}")
1579 (setq send-mail-command 'smtpmail-send-it) ; For mail-mode (Rmail)
1580 (setq message-send-mail-function 'smtpmail-send-it) ; For message-mode (Gnus)
1581 @end example
1583 Note that if you want to change the name of the SMTP server after
1584 smtpmail is loaded, then you'll need to change
1585 @code{smtpmail-smtp-server}.
1587 If you are experiencing problems with sending large messages, check
1588 the value of the variable @code{smtpmail-debug-info}. If it is
1589 non-@code{nil}, you should set it to @code{nil}:
1591 @node Incoming mail with Rmail
1592 @subsection Incoming mail with Rmail and POP3
1593 @cindex mail, incoming with rmail
1594 @cindex pop3, using rmail
1595 @cindex rmail, mail client
1596 @cindex movemail, using pop3
1597 @cindex MAILHOST
1598 @vindex rmail-primary-inbox-list
1599 @vindex rmail-pop-password-required
1601 For incoming mail using the Rmail package and a POP3 server, you will
1602 need the following configuration:
1604 @example
1605 (setenv "MAILHOST" "@var{domain.name.of.your.pop3.server}")
1606 (setq rmail-primary-inbox-list '("po:@var{your logon id}"))
1607 (setq rmail-pop-password-required t)
1608 @end example
1610 @node Incoming mail with Gnus
1611 @subsection Incoming mail with Gnus
1612 @cindex mail, incoming with Gnus
1613 @cindex pop3, using Gnus
1614 @cindex imap, using Gnus
1615 @cindex gnus, mail and news client
1617 Although Gnus started life as a Usenet news reader, it also makes a
1618 good mail reader, particularly if you subscribe to a lot of mailing
1619 lists, or you want to use IMAP rather than POP3, which is not
1620 supported by Rmail.  @xref{Top,The Gnus manual,,gnus, The Gnus manual}.
1622 @node Incoming mail other
1623 @subsection Other incoming mail options
1624 @cindex mail, other options
1625 @cindex wanderlust, mail and news client
1626 @cindex vm, mail client
1627 @cindex mh-e, mail client
1629 Other options for reading mail in Emacs include VM, MH-E and Wanderlust.
1630 MH-E is included with Emacs.  The others require lisp or executable code
1631 that does not come with Emacs, so you should seek help where you
1632 obtained the packages from if you want to use them.
1634 @node Attachments with Gnus
1635 @section How do I open attachments in Gnus?
1636 @cindex gnus, attachments
1637 @cindex attachments, in gnus
1638 @cindex mail, attachments in gnus
1639 @cindex .mailcap
1640 @cindex MIME, configuration for Gnus
1642 In your @env{HOME} directory create a file called @file{.mailcap},
1643 with contents like the following:
1644 @example
1645 application/zip "C:/Program Files/7-Zip/7zFM.exe"
1646 video/* "C:/Program Files/VideoLAN/VLC/vlc.exe"
1647 @end example
1649 @strong{Warning:} Associating MIME types with @command{start} or other
1650 generic Windows commands to open arbitrary files might seem like a
1651 good idea, but it leaves your system as open to attack as Outlook
1652 Express was at its worst.  Especially dangerous is associating
1653 application/* or */* in this way.
1655 @node Using FTP
1656 @section How do I use FTP within Emacs?
1657 @cindex ftp, using within Emacs
1658 @cindex ange-ftp
1659 @cindex tramp, ftp
1660 @cindex remote hosts via ftp
1661 @vindex ange-ftp-ftp-program-name
1663 Windows built in FTP client can be used with ange-ftp.  Ange-ftp is
1664 the Emacs package that provides FTP connectivity to tramp, a
1665 multi-protocol remote file access package for Emacs that is enabled by
1666 default.
1668 The Windows FTP client does have problems with some firewalls, due to
1669 lack of passive mode support, so you may want to try an alternative
1670 ftp client instead.  Make sure that the client you are trying is in
1671 your @env{PATH} before the default Windows client, or rename the
1672 default Windows client to avoid it getting in the way.  Alternatively
1673 you can customize @code{ange-ftp-ftp-program-name} to the full path to
1674 the version you are trying.  @xref{Other useful ports}.
1676 @node Tramp ssh
1677 @section How do I use Tramp to work in Emacs via SSH?
1678 @cindex tramp, ssh
1679 @cindex ssh, accessing remote hosts within Emacs
1680 @cindex remote hosts via ssh
1681 @cindex openssh
1682 @cindex PuTTY
1683 @cindex plink
1684 @vindex tramp-default-method
1685 @vindex tramp-default-method-alist
1687 Tramp can use a number of protocols to connect to remote machines to
1688 read files and even run commands on those files remotely.  A popular
1689 one is ssh.  As well as Cygwin versions of openssh, you can use
1690 PuTTY's command line plink program as the ssh client.  The relevant
1691 methods to use in @code{tramp-default-method} or
1692 @code{tramp-default-method-alist} for these options are:
1693 @itemize @w{}
1694 @item
1695 openssh
1696 @itemize
1697 @item @code{scp} Uses scp for copying, ssh for shell operations.
1698 @item @code{ssh} Uses ssh with encoding on stdin/stdout for file transfer.
1699 @end itemize
1701 @item
1702 PuTTY
1703 @itemize
1704 @item @code{pscp} Uses pscp for copying, plink for shell operations.
1705 @item @code{plink} Uses plink with encoding on stdin/stdout for file transfer.
1706 @end itemize
1707 @end itemize
1709 @node telnet
1710 @section How do I use telnet with Emacs?
1711 @cindex telnet, in Emacs
1712 @findex telnet
1713 @cindex telnet client, that works with Emacs
1715 To use telnet-mode on Windows, you need a telnet client that uses
1716 stdin and stdout for input and output.  The default Windows client is
1717 a Windows application, and will not work as a subprocess.  Several
1718 options exist, but information that was formerly in this FAQ is out of
1719 date now, so no concrete pointers are available.
1721 @c ------------------------------------------------------------
1722 @node Text and Utility modes
1723 @chapter Text and Utility modes
1725 @menu
1726 * TeX::
1727 * Spell check::
1728 * Encryption::
1729 * Mouse wheel::
1730 * Grep::
1731 @end menu
1733 @node TeX
1734 @section How do I use TeX with Emacs?
1735 @cindex tex
1736 @cindex typesetting
1738 You will need an implementation of TeX for Windows.
1739 A number of implementations are listed on the
1740 @uref{http://www.tug.org/interest.html#free, TeX Users Group} website.
1742 @menu
1743 * AUCTeX::
1744 @end menu
1746 @node AUCTeX
1747 @subsection AUCTeX
1748 @cindex auctex, precompiled for Windows
1749 @cindex latex
1750 @cindex preview-latex
1752 AUCTeX is an Emacs package for writing LaTeX files, which also
1753 includes preview-latex, an Emacs mode for previewing the formatted
1754 contents of LaTeX documents.  Pre-compiled versions for Windows are
1755 available from
1756 @uref{http://www.gnu.org/software/auctex/download-for-windows.html, the
1757 AUCTeX site}.
1759 @node Spell check
1760 @section How do I perform spell checks?
1761 @cindex spell checking
1762 @cindex ispell
1763 @cindex aspell
1764 @cindex flyspell
1765 @vindex ispell-program-name
1766 @findex flyspell-mode
1768 Emacs has support for spell checking on demand (@code{ispell}) and as
1769 your type (@code{flyspell}).  Both packages depend on a copy of
1770 @command{ispell} 3.2 or a compatible spell-checking program.
1771 GNU Aspell is a popular choice these days, Windows installers are
1772 available from the @uref{http://aspell.net/win32/, official site}.
1773 Another possibility is Hunspell, which is available from
1774 @uref{https://sourceforge.net/projects/ezwinports/files/?source=navbar,
1775 the ezwinports site}.
1777 Once installed, you will need to configure @code{ispell-program-name}
1778 to tell ispell and flyspell to use @command{aspell} or
1779 @command{hunspell} as a replacement for ispell.  You can include the
1780 full path to the @file{aspell}/@file{hunspell} binary, which means you
1781 do not need to add its installation directory to the @env{PATH}.
1783 @node Encryption
1784 @section Emacs and encryption
1785 @cindex encryption
1786 @cindex gpg, Windows binaries
1787 @cindex pgp encryption, with GNU Privacy Guard
1788 @cindex signatures on Emacs distribution, checking
1789 @cindex Emacs distribution, checking digital signatures
1791 GNU Privacy Guard is a Free replacement for PGP, with Windows binaries
1792 available.  See @uref{http://www.gnupg.org/}.
1794 @node Mouse wheel
1795 @section Why doesn't my wheel mouse work in Emacs?
1796 @cindex mouse wheel
1797 @cindex wheel mouse
1798 @cindex middle button, on wheel mouse
1799 @cindex scrolling, with mouse wheel
1801 Some wheel mice ship with default settings that do not send the
1802 standard wheel events to programs, but instead try to simulate scroll
1803 bar events.  Usually this is configurable from the hardware specific
1804 pages on the mouse control panel.  The middle button is often mapped
1805 in the same settings to have some functionality other than sending
1806 middle mouse button events.  In some cases, uninstalling the
1807 manufacturer's drivers and telling Windows to use the generic USB or
1808 PS/2 drivers is the only way to make the mouse work properly.
1810 @node Grep
1811 @section How do I use grep with Emacs?
1812 @cindex searching through files with grep
1813 @cindex grep
1814 @cindex findstr
1815 @findex grep
1817 The best way to use @kbd{M-x grep} with Emacs is to download a port of
1818 GNU @command{grep}. @xref{Other useful ports}.
1820 If you want a quick solution without installing extra tools, a poor
1821 substitute that works for simple text searches is to specify the built
1822 in Windows command @command{findstr} as the command to run at the
1823 @kbd{M-x grep} prompt.  Normally you will want to use the @option{/n}
1824 argument to @command{findstr}.
1826 @menu
1827 * Recursive grep::
1828 @end menu
1830 @node Recursive grep
1831 @subsection How do I do a recursive grep?
1832 @cindex recursive searching with grep
1833 @cindex grep, recursive through subdirectories
1834 @cindex findstr, recursive
1835 @cindex find, using with grep
1836 @cindex find, the POSIX command
1837 @findex rgrep
1838 @findex grep-find
1839 @findex find-grep-dired
1840 @vindex find-program
1841 @vindex grep-find-command
1843 The Emacs commands @code{rgrep}, @code{grep-find}
1844 and @code{find-grep-dired} are all different interfaces for
1845 grepping recursively into subdirectories.  By default, they use the
1846 command @command{find} to determine which files to work on, and either
1847 run @command{grep} directly from find, or use @command{xargs} to batch
1848 up files and reduce the number of invocations of @command{grep}.
1850 Windows also comes with a @command{find} command, but it is not in any
1851 way compatible with the POSIX @command{find} that Emacs tries to use.
1852 Emacs expects a @command{find} compatible with GNU findutils.
1853 @xref{Other useful ports}.  After you have installed it, you will need
1854 to make sure that Emacs finds this version, not the standard Windows
1855 @command{find} command.  You can do this by either renaming the
1856 Windows command, changing your @env{PATH} to ensure that the directory
1857 containing the findutils @file{bin} directory comes before the Windows
1858 system directory, or set the variable @code{find-program} to the full
1859 path to the findutils @command{find} command.
1861 An alternative if you have a recent version of grep is to customize
1862 @code{grep-find-command} to use @samp{grep -r} instead of both find
1863 and grep.  Another alternative if you don't need the full capabilities
1864 of grep is to use @samp{findstr /n /r}.
1866 @c ------------------------------------------------------------
1867 @node Developing with Emacs
1868 @chapter Developing with Emacs
1870 We recommend using the GNU Compiler Collection for developing C/C++
1871 code from Emacs.  The MinGW development toolchain provides Windows
1872 ports of GCC and other compilers.
1874 The rest of this chapter describes other alternatives which you may
1875 need to use.
1877 @menu
1878 * MSVC::
1879 * Borland C++ Builder::
1880 * Version control::
1881 * Perldb::
1882 @end menu
1884 @node MSVC
1885 @section How do I use Emacs with Microsoft Visual C++
1887 There are two ways you can use Emacs in conjunction with MSVC.  You
1888 can use Emacs as the editor, and do everything else in the DevStudio
1889 IDE.  Or you can use Emacs as an IDE, calling the MSVC command line
1890 tools to build your project.
1892 @menu
1893 * DevStudio::
1894 * MSVC command line::
1895 @end menu
1897 @node DevStudio
1898 @subsection Emacs as the text editor for DevStudio
1899 @cindex DevStudio, using Emacs as editor in
1900 @cindex MSVC++, using Emacs as editor with
1901 @cindex Visual Studio, using Emacs as editor in
1902 @cindex VisEmacs, add in for MS Developer Studio
1904 Christopher Payne wrote a Visual Studio add-in that makes Emacs the
1905 default text editor, this has now been taken over by Jeff Paquette.
1906 See the following two URLs for details:
1907 @itemize
1908 @item @uref{http://sourceforge.net/projects/visemacs/} for the latest version.
1909 @item @uref{http://www.smathers.net/VisEmacs.htm} for notes on usage.
1910 @end itemize
1912 @node MSVC command line
1913 @subsection Using MSVC command line tools from Emacs
1914 @cindex MSVC++, compiling within Emacs
1915 @findex compile
1917 This is an app note on how to use Microsoft Visual C++ with Emacs. The
1918 experiments done below were done with Emacs 19.34.1 on Windows 95,
1919 using Visual C++ 4.0 Standard Edition. Your mileage may vary.
1921 This writeup assumes minimal knowledge of Emacs hacking on the part of
1922 the reader.
1924 @menu
1925 * VC++ environment::
1926 * Default compile command::
1927 * Reverting buffers::
1928 * Edit MSVC::
1929 @end menu
1931 @node VC++ environment
1932 @subsubsection VC++ Environment Variables
1933 @cindex vcvars32.bat
1934 @cindex MSVC++, environment variables
1936 There is a batch file in your VC++ installation's bin directory called
1937 @file{vcvars32.bat}, which sets up the environment variables needed to
1938 run the VC++ command line tools.  Arrange for those same environment
1939 variables to be set in your Emacs session.  You can do this on Windows
1940 9x by calling the @file{vcvars32.bat} script from @file{autoexec.bat}.
1941 On other versions of Windows you can set the environment variables
1942 globally using the System control panel.
1944 For all versions of Windows you can alternatively set the variables
1945 just inside Emacs by using @code{setenv} calls in your init file.
1946 @xref{Installing Emacs,,Where do I put my init file?}.
1948 You should now be able to compile from Emacs. Load a source file from
1949 a VC++ project. Type @kbd{M-x compile}. Replace the proposed command line
1950 with:
1951 @example
1952 nmake -f @var{ProjectName}.mak
1953 @end example
1955 You will find that this defaults to a debug build. You can change it
1956 to a release build with:
1957 @example
1958 nmake -f @var{ProjectName}.mak CFG="@var{ProjectName} - Win32 Release"
1959 @end example
1961 @node Default compile command
1962 @subsubsection Setting the default compile command
1963 @cindex compile, setting default command
1964 @cindex nmake, as default compile command
1965 @vindex compile-command
1967 Now set the default value for the compile command line.  Add the
1968 following to your init file:
1970 @example
1971 ;; Set up for Visual C++ compiling
1972 (setq compile-command "nmake -f ")
1973 @end example
1975 If you work on the same project long term, you can add the project
1976 makefile to the string.
1978 David Biesack suggests that perhaps it's
1979 easy to write a @file{Makefile} in the project directory which does
1981 @example
1982 PROJECT=MyProject
1983 all: debug
1984 debug: FORCE
1985         nmake /f $(PROJECT).mak CFG="$(PROJECT) - Win32 Debug"
1986 release: FORCE
1987         nmake /f $(PROJECT).mak CFG="$(PROJECT) - Win32 Release"
1988 FORCE:
1989 @end example
1991 and then you can simply change compile-command to @command{nmake}.
1993 Caleb T. Deupree reports that on VC++
1994 5.0 and up, "You can also set an option in Options/Build to export a
1995 makefile every time the project is saved, which you can then use to
1996 compile with @samp{nmake -f project.mak}."  VC++ 4.0 builds the make file
1997 every time, and there is no option.
1999 @node Reverting buffers
2000 @subsubsection Reverting Buffers
2001 @cindex DevStudio, keeping source in sync
2002 @cindex Visual Studio, keeping source in sync
2003 @cindex MSVC++, keeping source in sync
2004 @findex auto-revert-mode
2005 @findex global-auto-revert-mode
2007 It is recommended that you use @code{auto-revert-mode} in buffers
2008 that you have open in both Emacs and MSVC++ at the same time.  Then if
2009 you mistakenly edit the file in MSVC++, Emacs will pick up your
2010 changes immediately, rather than after you have written lots more code
2011 and attempt to save.
2013 @node Edit MSVC
2014 @subsubsection Edit with Emacs function for MSVC
2015 @cindex DevStudio, load in Emacs command
2016 @cindex Visual Studio, load in Emacs command
2017 @cindex MSVC++, load in Emacs command
2018 @cindex emacsclient, calling from Visual Studio
2020 You can also set up VC++ to import a file into Emacs for you, all
2021 ready for editing.  In VC++, go to the @code{Tools} pull-down menu, and
2022 click on @code{Customize...}.  In the @code{Tools} tab, click on
2023 @code{Add}.  Use @code{Browse} to locate the
2024 @file{emacsclientw.exe} file in your Emacs bin directory, and
2025 select it.  For arguments, use @option{+$(CurLine)}
2026 @option{"$(FilePath)"} and for the directory use the @code{$(WkspDir)}
2027 (the quotes around FilePath handle paths with spaces in them). Set the
2028 Menu Text to say "Em&acs". The @option{+$(CurLine)} will set point in
2029 Emacs to the same line as the cursor position in VC++. The ampersand
2030 in the word @code{Em&acs} allows you to select emacs from the keyboard.
2031 (E is already used for the OLE control test container.)
2033 You should now be able to go to any source file in your project. Then,
2034 use the pull-down menu @code{Tools->Emacs}. The active file in your
2035 VC++ IDE should now be front and center in Emacs, all ready to edit as
2036 you wish. If you use keystrokes to work the menus, try @kbd{Alt-T A} to
2037 move the file into Emacs. Binding this tool to a keystroke will be
2038 left as an exercise for the student.
2040 If you have the option of saving files before running tools, make sure
2041 this option is set. (I don't see it on VC++ 4.0.)
2043 @node Borland C++ Builder
2044 @section Emacs and Borland C++ Builder
2045 @cindex Borland C++, integration with Emacs
2047 Jonathan Arnold has written an
2048 @uref{http://www.buddydog.org/C++Builder/c++builder.html, EmacsEdit
2049 ``expert''} for interfacing C++ Builder and Emacs.
2051 @node Version control
2052 @section Is there a version of my VC software I can use with Emacs?
2053 @cindex version control, integration with Emacs
2054 @cindex revision control, integration with Emacs
2055 @cindex source control,  integration with Emacs
2056 @cindex cvs, version control integration with Emacs
2057 @cindex rcs, version control integration with Emacs
2058 @cindex svn, version control integration with Emacs
2059 @cindex git, version control integration with Emacs
2060 @cindex bzr, version control integration with Emacs
2061 @cindex arch, version control integration with Emacs
2062 @cindex mercurial, version control integration with Emacs
2063 @cindex hg, version control integration with Emacs
2064 @cindex monotone, version control integration with Emacs
2065 @cindex mcvs, version control integration with Emacs
2067 If you are using a graphical revision control tool already, check if
2068 it comes with command-line tools.  Many such GUI tools are just
2069 wrappers for the same command line tools that Emacs requires for its
2070 VC integration.  Most of the supported VC systems have well supported
2071 Free native Windows binaries.  For those that don't Cygwin may be an option.
2072 @xref{Other useful ports}.
2074 @node Perldb
2075 @section How do I use the Perl debugger with Emacs?
2076 @cindex perl, debugging within Emacs
2077 @cindex perldb, using with Emacs
2079 From Jay Rogers:
2081 Some versions of the perl debugger itself need to be patched to work
2082 with emacs. They are perl versions 5.001 and less, and version
2083 5.004_01. To fix, locate and change the code similar to the following
2084 code in lib/perl5db.pl
2085 @example
2086         if (-e "/dev/tty") @{
2087             $console = "/dev/tty";
2088             $rcfile=".perldb";
2089         @}
2090         elsif (-e "con") @{
2091             $console = "";                 <---- change "con" to ""
2092             $rcfile="perldb.ini";
2093         @}
2094         else @{
2095             $console = "sys\$command";
2096             $rcfile="perldb.ini";
2097         @}
2098 @end example
2100 Doug Campbell also has some
2101 @uref{http://www.gnu.org/software/emacs/windows/ntemacs/discuss/perldb,
2102 suggestions} for improving the interaction of perldb and Emacs.
2104 @c ------------------------------------------------------------
2105 @node Other useful ports
2106 @chapter Other useful ports
2107 @cindex useful tools
2108 @cindex subprocesses, useful tools
2110 @menu
2111 * Cygwin::
2112 * MinGW::
2113 * EZWinPorts::
2114 * UWIN::
2115 * GnuWin32::
2116 * GTK::
2117 * Read man pages::
2118 @end menu
2120 @node Cygwin
2121 @section Cygwin
2122 @cindex cygwin environment
2123 @cindex cygwin, library conflicts
2124 @cindex library conflicts with cygwin
2125 @cindex interoperability with cygwin
2126 @cindex subprocesses, cygwin tools
2127 @vindex exec-path
2129 @uref{http://www.cygwin.com/}.
2131 Cygwin is a popular complete POSIX emulation environment for Windows.
2132 Most of its tools can be used with Emacs, and it covers a wide range
2133 of ported software.  The main shell used by Cygwin is GNU
2134 @command{bash}, but other shells are also available.  Some Cygwin
2135 tools may not interoperate well with Emacs or other native Windows
2136 tools, due to the total immersion aspect of Cygwin, including its
2137 non-native filesystem mapping.
2139 If you choose to use Cygwin, then its tools will probably be all that
2140 you need, but you will need to get image libraries from elsewhere, as
2141 the Cygwin ones are not compatible with non-Cygwin software.  In fact,
2142 if Cygwin is on your PATH when you run Emacs, and Emacs does not find
2143 other versions of the image libraries first, then the Cygwin ones can
2144 cause problems.  Cygwin developers recommend that you do not put
2145 Cygwin on your system @env{PATH} for this reason.  Instead you can
2146 make the Cygwin tools available within Emacs by setting @code{exec-path}
2147 in your init file.
2149 @node MinGW
2150 @section MinGW and MSYS
2151 @cindex mingw tools
2152 @cindex msys environment
2153 @cindex subprocesses, mingw and msys
2155 @uref{http://www.mingw.org/}
2157 MinGW is a set of development tools that produce native Windows
2158 executables, not dependent on Cygwin's POSIX emulation DLLs.
2160 MSYS is a POSIX shell and minimal set of tools that are commonly used in
2161 configure scripts.  Like Cygwin, this environment uses a non-native
2162 filesystem mapping to appear more POSIX like to the scripts that it
2163 runs.  This is intended to complement the MinGW tools to make it easier
2164 to port software to Windows.
2166 @node EZWinPorts
2167 @section EZWinPorts
2168 @cindex ezwinports
2170 The @uref{https://sourceforge.net/projects/ezwinports/, EZWinPorts
2171 project} provides many useful ports of recent versions of GNU and Unix
2172 software.  This includes all the optional libraries used by Emacs
2173 (image libraries, libxml2, GnuTLS), RCS, Texinfo, a clone of
2174 @command{man} command, Grep, xz, bzip2, bsdtar, ID Utils, Findutils,
2175 Hunspell, Gawk, GNU Make, Groff, GDB.
2177 @node UWIN
2178 @section UWIN
2179 @cindex uwin environment
2180 @cindex subprocesses, uwin
2182 @uref{http://www.research.att.com/sw/tools/uwin/}
2184 UWIN is another POSIX emulation environment, like Cygwin and MSYS,
2185 that provides a large number of ported tools.  The shell used by UWIN
2186 is @command{ksh}, the Korn shell.
2188 @node GnuWin32
2189 @section GnuWin32
2190 @cindex gnuwin32 tools
2191 @cindex subprocesses, gnuwin32
2192 @cindex image libraries, gnuwin32
2193 @cindex image libraries, development
2195 @uref{http://gnuwin32.sourceforge.net/}
2197 GnuWin32 provides precompiled native Windows ports of a wide selection
2198 of Free software and libraries.  Unfortunately, the ports are
2199 outdated.  Tools available here that are useful for Emacs include:
2201 @itemize
2202 @item Arc - used by @code{archive-mode} to edit .arc files.
2203 @item Bzip2 - used by Emacs to automatically decompress .bz2 files.
2204 @item CompFace - used by @code{gnus} to display XFace headers in messages.
2205 @item CoreUtils - GNU file, shell and text utilities (also in MSYS)
2206 @item DiffUtils - for @code{ediff} and producing patches
2207 @item FindUtils - for @code{grep-find} and other file searches.
2208 @item GifLib - library to support GIF images.
2209 @item Grep - for searching through files with @code{grep}.
2210 @item Gzip - used by Emacs to automatically decompress .gz files.
2211 @item Jpeg - library to support JPEG images (also in GTK).
2212 @item Lha - used by @code{archive-mode} to edit .lzh files.
2213 @item LibPng - library to support PNG images (also in GTK).
2214 @item LibTiff - library to support TIFF images (also in GTK).
2215 @item Make - used by @code{compile} for building projects (also in MinGW)
2216 @item OpenSSL - used by @code{gnus} to talk to servers over SSL.
2217 @item Patch - used by @code{ediff-patch-file} and others to apply patches.
2218 @item Tar - used by @code{tar-mode} to edit tar files.
2219 @item TexInfo - used to build Emacs' manuals.
2220 @item Unzip - used by @code{archive-mode} for extracting zip files.
2221 @item Xpm - library to support XPM images (bundled with Emacs binaries)
2222 @item Zip - used by @code{archive-mode} for editing zip files.
2223 @item Zlib - required by LibPng (also in GTK).
2224 @end itemize
2226 @node GTK
2227 @section GTK
2228 @cindex GTK image libraries
2229 @cindex image libraries, GTK
2230 @cindex addpm, using GTK image libraries
2232 GTK is a potential source for some of the image libraries that Emacs
2233 requires.  GTK is installed along with other ports of GUI software,
2234 such as the GIMP image editor, and Pidgin instant messenger client.
2235 If GTK is installed when you run @command{addpm}, Emacs will use the
2236 image libraries that it provides, even if they are not on the
2237 @env{PATH}.  GTK ships with JPEG, PNG and TIFF support.
2239 @node Read man pages
2240 @section How do I read man pages?
2241 @cindex man pages
2242 @findex woman
2243 @findex man
2245 Man pages for Emacs and other ported programs that you have can be
2246 read using Emacs' built-in manual reader @code{woman}.  This
2247 requires no external programs, but if you do have a port of
2248 @command{man}, there is also an Emacs wrapper @code{man} that
2249 which may be slightly faster.  A Windows version of @command{man} is
2250 available from the EZWinPorts site (@pxref{EZWinPorts}).
2252 @c ------------------------------------------------------------
2253 @node Further information
2254 @chapter Further information
2256 @menu
2257 * More information::
2258 * Mailing lists::
2259 @end menu
2261 @node More information
2262 @section Where can I get more information about Emacs?
2263 @cindex other sources of information
2264 @cindex faqs, general
2265 @cindex faqs, old
2266 @cindex help, manuals and other sources
2267 @cindex manuals
2268 @cindex wiki
2270 If you have general questions about Emacs, the best places to start
2271 looking are @ref{Top,,, emacs, The GNU Emacs Manual}, and
2272 @ref{Top,,, efaq, the standard Emacs FAQ}.
2273 In Emacs, you can browse the manual using Info by typing @kbd{C-h r},
2274 and you can view the FAQ by typing @kbd{C-h C-f}. Other resources include:
2276 @itemize
2277 @item @uref{http://www.gnu.org/software/emacs/, The Emacs homepage}
2278 @item @uref{http://www.gnu.org/software/emacs/manual/, Other Emacs manuals}
2279 @item @uref{http://www.emacswiki.org/, Emacs Wiki}
2280 @end itemize
2282 @node Mailing lists
2283 @section What mailing lists are there for discussing Emacs on Windows?
2284 @cindex mailing lists
2285 @cindex help, mailing lists
2287 The official mailing list for Windows specific help and discussion is
2288 @url{http://lists.gnu.org/mailman/listinfo/help-emacs-windows,
2289 help-emacs-windows}.  See that link for information on how to subscribe
2290 or unsubscribe.  The
2291 @uref{http://lists.gnu.org/archive/html/help-emacs-windows/, list archives}
2292 are available online.
2294 @c ------------------------------------------------------------
2295 @node Indexes
2296 @unnumbered Indexes
2298 @unnumberedsec Function and Variable Index
2300 @printindex fn
2302 @unnumberedsec Concept Index
2304 @printindex cp
2306 @bye