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