Add 2007 to copyright years.
[bpt/emacs.git] / man / msdog.texi
CommitLineData
ca2565b0 1@c This is part of the Emacs manual.
b65d8176 2@c Copyright (C) 1985, 1986, 1987, 1993, 1994, 1995, 1997, 2000, 2001,
4e6835db 3@c 2002, 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
ca2565b0 4@c See file emacs.texi for copying conditions.
53c1041b 5@node Microsoft Windows, Manifesto, Mac OS, Top
5798efc8 6@appendix Emacs and Microsoft Windows/MS-DOS
c6b30bd2 7@cindex Microsoft Windows
270c6692 8@cindex MS-Windows, Emacs peculiarities
ca2565b0 9
e691d082 10 This section describes peculiarities of using Emacs on Microsoft
270c6692
EZ
11Windows. Some of these peculiarities are also relevant to Microsoft's
12older MS-DOS ``operating system'' (also known as ``MS-DOG'').
13However, Emacs features that are relevant @emph{only} to MS-DOS are
5798efc8
EZ
14described in a separate
15@iftex
9dc999d3 16manual (@pxref{MS-DOS,,, emacs-xtra, Specialized Emacs Features}).
5798efc8
EZ
17@end iftex
18@ifnottex
19section (@pxref{MS-DOS}).
20@end ifnottex
21
ca2565b0 22
270c6692
EZ
23 The behavior of Emacs on MS-Windows is reasonably similar to what is
24documented in the rest of the manual, including support for long file
25names, multiple frames, scroll bars, mouse menus, and subprocesses.
26However, a few special considerations apply, and they are described
27here.
ca2565b0
AI
28
29@menu
5798efc8
EZ
30* Text and Binary:: Text files use CRLF to terminate lines.
31* Windows Files:: File-name conventions on Windows.
9974630f 32* ls in Lisp:: Emulation of @code{ls} for Dired.
5798efc8 33* Windows HOME:: Where Emacs looks for your @file{.emacs}.
5a3e3201 34* Windows Keyboard:: Windows-specific keyboard features.
37a75312 35* Windows Mouse:: Windows-specific mouse features.
5798efc8
EZ
36* Windows Processes:: Running subprocesses on Windows.
37* Windows Printing:: How to specify the printer on MS-Windows.
37a75312 38* Windows Misc:: Miscellaneous Windows features.
5798efc8
EZ
39@ifnottex
40* MS-DOS:: Using Emacs on MS-DOS (otherwise known as @dfn{MS-DOG}).
41@end ifnottex
ca2565b0
AI
42@end menu
43
ca2565b0
AI
44@node Text and Binary
45@section Text Files and Binary Files
46@cindex text and binary files on MS-DOS/MS-Windows
47
48 GNU Emacs uses newline characters to separate text lines. This is the
270c6692 49convention used on GNU, Unix, and other Posix-compliant systems.
ca2565b0
AI
50
51@cindex end-of-line conversion on MS-DOS/MS-Windows
270c6692
EZ
52 By contrast, MS-DOS and MS-Windows normally use carriage-return linefeed,
53a two-character sequence, to separate text lines. (Linefeed is the same
ca2565b0
AI
54character as newline.) Therefore, convenient editing of typical files
55with Emacs requires conversion of these end-of-line (EOL) sequences.
56And that is what Emacs normally does: it converts carriage-return
57linefeed into newline when reading files, and converts newline into
58carriage-return linefeed when writing files. The same mechanism that
59handles conversion of international character codes does this conversion
60also (@pxref{Coding Systems}).
61
1ca54e68
EZ
62@cindex cursor location, on MS-DOS
63@cindex point location, on MS-DOS
ca2565b0
AI
64 One consequence of this special format-conversion of most files is
65that character positions as reported by Emacs (@pxref{Position Info}) do
66not agree with the file size information known to the operating system.
67
ca2565b0
AI
68 In addition, if Emacs recognizes from a file's contents that it uses
69newline rather than carriage-return linefeed as its line separator, it
8e375db2
RS
70does not perform EOL conversion when reading or writing that file.
71Thus, you can read and edit files from GNU and Unix systems on MS-DOS
72with no special effort, and they will retain their Unix-style
73end-of-line convention after you edit them.
ca2565b0 74
ca2565b0 75 The mode line indicates whether end-of-line translation was used for
1ca54e68 76the current buffer. If MS-DOS end-of-line translation is in use for the
270c6692
EZ
77buffer, the MS-Windows build of Emacs displays a backslash @samp{\} after
78the coding system mnemonic near the beginning of the mode line
79(@pxref{Mode Line}). If no EOL translation was performed, the string
80@samp{(Unix)} is displayed instead of the backslash, to alert you that the
81file's EOL format is not the usual carriage-return linefeed.
1ca54e68
EZ
82
83@cindex DOS-to-Unix conversion of files
8e375db2 84 To visit a file and specify whether it uses DOS-style or Unix-style
fef4d6a6 85end-of-line, specify a coding system (@pxref{Text Coding}). For
8e375db2
RS
86example, @kbd{C-x @key{RET} c unix @key{RET} C-x C-f foobar.txt}
87visits the file @file{foobar.txt} without converting the EOLs; if some
88line ends with a carriage-return linefeed pair, Emacs will display
89@samp{^M} at the end of that line. Similarly, you can direct Emacs to
90save a buffer in a specified EOL format with the @kbd{C-x @key{RET} f}
91command. For example, to save a buffer with Unix EOL format, type
92@kbd{C-x @key{RET} f unix @key{RET} C-x C-s}. If you visit a file
93with DOS EOL conversion, then save it with Unix EOL format, that
94effectively converts the file to Unix EOL style, like @code{dos2unix}.
ca2565b0
AI
95
96@cindex untranslated file system
97@findex add-untranslated-filesystem
270c6692
EZ
98 When you use NFS, Samba, or some other similar method to access file
99systems that reside on computers using GNU or Unix systems, Emacs
100should not perform end-of-line translation on any files in these file
101systems---not even when you create a new file. To request this,
102designate these file systems as @dfn{untranslated} file systems by
103calling the function @code{add-untranslated-filesystem}. It takes one
104argument: the file system name, including a drive letter and
105optionally a directory. For example,
ca2565b0
AI
106
107@example
108(add-untranslated-filesystem "Z:")
109@end example
110
111@noindent
112designates drive Z as an untranslated file system, and
113
114@example
115(add-untranslated-filesystem "Z:\\foo")
116@end example
117
118@noindent
119designates directory @file{\foo} on drive Z as an untranslated file
120system.
121
122 Most often you would use @code{add-untranslated-filesystem} in your
270c6692 123@file{.emacs} file, or in @file{site-start.el} so that all the users at
ca2565b0
AI
124your site get the benefit of it.
125
126@findex remove-untranslated-filesystem
127 To countermand the effect of @code{add-untranslated-filesystem}, use
128the function @code{remove-untranslated-filesystem}. This function takes
129one argument, which should be a string just like the one that was used
130previously with @code{add-untranslated-filesystem}.
131
8e375db2
RS
132 Designating a file system as untranslated does not affect character
133set conversion, only end-of-line conversion. Essentially, it directs
134Emacs to create new files with the Unix-style convention of using
135newline at the end of a line. @xref{Coding Systems}.
1ca54e68
EZ
136
137@vindex file-name-buffer-file-type-alist
138@cindex binary files, on MS-DOS/MS-Windows
139 Some kinds of files should not be converted at all, because their
270c6692 140contents are not really text. Therefore, Emacs on MS-Windows distinguishes
1ca54e68 141certain files as @dfn{binary files}. (This distinction is not part of
270c6692 142MS-Windows; it is made by Emacs only.) Binary files include executable
1ca54e68
EZ
143programs, compressed archives, etc. Emacs uses the file name to decide
144whether to treat a file as binary: the variable
145@code{file-name-buffer-file-type-alist} defines the file-name patterns
146that indicate binary files. If a file name matches one of the patterns
147for binary files (those whose associations are of the type
148@code{(@var{pattern} . t)}, Emacs reads and writes that file using the
149@code{no-conversion} coding system (@pxref{Coding Systems}) which turns
150off @emph{all} coding-system conversions, not only the EOL conversion.
151@code{file-name-buffer-file-type-alist} also includes file-name patterns
270c6692 152for files which are known to be Windows-style text files with
1ca54e68 153carriage-return linefeed EOL format, such as @file{CONFIG.SYS}; Emacs
270c6692 154always writes those files with Windows-style EOLs.
1ca54e68
EZ
155
156 If a file which belongs to an untranslated file system matches one of
157the file-name patterns in @code{file-name-buffer-file-type-alist}, the
158EOL conversion is determined by @code{file-name-buffer-file-type-alist}.
159
270c6692
EZ
160@node Windows Files
161@section File Names on MS-Windows
162@cindex file names on MS-Windows
163
164 MS-Windows and MS-DOS normally use a backslash, @samp{\}, to
165separate name units within a file name, instead of the slash used on
166other systems. Emacs on MS-DOS/MS-Windows permits use of either slash or
167backslash, and also knows about drive letters in file names.
168
169@cindex file-name completion, on MS-Windows
170 On MS-DOS/MS-Windows, file names are case-insensitive, so Emacs by
171default ignores letter-case in file names during completion.
172
37a75312
EZ
173@vindex w32-get-true-file-attributes
174 If the variable @code{w32-get-true-file-attributes} is
175non-@code{nil} (the default), Emacs tries to determine the accurate
75099884
EZ
176link counts for files. This option is only useful on NTFS volumes,
177and it considerably slows down Dired and other features, so use it
178only on fast machines.
37a75312 179
9974630f
EZ
180@node ls in Lisp
181@section Emulation of @code{ls} on MS-Windows
182@cindex Dired, and MS-Windows/MS-DOS
183@cindex @code{ls} emulation
184
185 Dired normally uses the external program @code{ls} (or its close
186work-alike) to produce the directory listing displayed in Dired
187buffers (@pxref{Dired}). However, MS-Windows and MS-DOS systems don't
188come with such a program, although several ports of @sc{gnu} @code{ls}
189are available. Therefore, Emacs on those systems @emph{emulates}
190@code{ls} in Lisp, by using the @file{ls-lisp.el} package. While
191@file{ls-lisp.el} provides a reasonably full emulation of @code{ls},
7d0a2d30
EZ
192there are some options and features peculiar to that emulation;
193@iftex
194for more details, see the documentation of the variables whose names
195begin with @code{ls-lisp}.
196@end iftex
197@ifnottex
198they are described in this section.
9974630f
EZ
199
200 The @code{ls} emulation supports many of the @code{ls} switches, but
201it doesn't support all of them. Here's the list of the switches it
202does support: @option{-A}, @option{-a}, @option{-B}, @option{-C},
203@option{-c}, @option{-i}, @option{-G}, @option{-g}, @option{-R},
204@option{-r}, @option{-S}, @option{-s}, @option{-t}, @option{-U},
205@option{-u}, and @option{-X}. The @option{-F} switch is partially
206supported (it appends the character that classifies the file, but does
207not prevent symlink following).
208
209@vindex ls-lisp-use-insert-directory-program
210 On MS-Windows and MS-DOS, @file{ls-lisp.el} is preloaded when Emacs
211is built, so the Lisp emulation of @code{ls} is always used on those
212platforms. If you have a ported @code{ls}, setting
213@code{ls-lisp-use-insert-directory-program} to a non-@code{nil} value
214will revert to using an external program named by the variable
215@code{insert-directory-program}.
216
217@vindex ls-lisp-ignore-case
218 By default, @file{ls-lisp.el} uses a case-sensitive sort order for
219the directory listing it produces; this is so the listing looks the
220same as on other platforms. If you wish that the files be sorted in
221case-insensitive order, set the variable @code{ls-lisp-ignore-case} to
222a non-@code{nil} value.
223
224@vindex ls-lisp-dirs-first
225 By default, files and subdirectories are sorted together, to emulate
226the behavior of @code{ls}. However, native MS-Windows/MS-DOS file
227managers list the directories before the files; if you want that
228behavior, customize the option @code{ls-lisp-dirs-first} to a
229non-@code{nil} value.
230
231@vindex ls-lisp-verbosity
232 The variable @code{ls-lisp-verbosity} controls the file attributes
233that @file{ls-lisp.el} displays. The value should be a list that
234contains one or more of the symbols @code{links}, @code{uid}, and
235@code{gid}. @code{links} means display the count of different file
236names that are associated with (a.k.a.@: @dfn{links to}) the file's
75099884
EZ
237data; this is only useful on NTFS volumes. @code{uid} means display
238the numerical identifier of the user who owns the file. @code{gid}
239means display the numerical identifier of the file owner's group. The
240default value is @code{(links uid gid)} i.e.@: all the 3 optional
241attributes are displayed.
9974630f
EZ
242
243@vindex ls-lisp-emulation
244 The variable @code{ls-lisp-emulation} controls the flavour of the
245@code{ls} emulation by setting the defaults for the 3 options
246described above: @code{ls-lisp-ignore-case},
247@code{ls-lisp-dirs-first}, and @code{ls-lisp-verbosity}. The value of
248this option can be one of the following symbols:
249
250@table @code
251@item GNU
252@itemx nil
253Emulate @sc{gnu} systems; this is the default. This sets
254@code{ls-lisp-ignore-case} and @code{ls-lisp-dirs-first} to
255@code{nil}, and @code{ls-lisp-verbosity} to @code{(links uid gid)}.
256@item UNIX
257Emulate Unix systems. Like @code{GNU}, but sets
258@code{ls-lisp-verbosity} to @code{(links uid)}.
259@item MacOS
260Emulate MacOS. Sets @code{ls-lisp-ignore-case} to @code{t}, and
261@code{ls-lisp-dirs-first} and @code{ls-lisp-verbosity} to @code{nil}.
262@item MS-Windows
263Emulate MS-Windows. Sets @code{ls-lisp-ignore-case} and
264@code{ls-lisp-dirs-first} to @code{t}, and @code{ls-lisp-verbosity} to
265@code{(links)} on Windows NT/2K/XP/2K3 and to @code{nil} on Windows 9X.
266Note that the default emulation is @emph{not} @code{MS-Windows}, even
267on Windows, since many users of Emacs on those platforms prefer the
268@sc{gnu} defaults.
269@end table
270
271@noindent
272Any other value of @code{ls-lisp-emulation} means the same as
273@code{GNU}. Note that this option needs to be set @emph{before}
274@file{ls-lisp.el} is loaded, which means that on MS-Windows and MS-DOS
275you will have to set the value from your @file{.emacs} file and then
276restart Emacs, since @file{ls-lisp.el} is preloaded.
277
278@vindex ls-lisp-support-shell-wildcards
279 The variable @code{ls-lisp-support-shell-wildcards} controls how
280file-name patterns are supported: if it is non-@code{nil} (the
281default), they are treated as shell-style wildcards; otherwise they
282are treated as Emacs regular expressions.
7d0a2d30 283@end ifnottex
9974630f 284
270c6692
EZ
285@node Windows HOME
286@section HOME Directory on MS-Windows
287@cindex @code{HOME} directory on MS-Windows
288
444246ca 289 The Windows equivalent of the @code{HOME} directory is the
270c6692
EZ
290@dfn{user-specific application data directory}. The actual location
291depends on your Windows version and system configuration; typical values
292are @file{C:\Documents and Settings\@var{username}\Application Data} on
293Windows 2K/XP and later, and either @file{C:\WINDOWS\Application Data}
294or @file{C:\WINDOWS\Profiles\@var{username}\Application Data} on the
295older Windows 9X/ME systems.
296
297@cindex init file @file{.emacs} on MS-Windows
298 The home directory is where your init file @file{.emacs} is stored.
299When Emacs starts, it first checks whether the environment variable
300@env{HOME} is set. If it is, it looks for the init file in the
301directory pointed by @env{HOME}. If @env{HOME} is not defined, Emacs
302checks for an existing @file{.emacs} file in @file{C:\}, the root
303directory of drive @file{C:}@footnote{
304The check in @file{C:\} is in preference to the application data
305directory for compatibility with older versions of Emacs, which didn't
306check the application data directory.
307}. If there's no such file in @file{C:\}, Emacs next uses the Windows
308system calls to find out the exact location of your application data
309directory. If that fails as well, Emacs falls back to @file{C:\}.
310
311 Whatever the final place is, Emacs sets the value of the @env{HOME}
312environment variable to point to it, and it will use that location for
313other files and directories it normally creates in the user's home
314directory.
315
316 You can always find out where Emacs thinks is your home directory's
317location by typing @kbd{C-x d ~/ @key{RET}}. This should present the
318list of files in the home directory, and show its full name on the
319first line. Likewise, to visit your init file, type @kbd{C-x C-f
320~/.emacs @key{RET}}.
321
322@cindex @file{_emacs} init file, MS-Windows
323 Because MS-DOS does not allow file names with leading dots, and
324because older Windows systems made it hard to create files with such
325names, the Windows port of Emacs supports an alternative name
326@file{_emacs} as a fallback, if such a file exists in the home
327directory, whereas @file{.emacs} does not.
328
5a3e3201
EZ
329@node Windows Keyboard
330@section Keyboard Usage on MS-Windows
331@cindex keyboard, MS-Windows
332
333 This section describes the Windows-specific features related to
334keyboard input in Emacs.
335
e7379492 336@cindex MS-Windows keyboard shortcuts
668ef058
RS
337 Many key combinations (known as ``keyboard shortcuts'') that have
338conventional uses in MS-Windows programs conflict with traditional
51524f43
RS
339Emacs key bindings. (These Emacs key bindings were established years
340before Microsoft was founded.) Examples of conflicts include
341@kbd{C-c}, @kbd{C-x}, @kbd{C-z}, @kbd{C-a}, and @kbd{W-@key{SPC}}.
342You can redefine some of them with meanings more like the MS-Windows
343meanings by enabling CUA Mode (@pxref{CUA Bindings}).
e7379492 344
5a3e3201
EZ
345@kindex F10 @r{(MS-Windows)}
346@cindex menu bar access using keyboard @r{(MS-Windows)}
347 The @key{F10} key on Windows activates the menu bar in a way that
348makes it possible to use the menus without a mouse. In this mode, the
349arrow keys traverse the menus, @key{RET} selects a highlighted menu
350item, and @key{ESC} closes the menu.
351
a210f8e6
EZ
352@iftex
353@inforef{Windows Keyboard, , emacs}, for information about additional
354Windows-specific variables in this category.
355@end iftex
7d0a2d30 356@ifnottex
5a3e3201
EZ
357@vindex w32-alt-is-meta
358@cindex @code{Alt} key (MS-Windows)
359 By default, the key labeled @key{Alt} is mapped as the @key{META}
360key. If you wish it to produce the @code{Alt} modifier instead, set
361the variable @code{w32-alt-is-meta} to a @code{nil} value.
362
5a3e3201
EZ
363@vindex w32-capslock-is-shiftlock
364 By default, the @key{CapsLock} key only affects normal character
365keys (it converts lower-case characters to their upper-case
366variants). However, if you set the variable
367@code{w32-capslock-is-shiftlock} to a non-@code{nil} value, the
368@key{CapsLock} key will affect non-character keys as well, as if you
369pressed the @key{Shift} key while typing the non-character key.
370
371@vindex w32-enable-caps-lock
372 If the variable @code{w32-enable-caps-lock} is set to a @code{nil}
373value, the @key{CapsLock} key produces the symbol @code{capslock}
374instead of the shifted version of they keys. The default value is
375@code{t}.
376
377@vindex w32-enable-num-lock
378@cindex keypad keys (MS-Windows)
379 Similarly, if @code{w32-enable-num-lock} is @code{nil}, the
380@key{NumLock} key will produce the symbol @code{kp-numlock}. The
381default is @code{t}, which causes @key{NumLock} to work as expected:
382toggle the meaning of the keys on the numeric keypad.
7d0a2d30 383@end ifnottex
5a3e3201 384
3a9d9327
EZ
385@vindex w32-apps-modifier
386 The variable @code{w32-apps-modifier} controls the effect of the
387@key{Apps} key (usually located between the right @key{Alt} and the
388right @key{Ctrl} keys). Its value can be one of the symbols
389@code{hyper}, @code{super}, @code{meta}, @code{alt}, @code{control},
390or @code{shift} for the respective modifier, or @code{nil} to appear
391as the key @code{apps}. The default is @code{nil}.
392
5a3e3201
EZ
393@vindex w32-lwindow-modifier
394@vindex w32-rwindow-modifier
395@vindex w32-scroll-lock-modifier
396 The variable @code{w32-lwindow-modifier} determines the effect of
397the left Windows key (usually labeled with @key{start} and the Windows
398logo). If its value is @code{nil} (the default), the key will produce
399the symbol @code{lwindow}. Setting it to one of the symbols
400@code{hyper}, @code{super}, @code{meta}, @code{alt}, @code{control},
401or @code{shift} will produce the respective modifier. A similar
402variable @code{w32-rwindow-modifier} controls the effect of the right
403Windows key, and @code{w32-scroll-lock-modifier} does the same for the
404@key{ScrLock} key. If these variables are set to @code{nil}, the
405right Windows key produces the symbol @code{rwindow} and @key{ScrLock}
406produces the symbol @code{scroll}.
407
408@vindex w32-pass-alt-to-system
37a75312
EZ
409@cindex Windows system menu
410@cindex @code{Alt} key invokes menu (Windows)
411 Emacs compiled as a native Windows application normally turns off
412the Windows feature that tapping the @key{ALT} key invokes the Windows
413menu. The reason is that the @key{ALT} serves as @key{META} in Emacs.
414When using Emacs, users often press the @key{META} key temporarily and
415then change their minds; if this has the effect of bringing up the
416Windows menu, it alters the meaning of subsequent commands. Many
417users find this frustrating.
418
419 You can re-enable Windows' default handling of tapping the @key{ALT}
420key by setting @code{w32-pass-alt-to-system} to a non-@code{nil}
421value.
422
7d0a2d30 423@ifnottex
5a3e3201
EZ
424@vindex w32-pass-lwindow-to-system
425@vindex w32-pass-rwindow-to-system
37a75312 426 The variables @code{w32-pass-lwindow-to-system} and
5a3e3201
EZ
427@code{w32-pass-rwindow-to-system} determine whether the respective
428keys are passed to Windows or swallowed by Emacs. If the value is
429@code{nil}, the respective key is silently swallowed by Emacs,
37a75312
EZ
430otherwise it is passed to Windows. The default is @code{t} for both
431of these variables. Passing each of these keys to Windows produces
432its normal effect: for example, @kbd{@key{Lwindow}} opens the
a26d12e3
EZ
433@code{Start} menu, etc.@footnote{
434Some combinations of the ``Windows'' keys with other keys are caught
435by Windows at low level in a way that Emacs currently cannot prevent.
436For example, @kbd{@key{Lwindow} r} always pops up the Windows
437@samp{Run} dialog. Customizing the value of
438@code{w32-phantom-key-code} might help in some cases, though.}
5a3e3201
EZ
439
440@vindex w32-recognize-altgr
441@kindex AltGr @r{(MS-Windows)}
442@cindex AltGr key (MS-Windows)
6041f4e1 443 The variable @code{w32-recognize-altgr} controls whether the
1521f22e
EZ
444@key{AltGr} key (if it exists on your keyboard), or its equivalent,
445the combination of the right @key{Alt} and left @key{Ctrl} keys
446pressed together, is recognized as the @key{AltGr} key. The default
447is @code{t}, which means these keys produce @code{AltGr}; setting it
448to @code{nil} causes @key{AltGr} or the equivalent key combination to
449be interpreted as the combination of @key{CTRL} and @key{META}
450modifiers.
7d0a2d30 451@end ifnottex
5a3e3201 452
37a75312
EZ
453@node Windows Mouse
454@section Mouse Usage on MS-Windows
455@cindex mouse, and MS-Windows
456
457 This section describes the Windows-specific variables related to
458mouse.
459
460@vindex w32-mouse-button-tolerance
461@cindex simulation of middle mouse button
462 The variable @code{w32-mouse-button-tolerance} specifies the
463time interval, in milliseconds, for faking middle mouse button press
464on 2-button mice. If both mouse buttons are depressed within this
465time interval, Emacs generates a middle mouse button click event
466instead of a double click on one of the buttons.
467
468@vindex w32-pass-extra-mouse-buttons-to-system
469 If the variable @code{w32-pass-extra-mouse-buttons-to-system} is
470non-@code{nil}, Emacs passes the fourth and fifth mouse buttons to
471Windows.
472
473@vindex w32-swap-mouse-buttons
474 The variable @code{w32-swap-mouse-buttons} controls which of the 3
475mouse buttons generates the @kbd{mouse-2} events. When it is
476@code{nil} (the default), the middle button generates @kbd{mouse-2}
477and the right button generates @kbd{mouse-3} events. If this variable
478is non-@code{nil}, the roles of these two buttons are reversed.
5a3e3201 479
ca2565b0 480@node Windows Processes
270c6692
EZ
481@section Subprocesses on Windows 9X/ME and Windows NT/2K/XP
482@cindex subprocesses on MS-Windows
ca2565b0 483
270c6692 484@cindex DOS applications, running from Emacs
049224f6 485 Emacs compiled as a native Windows application (as opposed to the DOS
ca2565b0
AI
486version) includes full support for asynchronous subprocesses.
487In the Windows version, synchronous and asynchronous subprocesses work
488fine on both
270c6692 489Windows 9X/ME and Windows NT/2K/XP as long as you run only 32-bit Windows
ca2565b0
AI
490applications. However, when you run a DOS application in a subprocess,
491you may encounter problems or be unable to run the application at all;
492and if you run two DOS applications at the same time in two
493subprocesses, you may have to reboot your system.
494
495Since the standard command interpreter (and most command line utilities)
270c6692 496on Windows 9X are DOS applications, these problems are significant when
ca2565b0
AI
497using that system. But there's nothing we can do about them; only
498Microsoft can fix them.
499
500If you run just one DOS application subprocess, the subprocess should
501work as expected as long as it is ``well-behaved'' and does not perform
502direct screen access or other unusual actions. If you have a CPU
503monitor application, your machine will appear to be 100% busy even when
504the DOS application is idle, but this is only an artifact of the way CPU
505monitors measure processor load.
506
507You must terminate the DOS application before you start any other DOS
508application in a different subprocess. Emacs is unable to interrupt or
509terminate a DOS subprocess. The only way you can terminate such a
510subprocess is by giving it a command that tells its program to exit.
511
512If you attempt to run two DOS applications at the same time in separate
513subprocesses, the second one that is started will be suspended until the
514first one finishes, even if either or both of them are asynchronous.
515
270c6692 516@cindex kill DOS application
ca2565b0
AI
517If you can go to the first subprocess, and tell it to exit, the second
518subprocess should continue normally. However, if the second subprocess
519is synchronous, Emacs itself will be hung until the first subprocess
520finishes. If it will not finish without user input, then you have no
ff43a665 521choice but to reboot if you are running on Windows 9X. If you are
270c6692
EZ
522running on Windows NT/2K/XP, you can use a process viewer application to kill
523the appropriate instance of NTVDM instead (this will terminate both DOS
ca2565b0
AI
524subprocesses).
525
ff43a665 526If you have to reboot Windows 9X in this situation, do not use the
ca2565b0
AI
527@code{Shutdown} command on the @code{Start} menu; that usually hangs the
528system. Instead, type @kbd{CTL-ALT-@key{DEL}} and then choose
529@code{Shutdown}. That usually works, although it may take a few minutes
530to do its job.
531
37a75312 532@vindex w32-quote-process-args
a210f8e6
EZ
533 The variable @code{w32-quote-process-args} controls how Emacs quotes
534the process arguments. Non-@code{nil} means quote with the @code{"}
535character. If the value is a character, use that character to escape
536any quote characters that appear; otherwise chose a suitable escape
537character based on the type of the program.
37a75312 538
ccff391f
EZ
539@ifnottex
540@findex w32-shell-execute
541 The function @code{w32-shell-execute} can be useful for writing
542customized commands that run MS-Windows applications registered to
543handle a certain standard Windows operation for a specific type of
544document or file. This function is a wrapper around the Windows
545@code{ShellExecute} API. See the MS-Windows API documentation for
546more details.
547@end ifnottex
548
270c6692
EZ
549@node Windows Printing
550@section Printing and MS-Windows
551
552 Printing commands, such as @code{lpr-buffer} (@pxref{Printing}) and
553@code{ps-print-buffer} (@pxref{PostScript}) work in MS-DOS and
554MS-Windows by sending the output to one of the printer ports, if a
555Posix-style @code{lpr} program is unavailable. The same Emacs
556variables control printing on all systems, but in some cases they have
557different default values on MS-DOS and MS-Windows.
558
559 Emacs on Windows automatically determines your default printer and
560sets the variable @var{printer-name} to that printer's name. But in
561some rare cases this can fail, or you may wish to use a different
562printer from within Emacs. The rest of this section explains how to
563tell Emacs which printer to use.
564
565@vindex printer-name@r{, (MS-DOS/MW-Windows)}
566 If you want to use your local printer, then set the Lisp variable
567@code{lpr-command} to @code{""} (its default value on Windows) and
568@code{printer-name} to the name of the printer port---for example,
569@code{"PRN"}, the usual local printer port or @code{"LPT2"}, or
570@code{"COM1"} for a serial printer. You can also set
571@code{printer-name} to a file name, in which case ``printed'' output
572is actually appended to that file. If you set @code{printer-name} to
573@code{"NUL"}, printed output is silently discarded (sent to the system
574null device).
575
576 You can also use a printer shared by another machine by setting
577@code{printer-name} to the UNC share name for that printer---for
578example, @code{"//joes_pc/hp4si"}. (It doesn't matter whether you use
579forward slashes or backslashes here.) To find out the names of shared
580printers, run the command @samp{net view} from the command prompt to
581obtain a list of servers, and @samp{net view @var{server-name}} to see
582the names of printers (and directories) shared by that server.
583Alternatively, click the @samp{Network Neighborhood} icon on your
584desktop, and look for machines which share their printers via the
585network.
586
587@cindex @samp{net use}, and printing on MS-Windows
588@cindex networked printers (MS-Windows)
589 If the printer doesn't appear in the output of @samp{net view}, or
590if setting @code{printer-name} to the UNC share name doesn't produce a
591hardcopy on that printer, you can use the @samp{net use} command to
592connect a local print port such as @code{"LPT2"} to the networked
593printer. For example, typing @kbd{net use LPT2: \\joes_pc\hp4si}@footnote{
594Note that the @samp{net use} command requires the UNC share name to be
595typed with the Windows-style backslashes, while the value of
596@code{printer-name} can be set with either forward- or backslashes.}
597causes Windows to @dfn{capture} the @code{LPT2} port and redirect the
598printed material to the printer connected to the machine @code{joes_pc}.
599After this command, setting @code{printer-name} to @code{"LPT2"}
600should produce the hardcopy on the networked printer.
601
602 With some varieties of Windows network software, you can instruct
603Windows to capture a specific printer port such as @code{"LPT2"}, and
604redirect it to a networked printer via the @w{@code{Control
605Panel->Printers}} applet instead of @samp{net use}.
606
607 If you set @code{printer-name} to a file name, it's best to use an
608absolute file name. Emacs changes the working directory according to
609the default directory of the current buffer, so if the file name in
610@code{printer-name} is relative, you will end up with several such
611files, each one in the directory of the buffer from which the printing
612was done.
613
375136cc
EZ
614 If the value of @code{printer-name} is correct, but printing does
615not produce the hardcopy on your printer, it is possible that your
616printer does not support printing plain text (some cheap printers omit
a210f8e6
EZ
617this functionality). In that case, try the PostScript print commands,
618described below.
375136cc 619
270c6692
EZ
620@findex print-buffer @r{(MS-DOS)}
621@findex print-region @r{(MS-DOS)}
622@vindex lpr-headers-switches @r{(MS-DOS)}
623 The commands @code{print-buffer} and @code{print-region} call the
624@code{pr} program, or use special switches to the @code{lpr} program, to
625produce headers on each printed page. MS-DOS and MS-Windows don't
626normally have these programs, so by default, the variable
627@code{lpr-headers-switches} is set so that the requests to print page
628headers are silently ignored. Thus, @code{print-buffer} and
629@code{print-region} produce the same output as @code{lpr-buffer} and
630@code{lpr-region}, respectively. If you do have a suitable @code{pr}
631program (for example, from GNU Coreutils), set
632@code{lpr-headers-switches} to @code{nil}; Emacs will then call
633@code{pr} to produce the page headers, and print the resulting output as
634specified by @code{printer-name}.
635
636@vindex print-region-function @r{(MS-DOS)}
637@cindex lpr usage under MS-DOS
638@vindex lpr-command @r{(MS-DOS)}
639@vindex lpr-switches @r{(MS-DOS)}
640 Finally, if you do have an @code{lpr} work-alike, you can set the
641variable @code{lpr-command} to @code{"lpr"}. Then Emacs will use
642@code{lpr} for printing, as on other systems. (If the name of the
643program isn't @code{lpr}, set @code{lpr-command} to specify where to
644find it.) The variable @code{lpr-switches} has its standard meaning
645when @code{lpr-command} is not @code{""}. If the variable
646@code{printer-name} has a string value, it is used as the value for the
647@code{-P} option to @code{lpr}, as on Unix.
648
649@findex ps-print-buffer @r{(MS-DOS)}
650@findex ps-spool-buffer @r{(MS-DOS)}
651@vindex ps-printer-name @r{(MS-DOS)}
652@vindex ps-lpr-command @r{(MS-DOS)}
653@vindex ps-lpr-switches @r{(MS-DOS)}
654 A parallel set of variables, @code{ps-lpr-command},
655@code{ps-lpr-switches}, and @code{ps-printer-name} (@pxref{PostScript
656Variables}), defines how PostScript files should be printed. These
657variables are used in the same way as the corresponding variables
658described above for non-PostScript printing. Thus, the value of
659@code{ps-printer-name} is used as the name of the device (or file) to
660which PostScript output is sent, just as @code{printer-name} is used
661for non-PostScript printing. (There are two distinct sets of
662variables in case you have two printers attached to two different
663ports, and only one of them is a PostScript printer.)
664
665 The default value of the variable @code{ps-lpr-command} is @code{""},
666which causes PostScript output to be sent to the printer port specified
667by @code{ps-printer-name}, but @code{ps-lpr-command} can also be set to
668the name of a program which will accept PostScript files. Thus, if you
669have a non-PostScript printer, you can set this variable to the name of
670a PostScript interpreter program (such as Ghostscript). Any switches
671that need to be passed to the interpreter program are specified using
672@code{ps-lpr-switches}. (If the value of @code{ps-printer-name} is a
673string, it will be added to the list of switches as the value for the
674@code{-P} option. This is probably only useful if you are using
675@code{lpr}, so when using an interpreter typically you would set
676@code{ps-printer-name} to something other than a string so it is
677ignored.)
678
679 For example, to use Ghostscript for printing on the system's default
680printer, put this in your @file{.emacs} file:
681
682@example
683(setq ps-printer-name t)
684(setq ps-lpr-command "D:/gs6.01/bin/gswin32c.exe")
685(setq ps-lpr-switches '("-q" "-dNOPAUSE" "-dBATCH"
686 "-sDEVICE=mswinpr2"
687 "-sPAPERSIZE=a4"))
688@end example
689
690@noindent
691(This assumes that Ghostscript is installed in the
692@file{D:/gs6.01} directory.)
693
37a75312
EZ
694@node Windows Misc
695@section Miscellaneous Windows-specific features
696
697 This section describes miscellaneous Windows-specific features.
698
a210f8e6
EZ
699@vindex w32-use-visible-system-caret
700@cindex screen reader software, MS-Windows
701 The variable @code{w32-use-visible-system-caret} is a flag that
702determines whether to make the system caret visible. The default is
703@code{nil}, which means Emacs draws its own cursor to indicate the
704position of point. A non-@code{nil} value means Emacs will indicate
705point location by the system caret; this facilitates use of screen
706reader software. When this variable is non-@code{nil}, other
707variables affecting the cursor display have no effect.
708
709@iftex
710@inforef{Windows Misc, , emacs}, for information about additional
711Windows-specific variables in this category.
712@end iftex
713
7d0a2d30 714@ifnottex
37a75312
EZ
715@vindex w32-grab-focus-on-raise
716@cindex frame focus policy, MS-Windows
717 The variable @code{w32-grab-focus-on-raise}, if set to a
718non-@code{nil} value causes a frame to grab focus when it is raised.
719The default is @code{t}, which fits well with the Windows default
720click-to-focus policy.
721
722@vindex w32-list-proportional-fonts
723 The variable @code{w32-list-proportional-fonts} controls whether
724proportional fonts are included in the font selection dialog. If its
725value is non-@code{nil}, these fonts will be included. The default is
726@code{nil}.
7d0a2d30 727@end ifnottex
37a75312 728
5798efc8
EZ
729@ifnottex
730@include msdog-xtra.texi
731@end ifnottex
732
ab5796a9
MB
733@ignore
734 arch-tag: f39d2590-5dcc-4318-88d9-0eb73ca10fa2
735@end ignore