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