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