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