Fix bug #7300.
[emacs.git] / doc / emacs / msdog.texi
blob3e8d5ef57c1644cb30ecfd41125157a4a8cc7d90
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, 2009, 2010
4 @c   Free Software Foundation, Inc.
5 @c See file emacs.texi for copying conditions.
6 @node Microsoft Windows, Manifesto, Mac OS / GNUstep, Top
7 @appendix Emacs and Microsoft Windows/MS-DOS
8 @cindex Microsoft Windows
9 @cindex MS-Windows, Emacs peculiarities
11   This section describes peculiarities of using Emacs on Microsoft
12 Windows.  Some of these peculiarities are also relevant to Microsoft's
13 older MS-DOS ``operating system'' (also known as ``MS-DOG'').
14 However, Emacs features that are relevant @emph{only} to MS-DOS are
15 described in a separate
16 @iftex
17 manual (@pxref{MS-DOS,,, emacs-xtra, Specialized Emacs Features}).
18 @end iftex
19 @ifnottex
20 section (@pxref{MS-DOS}).
21 @end ifnottex
24   The behavior of Emacs on MS-Windows is reasonably similar to what is
25 documented in the rest of the manual, including support for long file
26 names, multiple frames, scroll bars, mouse menus, and subprocesses.
27 However, a few special considerations apply, and they are described
28 here.
30 @menu
31 * Text and Binary::     Text files use CRLF to terminate lines.
32 * Windows Files::       File-name conventions on Windows.
33 * ls in Lisp::          Emulation of @code{ls} for Dired.
34 * Windows HOME::        Where Emacs looks for your @file{.emacs} and
35                           where it starts up.
36 * Windows Keyboard::    Windows-specific keyboard features.
37 * Windows Mouse::       Windows-specific mouse features.
38 * Windows Processes::   Running subprocesses on Windows.
39 * Windows Printing::    How to specify the printer on MS-Windows.
40 * Windows Fonts::       Specifying fonts on MS-Windows.
41 * Windows Misc::        Miscellaneous Windows features.
42 @ifnottex
43 * MS-DOS::              Using Emacs on MS-DOS (otherwise known as @dfn{MS-DOG}).
44 @end ifnottex
45 @end menu
47 @node Text and Binary
48 @section Text Files and Binary Files
49 @cindex text and binary files on MS-DOS/MS-Windows
51   GNU Emacs uses newline characters to separate text lines.  This is the
52 convention used on GNU, Unix, and other Posix-compliant systems.
54 @cindex end-of-line conversion on MS-DOS/MS-Windows
55   By contrast, MS-DOS and MS-Windows normally use carriage-return linefeed,
56 a two-character sequence, to separate text lines.  (Linefeed is the same
57 character as newline.)  Therefore, convenient editing of typical files
58 with Emacs requires conversion of these end-of-line (EOL) sequences.
59 And that is what Emacs normally does: it converts carriage-return
60 linefeed into newline when reading files, and converts newline into
61 carriage-return linefeed when writing files.  The same mechanism that
62 handles conversion of international character codes does this conversion
63 also (@pxref{Coding Systems}).
65 @cindex cursor location, on MS-DOS
66 @cindex point location, on MS-DOS
67   One consequence of this special format-conversion of most files is
68 that character positions as reported by Emacs (@pxref{Position Info}) do
69 not agree with the file size information known to the operating system.
71   In addition, if Emacs recognizes from a file's contents that it uses
72 newline rather than carriage-return linefeed as its line separator, it
73 does not perform EOL conversion when reading or writing that file.
74 Thus, you can read and edit files from GNU and Unix systems on MS-DOS
75 with no special effort, and they will retain their Unix-style
76 end-of-line convention after you edit them.
78   The mode line indicates whether end-of-line translation was used for
79 the current buffer.  If MS-DOS end-of-line translation is in use for the
80 buffer, the MS-Windows build of Emacs displays a backslash @samp{\} after
81 the coding system mnemonic near the beginning of the mode line
82 (@pxref{Mode Line}).  If no EOL translation was performed, the string
83 @samp{(Unix)} is displayed instead of the backslash, to alert you that the
84 file's EOL format is not the usual carriage-return linefeed.
86 @cindex DOS-to-Unix conversion of files
87   To visit a file and specify whether it uses DOS-style or Unix-style
88 end-of-line, specify a coding system (@pxref{Text Coding}).  For
89 example, @kbd{C-x @key{RET} c unix @key{RET} C-x C-f foobar.txt}
90 visits the file @file{foobar.txt} without converting the EOLs; if some
91 line ends with a carriage-return linefeed pair, Emacs will display
92 @samp{^M} at the end of that line.  Similarly, you can direct Emacs to
93 save a buffer in a specified EOL format with the @kbd{C-x @key{RET} f}
94 command.  For example, to save a buffer with Unix EOL format, type
95 @kbd{C-x @key{RET} f unix @key{RET} C-x C-s}.  If you visit a file
96 with DOS EOL conversion, then save it with Unix EOL format, that
97 effectively converts the file to Unix EOL style, like @code{dos2unix}.
99 @cindex untranslated file system
100 @findex add-untranslated-filesystem
101   When you use NFS, Samba, or some other similar method to access file
102 systems that reside on computers using GNU or Unix systems, Emacs
103 should not perform end-of-line translation on any files in these file
104 systems---not even when you create a new file.  To request this,
105 designate these file systems as @dfn{untranslated} file systems by
106 calling the function @code{add-untranslated-filesystem}.  It takes one
107 argument: the file system name, including a drive letter and
108 optionally a directory.  For example,
110 @example
111 (add-untranslated-filesystem "Z:")
112 @end example
114 @noindent
115 designates drive Z as an untranslated file system, and
117 @example
118 (add-untranslated-filesystem "Z:\\foo")
119 @end example
121 @noindent
122 designates directory @file{\foo} on drive Z as an untranslated file
123 system.
125   Most often you would use @code{add-untranslated-filesystem} in your
126 @file{.emacs} file, or in @file{site-start.el} so that all the users at
127 your site get the benefit of it.
129 @findex remove-untranslated-filesystem
130   To countermand the effect of @code{add-untranslated-filesystem}, use
131 the function @code{remove-untranslated-filesystem}.  This function takes
132 one argument, which should be a string just like the one that was used
133 previously with @code{add-untranslated-filesystem}.
135   Designating a file system as untranslated does not affect character
136 set conversion, only end-of-line conversion.  Essentially, it directs
137 Emacs to create new files with the Unix-style convention of using
138 newline at the end of a line.  @xref{Coding Systems}.
140 @vindex file-name-buffer-file-type-alist
141 @cindex binary files, on MS-DOS/MS-Windows
142   Some kinds of files should not be converted at all, because their
143 contents are not really text.  Therefore, Emacs on MS-Windows distinguishes
144 certain files as @dfn{binary files}.  (This distinction is not part of
145 MS-Windows; it is made by Emacs only.)  Binary files include executable
146 programs, compressed archives, etc.  Emacs uses the file name to decide
147 whether to treat a file as binary: the variable
148 @code{file-name-buffer-file-type-alist} defines the file-name patterns
149 that indicate binary files.  If a file name matches one of the patterns
150 for binary files (those whose associations are of the type
151 @code{(@var{pattern} . t)}, Emacs reads and writes that file using the
152 @code{no-conversion} coding system (@pxref{Coding Systems}) which turns
153 off @emph{all} coding-system conversions, not only the EOL conversion.
154 @code{file-name-buffer-file-type-alist} also includes file-name patterns
155 for files which are known to be Windows-style text files with
156 carriage-return linefeed EOL format, such as @file{CONFIG.SYS}; Emacs
157 always writes those files with Windows-style EOLs.
159   If a file which belongs to an untranslated file system matches one of
160 the file-name patterns in @code{file-name-buffer-file-type-alist}, the
161 EOL conversion is determined by @code{file-name-buffer-file-type-alist}.
163 @node Windows Files
164 @section File Names on MS-Windows
165 @cindex file names on MS-Windows
167   MS-Windows and MS-DOS normally use a backslash, @samp{\}, to
168 separate name units within a file name, instead of the slash used on
169 other systems.  Emacs on MS-DOS/MS-Windows permits use of either slash or
170 backslash, and also knows about drive letters in file names.
172 @cindex file-name completion, on MS-Windows
173   On MS-DOS/MS-Windows, file names are case-insensitive, so Emacs by
174 default ignores letter-case in file names during completion.
176 @vindex w32-get-true-file-attributes
177   The variable @code{w32-get-true-file-attributes} controls whether
178 Emacs should issue additional system calls to determine more
179 accurately file attributes in primitives like @code{file-attributes}
180 and @code{directory-files-and-attributes}.  These additional calls are
181 needed to report correct file ownership, link counts and file types
182 for special files such as pipes.  Without these system calls, file
183 ownership will be attributed to the current user, link counts will be
184 always reported as 1, and special files will be reported as regular
185 files.
187   If the value of this variable is @code{local} (the default), Emacs
188 will issue these additional system calls only for files on local fixed
189 drives.  Any other non-@code{nil} value means do this even for
190 removable and remote volumes, where this could potentially slow down
191 Dired and other related features.  The value of @code{nil} means never
192 issue those system calls.  Non-@code{nil} values are more useful on
193 NTFS volumes, which support hard links and file security, than on FAT,
194 FAT32, and XFAT volumes.
196 @node ls in Lisp
197 @section Emulation of @code{ls} on MS-Windows
198 @cindex Dired, and MS-Windows/MS-DOS
199 @cindex @code{ls} emulation
201   Dired normally uses the external program @code{ls} (or its close
202 work-alike) to produce the directory listing displayed in Dired
203 buffers (@pxref{Dired}).  However, MS-Windows and MS-DOS systems don't
204 come with such a program, although several ports of @sc{gnu} @code{ls}
205 are available.  Therefore, Emacs on those systems @emph{emulates}
206 @code{ls} in Lisp, by using the @file{ls-lisp.el} package.  While
207 @file{ls-lisp.el} provides a reasonably full emulation of @code{ls},
208 there are some options and features peculiar to that emulation;
209 @iftex
210 for more details, see the documentation of the variables whose names
211 begin with @code{ls-lisp}.
212 @end iftex
213 @ifnottex
214 they are described in this section.
216   The @code{ls} emulation supports many of the @code{ls} switches, but
217 it doesn't support all of them.  Here's the list of the switches it
218 does support: @option{-A}, @option{-a}, @option{-B}, @option{-C},
219 @option{-c}, @option{-i}, @option{-G}, @option{-g}, @option{-R},
220 @option{-r}, @option{-S}, @option{-s}, @option{-t}, @option{-U},
221 @option{-u}, and @option{-X}.  The @option{-F} switch is partially
222 supported (it appends the character that classifies the file, but does
223 not prevent symlink following).
225 @vindex ls-lisp-use-insert-directory-program
226   On MS-Windows and MS-DOS, @file{ls-lisp.el} is preloaded when Emacs
227 is built, so the Lisp emulation of @code{ls} is always used on those
228 platforms.  If you have a ported @code{ls}, setting
229 @code{ls-lisp-use-insert-directory-program} to a non-@code{nil} value
230 will revert to using an external program named by the variable
231 @code{insert-directory-program}.
233 @vindex ls-lisp-ignore-case
234   By default, @file{ls-lisp.el} uses a case-sensitive sort order for
235 the directory listing it produces; this is so the listing looks the
236 same as on other platforms.  If you wish that the files be sorted in
237 case-insensitive order, set the variable @code{ls-lisp-ignore-case} to
238 a non-@code{nil} value.
240 @vindex ls-lisp-dirs-first
241   By default, files and subdirectories are sorted together, to emulate
242 the behavior of @code{ls}.  However, native MS-Windows/MS-DOS file
243 managers list the directories before the files; if you want that
244 behavior, customize the option @code{ls-lisp-dirs-first} to a
245 non-@code{nil} value.
247 @vindex ls-lisp-verbosity
248   The variable @code{ls-lisp-verbosity} controls the file attributes
249 that @file{ls-lisp.el} displays.  The value should be a list that
250 contains one or more of the symbols @code{links}, @code{uid}, and
251 @code{gid}.  @code{links} means display the count of different file
252 names that are associated with (a.k.a.@: @dfn{links to}) the file's
253 data; this is only useful on NTFS volumes.  @code{uid} means display
254 the numerical identifier of the user who owns the file.  @code{gid}
255 means display the numerical identifier of the file owner's group.  The
256 default value is @code{(links uid gid)} i.e.@: all the 3 optional
257 attributes are displayed.
259 @vindex ls-lisp-emulation
260   The variable @code{ls-lisp-emulation} controls the flavour of the
261 @code{ls} emulation by setting the defaults for the 3 options
262 described above: @code{ls-lisp-ignore-case},
263 @code{ls-lisp-dirs-first}, and @code{ls-lisp-verbosity}.  The value of
264 this option can be one of the following symbols:
266 @table @code
267 @item GNU
268 @itemx nil
269 Emulate @sc{gnu} systems; this is the default.  This sets
270 @code{ls-lisp-ignore-case} and @code{ls-lisp-dirs-first} to
271 @code{nil}, and @code{ls-lisp-verbosity} to @code{(links uid gid)}.
272 @item UNIX
273 Emulate Unix systems.  Like @code{GNU}, but sets
274 @code{ls-lisp-verbosity} to @code{(links uid)}.
275 @item MacOS
276 Emulate MacOS.  Sets @code{ls-lisp-ignore-case} to @code{t}, and
277 @code{ls-lisp-dirs-first} and @code{ls-lisp-verbosity} to @code{nil}.
278 @item MS-Windows
279 Emulate MS-Windows.  Sets @code{ls-lisp-ignore-case} and
280 @code{ls-lisp-dirs-first} to @code{t}, and @code{ls-lisp-verbosity} to
281 @code{(links)} on Windows NT/2K/XP/2K3 and to @code{nil} on Windows 9X.
282 Note that the default emulation is @emph{not} @code{MS-Windows}, even
283 on Windows, since many users of Emacs on those platforms prefer the
284 @sc{gnu} defaults.
285 @end table
287 @noindent
288 Any other value of @code{ls-lisp-emulation} means the same as
289 @code{GNU}.  Note that this option needs to be set @emph{before}
290 @file{ls-lisp.el} is loaded, which means that on MS-Windows and MS-DOS
291 you will have to set the value from your @file{.emacs} file and then
292 restart Emacs, since @file{ls-lisp.el} is preloaded.
294 @vindex ls-lisp-support-shell-wildcards
295   The variable @code{ls-lisp-support-shell-wildcards} controls how
296 file-name patterns are supported: if it is non-@code{nil} (the
297 default), they are treated as shell-style wildcards; otherwise they
298 are treated as Emacs regular expressions.
300 @vindex ls-lisp-format-time-list
301   The variable @code{ls-lisp-format-time-list} defines how to format
302 the date and time of files.  @emph{The value of this variable is
303 ignored}, unless Emacs cannot determine the current locale.  (However,
304 if the value of @code{ls-lisp-use-localized-time-format} is
305 non-@code{nil}, Emacs obeys @code{ls-lisp-format-time-list} even if
306 the current locale is available; see below.)
308 The value of @code{ls-lisp-format-time-list} is a list of 2 strings.
309 The first string is used if the file was modified within the current
310 year, while the second string is used for older files.  In each of
311 these two strings you can use @samp{%}-sequences to substitute parts
312 of the time.  For example:
313 @lisp
314 ("%b %e %H:%M" "%b %e  %Y")
315 @end lisp
317 @noindent
318 Note that the strings substituted for these @samp{%}-sequences depend
319 on the current locale.  @xref{Time Parsing,,, elisp, The Emacs Lisp
320 Reference Manual}, for more about format time specs.
322 @vindex ls-lisp-use-localized-time-format
323   Normally, Emacs formats the file time stamps in either traditional
324 or ISO-style time format.  However, if the value of the variable
325 @code{ls-lisp-use-localized-time-format} is non-@code{nil}, Emacs
326 formats file time stamps according to what
327 @code{ls-lisp-format-time-list} specifies.  The @samp{%}-sequences in
328 @code{ls-lisp-format-time-list} produce locale-dependent month and day
329 names, which might cause misalignment of columns in Dired display.
330 @end ifnottex
332 @node Windows HOME
333 @section HOME and Startup Directories on MS-Windows
334 @cindex @code{HOME} directory on MS-Windows
336   The Windows equivalent of the @code{HOME} directory is the
337 @dfn{user-specific application data directory}.  The actual location
338 depends on your Windows version and system configuration; typical values
339 are @file{C:\Documents and Settings\@var{username}\Application Data} on
340 Windows 2K/XP and later, and either @file{C:\WINDOWS\Application Data}
341 or @file{C:\WINDOWS\Profiles\@var{username}\Application Data} on the
342 older Windows 9X/ME systems.
344 @cindex init file @file{.emacs} on MS-Windows
345   The home directory is where your init file @file{.emacs} is stored.
346 When Emacs starts, it first checks whether the environment variable
347 @env{HOME} is set.  If it is, it looks for the init file in the
348 directory pointed by @env{HOME}.  If @env{HOME} is not defined, Emacs
349 checks for an existing @file{.emacs} file in @file{C:\}, the root
350 directory of drive @file{C:}@footnote{
351 The check in @file{C:\} is for compatibility with older versions of Emacs,
352 which didn't check the application data directory.
353 }.  If there's no such file in @file{C:\}, Emacs next uses the Windows
354 system calls to find out the exact location of your application data
355 directory.  If that system call fails, Emacs falls back to @file{C:\}.
357   Whatever the final place is, Emacs sets the value of the @env{HOME}
358 environment variable to point to it, and it will use that location for
359 other files and directories it normally creates in the user's home
360 directory.
362   You can always find out where Emacs thinks is your home directory's
363 location by typing @kbd{C-x d ~/ @key{RET}}.  This should present the
364 list of files in the home directory, and show its full name on the
365 first line.  Likewise, to visit your init file, type @kbd{C-x C-f
366 ~/.emacs @key{RET}}.
368 @cindex @file{_emacs} init file, MS-Windows
369   Because MS-DOS does not allow file names with leading dots, and
370 because older Windows systems made it hard to create files with such
371 names, the Windows port of Emacs supports an alternative name
372 @file{_emacs} as a fallback, if such a file exists in the home
373 directory, whereas @file{.emacs} does not.
375 @cindex start directory, MS-Windows
376 @cindex directory where Emacs starts on MS-Windows
377   If you use a Windows desktop shortcut to start Emacs, it starts in
378 the directory specified by the shortcut.  To control where that is,
379 right-click on the shortcut, select ``Properties'', and in the
380 ``Shortcut'' tab modify the ``Start in'' field to your liking.
382 @node Windows Keyboard
383 @section Keyboard Usage on MS-Windows
384 @cindex keyboard, MS-Windows
386   This section describes the Windows-specific features related to
387 keyboard input in Emacs.
389 @cindex MS-Windows keyboard shortcuts
390   Many key combinations (known as ``keyboard shortcuts'') that have
391 conventional uses in MS-Windows programs conflict with traditional
392 Emacs key bindings.  (These Emacs key bindings were established years
393 before Microsoft was founded.)  Examples of conflicts include
394 @kbd{C-c}, @kbd{C-x}, @kbd{C-z}, @kbd{C-a}, and @kbd{W-@key{SPC}}.
395 You can redefine some of them with meanings more like the MS-Windows
396 meanings by enabling CUA Mode (@pxref{CUA Bindings}).
398 @kindex F10 @r{(MS-Windows)}
399 @cindex menu bar access using keyboard @r{(MS-Windows)}
400   The @key{F10} key on Windows activates the menu bar in a way that
401 makes it possible to use the menus without a mouse.  In this mode, the
402 arrow keys traverse the menus, @key{RET} selects a highlighted menu
403 item, and @key{ESC} closes the menu.
405 @iftex
406 @inforef{Windows Keyboard, , emacs}, for information about additional
407 Windows-specific variables in this category.
408 @end iftex
409 @ifnottex
410 @vindex w32-alt-is-meta
411 @cindex @code{Alt} key (MS-Windows)
412   By default, the key labeled @key{Alt} is mapped as the @key{META}
413 key.  If you wish it to produce the @code{Alt} modifier instead, set
414 the variable @code{w32-alt-is-meta} to a @code{nil} value.
416 @findex w32-register-hot-key
417 @findex w32-unregister-hot-key
418   MS-Windows reserves certain key combinations, such as
419 @kbd{Alt-@key{TAB}}, for its own use.  These key combinations are
420 intercepted by the system before Emacs can see them.  You can use the
421 @code{w32-register-hot-key} function to allow a key sequence to be
422 seen by Emacs instead of being grabbed by Windows.  This functions
423 registers a key sequence as a @dfn{hot key}, overriding the special
424 meaning of that key sequence for Windows.  (MS-Windows is told that
425 the key sequence is a hot key only when one of the Emacs windows has
426 focus, so that the special keys still have their usual meaning for
427 other Windows applications.)
429   The argument to @code{w32-register-hot-key} must be a single key,
430 with or without modifiers, in vector form that would be acceptable to
431 @code{define-key}.  The meta modifier is interpreted as the @key{ALT}
432 key if @code{w32-alt-is-meta} is @code{t} (the default), and the hyper
433 modifier is always interpreted as the Windows key (usually labeled
434 with @key{start} and the Windows logo).  If the function succeeds in
435 registering the key sequence, it returns the hotkey ID, a number;
436 otherwise it returns @code{nil}.
438 @kindex M-TAB@r{, (MS-Windows)}
439 @cindex @kbd{M-@key{TAB}} vs @kbd{Alt-@key{TAB}} (MS-Windows)
440 @cindex @kbd{Alt-@key{TAB}} vs @kbd{M-@key{TAB}} (MS-Windows)
441   For example, @code{(w32-register-hot-key [M-tab])} lets you use
442 @kbd{M-TAB} normally in Emacs, for instance, to complete the word or
443 symbol at point at top level, or to complete the current search string
444 against previously sought strings during incremental search.
446   The function @code{w32-unregister-hot-key} reverses the effect of
447 @code{w32-register-hot-key} for its argument key sequence.
449 @vindex w32-capslock-is-shiftlock
450   By default, the @key{CapsLock} key only affects normal character
451 keys (it converts lower-case characters to their upper-case
452 variants).  However, if you set the variable
453 @code{w32-capslock-is-shiftlock} to a non-@code{nil} value, the
454 @key{CapsLock} key will affect non-character keys as well, as if you
455 pressed the @key{Shift} key while typing the non-character key.
457 @vindex w32-enable-caps-lock
458   If the variable @code{w32-enable-caps-lock} is set to a @code{nil}
459 value, the @key{CapsLock} key produces the symbol @code{capslock}
460 instead of the shifted version of they keys.  The default value is
461 @code{t}.
463 @vindex w32-enable-num-lock
464 @cindex keypad keys (MS-Windows)
465   Similarly, if @code{w32-enable-num-lock} is @code{nil}, the
466 @key{NumLock} key will produce the symbol @code{kp-numlock}.  The
467 default is @code{t}, which causes @key{NumLock} to work as expected:
468 toggle the meaning of the keys on the numeric keypad.
469 @end ifnottex
471 @vindex w32-apps-modifier
472   The variable @code{w32-apps-modifier} controls the effect of the
473 @key{Apps} key (usually located between the right @key{Alt} and the
474 right @key{Ctrl} keys).  Its value can be one of the symbols
475 @code{hyper}, @code{super}, @code{meta}, @code{alt}, @code{control},
476 or @code{shift} for the respective modifier, or @code{nil} to appear
477 as the key @code{apps}.  The default is @code{nil}.
479 @vindex w32-lwindow-modifier
480 @vindex w32-rwindow-modifier
481 @vindex w32-scroll-lock-modifier
482   The variable @code{w32-lwindow-modifier} determines the effect of
483 the left Windows key (usually labeled with @key{start} and the Windows
484 logo).  If its value is @code{nil} (the default), the key will produce
485 the symbol @code{lwindow}.  Setting it to one of the symbols
486 @code{hyper}, @code{super}, @code{meta}, @code{alt}, @code{control},
487 or @code{shift} will produce the respective modifier.  A similar
488 variable @code{w32-rwindow-modifier} controls the effect of the right
489 Windows key, and @code{w32-scroll-lock-modifier} does the same for the
490 @key{ScrLock} key.  If these variables are set to @code{nil}, the
491 right Windows key produces the symbol @code{rwindow} and @key{ScrLock}
492 produces the symbol @code{scroll}.
494 @vindex w32-pass-alt-to-system
495 @cindex Windows system menu
496 @cindex @code{Alt} key invokes menu (Windows)
497   Emacs compiled as a native Windows application normally turns off
498 the Windows feature that tapping the @key{ALT} key invokes the Windows
499 menu.  The reason is that the @key{ALT} serves as @key{META} in Emacs.
500 When using Emacs, users often press the @key{META} key temporarily and
501 then change their minds; if this has the effect of bringing up the
502 Windows menu, it alters the meaning of subsequent commands.  Many
503 users find this frustrating.
505   You can re-enable Windows' default handling of tapping the @key{ALT}
506 key by setting @code{w32-pass-alt-to-system} to a non-@code{nil}
507 value.
509 @ifnottex
510 @vindex w32-pass-lwindow-to-system
511 @vindex w32-pass-rwindow-to-system
512   The variables @code{w32-pass-lwindow-to-system} and
513 @code{w32-pass-rwindow-to-system} determine whether the respective
514 keys are passed to Windows or swallowed by Emacs.  If the value is
515 @code{nil}, the respective key is silently swallowed by Emacs,
516 otherwise it is passed to Windows.  The default is @code{t} for both
517 of these variables.  Passing each of these keys to Windows produces
518 its normal effect: for example, @kbd{@key{Lwindow}} opens the
519 @code{Start} menu, etc.@footnote{
520 Some combinations of the ``Windows'' keys with other keys are caught
521 by Windows at low level in a way that Emacs currently cannot prevent.
522 For example, @kbd{@key{Lwindow} r} always pops up the Windows
523 @samp{Run} dialog.  Customizing the value of
524 @code{w32-phantom-key-code} might help in some cases, though.}
526 @vindex w32-recognize-altgr
527 @kindex AltGr @r{(MS-Windows)}
528 @cindex AltGr key (MS-Windows)
529   The variable @code{w32-recognize-altgr} controls whether the
530 @key{AltGr} key (if it exists on your keyboard), or its equivalent,
531 the combination of the right @key{Alt} and left @key{Ctrl} keys
532 pressed together, is recognized as the @key{AltGr} key.  The default
533 is @code{t}, which means these keys produce @code{AltGr}; setting it
534 to @code{nil} causes @key{AltGr} or the equivalent key combination to
535 be interpreted as the combination of @key{CTRL} and @key{META}
536 modifiers.
537 @end ifnottex
539 @node Windows Mouse
540 @section Mouse Usage on MS-Windows
541 @cindex mouse, and MS-Windows
543   This section describes the Windows-specific variables related to
544 mouse.
546 @vindex w32-mouse-button-tolerance
547 @cindex simulation of middle mouse button
548   The variable @code{w32-mouse-button-tolerance} specifies the
549 time interval, in milliseconds, for faking middle mouse button press
550 on 2-button mice.  If both mouse buttons are depressed within this
551 time interval, Emacs generates a middle mouse button click event
552 instead of a double click on one of the buttons.
554 @vindex w32-pass-extra-mouse-buttons-to-system
555   If the variable @code{w32-pass-extra-mouse-buttons-to-system} is
556 non-@code{nil}, Emacs passes the fourth and fifth mouse buttons to
557 Windows.
559 @vindex w32-swap-mouse-buttons
560   The variable @code{w32-swap-mouse-buttons} controls which of the 3
561 mouse buttons generates the @kbd{mouse-2} events.  When it is
562 @code{nil} (the default), the middle button generates @kbd{mouse-2}
563 and the right button generates @kbd{mouse-3} events.  If this variable
564 is non-@code{nil}, the roles of these two buttons are reversed.
566 @node Windows Processes
567 @section Subprocesses on Windows 9X/ME and Windows NT/2K/XP
568 @cindex subprocesses on MS-Windows
570 @cindex DOS applications, running from Emacs
571   Emacs compiled as a native Windows application (as opposed to the DOS
572 version) includes full support for asynchronous subprocesses.
573 In the Windows version, synchronous and asynchronous subprocesses work
574 fine on both
575 Windows 9X/ME and Windows NT/2K/XP as long as you run only 32-bit Windows
576 applications.  However, when you run a DOS application in a subprocess,
577 you may encounter problems or be unable to run the application at all;
578 and if you run two DOS applications at the same time in two
579 subprocesses, you may have to reboot your system.
581 Since the standard command interpreter (and most command line utilities)
582 on Windows 9X are DOS applications, these problems are significant when
583 using that system.  But there's nothing we can do about them; only
584 Microsoft can fix them.
586 If you run just one DOS application subprocess, the subprocess should
587 work as expected as long as it is ``well-behaved'' and does not perform
588 direct screen access or other unusual actions.  If you have a CPU
589 monitor application, your machine will appear to be 100% busy even when
590 the DOS application is idle, but this is only an artifact of the way CPU
591 monitors measure processor load.
593 You must terminate the DOS application before you start any other DOS
594 application in a different subprocess.  Emacs is unable to interrupt or
595 terminate a DOS subprocess.  The only way you can terminate such a
596 subprocess is by giving it a command that tells its program to exit.
598 If you attempt to run two DOS applications at the same time in separate
599 subprocesses, the second one that is started will be suspended until the
600 first one finishes, even if either or both of them are asynchronous.
602 @cindex kill DOS application
603 If you can go to the first subprocess, and tell it to exit, the second
604 subprocess should continue normally.  However, if the second subprocess
605 is synchronous, Emacs itself will be hung until the first subprocess
606 finishes.  If it will not finish without user input, then you have no
607 choice but to reboot if you are running on Windows 9X.  If you are
608 running on Windows NT/2K/XP, you can use a process viewer application to kill
609 the appropriate instance of NTVDM instead (this will terminate both DOS
610 subprocesses).
612 If you have to reboot Windows 9X in this situation, do not use the
613 @code{Shutdown} command on the @code{Start} menu; that usually hangs the
614 system.  Instead, type @kbd{CTL-ALT-@key{DEL}} and then choose
615 @code{Shutdown}.  That usually works, although it may take a few minutes
616 to do its job.
618 @vindex w32-quote-process-args
619   The variable @code{w32-quote-process-args} controls how Emacs quotes
620 the process arguments.  Non-@code{nil} means quote with the @code{"}
621 character.  If the value is a character, use that character to escape
622 any quote characters that appear; otherwise chose a suitable escape
623 character based on the type of the program.
625 @ifnottex
626 @findex w32-shell-execute
627   The function @code{w32-shell-execute} can be useful for writing
628 customized commands that run MS-Windows applications registered to
629 handle a certain standard Windows operation for a specific type of
630 document or file.  This function is a wrapper around the Windows
631 @code{ShellExecute} API.  See the MS-Windows API documentation for
632 more details.
633 @end ifnottex
635 @node Windows Printing
636 @section Printing and MS-Windows
638   Printing commands, such as @code{lpr-buffer} (@pxref{Printing}) and
639 @code{ps-print-buffer} (@pxref{PostScript}) work in MS-DOS and
640 MS-Windows by sending the output to one of the printer ports, if a
641 Posix-style @code{lpr} program is unavailable.  The same Emacs
642 variables control printing on all systems, but in some cases they have
643 different default values on MS-DOS and MS-Windows.
645   Emacs on Windows automatically determines your default printer and
646 sets the variable @code{printer-name} to that printer's name.  But in
647 some rare cases this can fail, or you may wish to use a different
648 printer from within Emacs.  The rest of this section explains how to
649 tell Emacs which printer to use.
651 @vindex printer-name@r{, (MS-DOS/MS-Windows)}
652   If you want to use your local printer, then set the Lisp variable
653 @code{lpr-command} to @code{""} (its default value on Windows) and
654 @code{printer-name} to the name of the printer port---for example,
655 @code{"PRN"}, the usual local printer port or @code{"LPT2"}, or
656 @code{"COM1"} for a serial printer.  You can also set
657 @code{printer-name} to a file name, in which case ``printed'' output
658 is actually appended to that file.  If you set @code{printer-name} to
659 @code{"NUL"}, printed output is silently discarded (sent to the system
660 null device).
662   You can also use a printer shared by another machine by setting
663 @code{printer-name} to the UNC share name for that printer---for
664 example, @code{"//joes_pc/hp4si"}.  (It doesn't matter whether you use
665 forward slashes or backslashes here.)  To find out the names of shared
666 printers, run the command @samp{net view} from the command prompt to
667 obtain a list of servers, and @samp{net view @var{server-name}} to see
668 the names of printers (and directories) shared by that server.
669 Alternatively, click the @samp{Network Neighborhood} icon on your
670 desktop, and look for machines which share their printers via the
671 network.
673 @cindex @samp{net use}, and printing on MS-Windows
674 @cindex networked printers (MS-Windows)
675   If the printer doesn't appear in the output of @samp{net view}, or
676 if setting @code{printer-name} to the UNC share name doesn't produce a
677 hardcopy on that printer, you can use the @samp{net use} command to
678 connect a local print port such as @code{"LPT2"} to the networked
679 printer.  For example, typing @kbd{net use LPT2: \\joes_pc\hp4si}@footnote{
680 Note that the @samp{net use} command requires the UNC share name to be
681 typed with the Windows-style backslashes, while the value of
682 @code{printer-name} can be set with either forward- or backslashes.}
683 causes Windows to @dfn{capture} the @code{LPT2} port and redirect the
684 printed material to the printer connected to the machine @code{joes_pc}.
685 After this command, setting @code{printer-name} to @code{"LPT2"}
686 should produce the hardcopy on the networked printer.
688   With some varieties of Windows network software, you can instruct
689 Windows to capture a specific printer port such as @code{"LPT2"}, and
690 redirect it to a networked printer via the @w{@code{Control
691 Panel->Printers}} applet instead of @samp{net use}.
693   If you set @code{printer-name} to a file name, it's best to use an
694 absolute file name.  Emacs changes the working directory according to
695 the default directory of the current buffer, so if the file name in
696 @code{printer-name} is relative, you will end up with several such
697 files, each one in the directory of the buffer from which the printing
698 was done.
700   If the value of @code{printer-name} is correct, but printing does
701 not produce the hardcopy on your printer, it is possible that your
702 printer does not support printing plain text (some cheap printers omit
703 this functionality).  In that case, try the PostScript print commands,
704 described below.
706 @findex print-buffer @r{(MS-DOS)}
707 @findex print-region @r{(MS-DOS)}
708 @vindex lpr-headers-switches @r{(MS-DOS)}
709   The commands @code{print-buffer} and @code{print-region} call the
710 @code{pr} program, or use special switches to the @code{lpr} program, to
711 produce headers on each printed page.  MS-DOS and MS-Windows don't
712 normally have these programs, so by default, the variable
713 @code{lpr-headers-switches} is set so that the requests to print page
714 headers are silently ignored.  Thus, @code{print-buffer} and
715 @code{print-region} produce the same output as @code{lpr-buffer} and
716 @code{lpr-region}, respectively.  If you do have a suitable @code{pr}
717 program (for example, from GNU Coreutils), set
718 @code{lpr-headers-switches} to @code{nil}; Emacs will then call
719 @code{pr} to produce the page headers, and print the resulting output as
720 specified by @code{printer-name}.
722 @vindex print-region-function @r{(MS-DOS)}
723 @cindex lpr usage under MS-DOS
724 @vindex lpr-command @r{(MS-DOS)}
725 @vindex lpr-switches @r{(MS-DOS)}
726   Finally, if you do have an @code{lpr} work-alike, you can set the
727 variable @code{lpr-command} to @code{"lpr"}.  Then Emacs will use
728 @code{lpr} for printing, as on other systems.  (If the name of the
729 program isn't @code{lpr}, set @code{lpr-command} to specify where to
730 find it.)  The variable @code{lpr-switches} has its standard meaning
731 when @code{lpr-command} is not @code{""}.  If the variable
732 @code{printer-name} has a string value, it is used as the value for the
733 @code{-P} option to @code{lpr}, as on Unix.
735 @findex ps-print-buffer @r{(MS-DOS)}
736 @findex ps-spool-buffer @r{(MS-DOS)}
737 @vindex ps-printer-name @r{(MS-DOS)}
738 @vindex ps-lpr-command @r{(MS-DOS)}
739 @vindex ps-lpr-switches @r{(MS-DOS)}
740   A parallel set of variables, @code{ps-lpr-command},
741 @code{ps-lpr-switches}, and @code{ps-printer-name} (@pxref{PostScript
742 Variables}), defines how PostScript files should be printed.  These
743 variables are used in the same way as the corresponding variables
744 described above for non-PostScript printing.  Thus, the value of
745 @code{ps-printer-name} is used as the name of the device (or file) to
746 which PostScript output is sent, just as @code{printer-name} is used
747 for non-PostScript printing.  (There are two distinct sets of
748 variables in case you have two printers attached to two different
749 ports, and only one of them is a PostScript printer.)
751 @cindex Ghostscript, use for PostScript printing
752   The default value of the variable @code{ps-lpr-command} is @code{""},
753 which causes PostScript output to be sent to the printer port specified
754 by @code{ps-printer-name}, but @code{ps-lpr-command} can also be set to
755 the name of a program which will accept PostScript files.  Thus, if you
756 have a non-PostScript printer, you can set this variable to the name of
757 a PostScript interpreter program (such as Ghostscript).  Any switches
758 that need to be passed to the interpreter program are specified using
759 @code{ps-lpr-switches}.  (If the value of @code{ps-printer-name} is a
760 string, it will be added to the list of switches as the value for the
761 @code{-P} option.  This is probably only useful if you are using
762 @code{lpr}, so when using an interpreter typically you would set
763 @code{ps-printer-name} to something other than a string so it is
764 ignored.)
766   For example, to use Ghostscript for printing on the system's default
767 printer, put this in your @file{.emacs} file:
769 @example
770 (setq ps-printer-name t)
771 (setq ps-lpr-command "D:/gs6.01/bin/gswin32c.exe")
772 (setq ps-lpr-switches '("-q" "-dNOPAUSE" "-dBATCH"
773                         "-sDEVICE=mswinpr2"
774                         "-sPAPERSIZE=a4"))
775 @end example
777 @noindent
778 (This assumes that Ghostscript is installed in the
779 @file{D:/gs6.01} directory.)
781 @node Windows Fonts
782 @section Specifying Fonts on MS-Windows
783 @cindex font specification (MS Windows)
785   Starting with Emacs 23, fonts are specified by their name, size
786 and optional properties.  The format for specifying fonts comes from the
787 fontconfig library used in modern Free desktops:
789 @example
790   [Family[-PointSize]][:Option1=Value1[:Option2=Value2[...]]]
791 @end example
793   The old XLFD based format is also supported for backwards compatibility.
795   Emacs 23 supports a number of backends.  Currently, the @code{gdi}
796 and @code{uniscribe} font backends are supported on Windows.  The
797 @code{gdi} font backend is available on all versions of Windows, and
798 supports all fonts that are natively supported by Windows.  The
799 @code{uniscribe} font backend is available on Windows 2000 and later,
800 and supports Truetype and Opentype fonts.  Some languages requiring
801 complex layout can only be properly supported by the uniscribe
802 backend.  By default, both backends are enabled if supported, with
803 @code{uniscribe} taking priority over @code{gdi}.
805 @cindex font properties (MS Windows)
806 @noindent
807 Optional properties common to all font backends on MS-Windows are:
809 @table @code
811 @vindex font-weight-table @r{(MS-Windows)}
812 @item weight
813 Specifies the weight of the font.  Special values @code{light},
814 @code{medium}, @code{demibold}, @code{bold}, and @code{black} can be specified
815 without @code{weight=} (e.g., @kbd{Courier New-12:bold}).  Otherwise,
816 the weight should be a numeric value between 100 and 900, or one of the
817 named weights in @code{font-weight-table}.  If unspecified, a regular font
818 is assumed.
820 @vindex font-slant-table @r{(MS-Windows)}
821 @item slant
822 Specifies whether the font is italic.  Special values
823 @code{roman}, @code{italic} and @code{oblique} can be specified
824 without @code{slant=} (e.g., @kbd{Courier New-12:italic}).
825 Otherwise, the slant should be a numeric value, or one of the named
826 slants in @code{font-slant-table}.  On Windows, any slant above 150 is
827 treated as italics, and anything below as roman.
829 @item family
830 Specifies the font family, but normally this will be specified
831 at the start of the font name.
833 @item pixelsize
834 Specifies the font size in pixels.  This can be used instead
835 of the point size specified after the family name.
837 @item adstyle
838 Specifies additional style information for the font.
839 On MS-Windows, the values @code{mono}, @code{sans}, @code{serif},
840 @code{script} and @code{decorative} are recognized.  These are most useful
841 as a fallback with the font family left unspecified.
843 @vindex w32-charset-info-alist
844 @item registry
845 Specifies the character set registry that the font is
846 expected to cover.  Most Truetype and Opentype fonts will be unicode fonts
847 that cover several national character sets, but you can narrow down the
848 selection of fonts to those that support a particular character set by
849 using a specific registry from @code{w32-charset-info-alist} here.
851 @item spacing
852 Specifies how the font is spaced.  The @code{p} spacing specifies
853 a proportional font, and @code{m} or @code{c} specify a monospaced font.
855 @item foundry
856 Not used on Windows, but for informational purposes and to
857 prevent problems with code that expects it to be set, is set internally to
858 @code{raster} for bitmapped fonts, @code{outline} for scalable fonts,
859 or @code{unknown} if the type cannot be determined as one of those.
860 @end table
862 @cindex font properties (MS Windows gdi backend)
863 Options specific to @code{GDI} fonts:
865 @table @code
867 @cindex font scripts (MS Windows)
868 @cindex font unicode subranges (MS Windows)
869 @item script
870 Specifies a unicode subrange the font should support.
872 The following scripts are recognized on Windows: @code{latin}, @code{greek},
873 @code{coptic}, @code{cyrillic}, @code{armenian}, @code{hebrew}, @code{arabic},
874 @code{syriac}, @code{nko}, @code{thaana}, @code{devanagari}, @code{bengali},
875 @code{gurmukhi}, @code{gujarati}, @code{oriya}, @code{tamil}, @code{telugu},
876 @code{kannada}, @code{malayam}, @code{sinhala}, @code{thai}, @code{lao},
877 @code{tibetan}, @code{myanmar}, @code{georgian}, @code{hangul},
878 @code{ethiopic}, @code{cherokee}, @code{canadian-aboriginal}, @code{ogham},
879 @code{runic}, @code{khmer}, @code{mongolian}, @code{symbol}, @code{braille},
880 @code{han}, @code{ideographic-description}, @code{cjk-misc}, @code{kana},
881 @code{bopomofo}, @code{kanbun}, @code{yi}, @code{byzantine-musical-symbol},
882 @code{musical-symbol}, and @code{mathematical}.
884 @cindex font antialiasing (MS Windows)
885 @item antialias
886 Specifies the antialiasing to use for the font.  The value @code{none}
887 means no antialiasing, @code{standard} means use standard antialiasing,
888 @code{subpixel} means use subpixel antialiasing (known as Cleartype on Windows),
889 and @code{natural} means use subpixel antialiasing with adjusted spacing between
890 letters.  If unspecified, the font will use the system default antialiasing.
891 @end table
893 @node Windows Misc
894 @section Miscellaneous Windows-specific features
896   This section describes miscellaneous Windows-specific features.
898 @vindex w32-use-visible-system-caret
899 @cindex screen reader software, MS-Windows
900   The variable @code{w32-use-visible-system-caret} is a flag that
901 determines whether to make the system caret visible.  The default when
902 no screen reader software is in use is @code{nil}, which means Emacs
903 draws its own cursor to indicate the position of point.  A
904 non-@code{nil} value means Emacs will indicate point location by the
905 system caret; this facilitates use of screen reader software, and is
906 the default when such software is detected when running Emacs.
907 When this variable is non-@code{nil}, other variables affecting the
908 cursor display have no effect.
910 @iftex
911 @inforef{Windows Misc, , emacs}, for information about additional
912 Windows-specific variables in this category.
913 @end iftex
915 @ifnottex
916 @vindex w32-grab-focus-on-raise
917 @cindex frame focus policy, MS-Windows
918   The variable @code{w32-grab-focus-on-raise}, if set to a
919 non-@code{nil} value causes a frame to grab focus when it is raised.
920 The default is @code{t}, which fits well with the Windows default
921 click-to-focus policy.
922 @end ifnottex
924 @ifnottex
925 @include msdog-xtra.texi
926 @end ifnottex
928 @ignore
929    arch-tag: f39d2590-5dcc-4318-88d9-0eb73ca10fa2
930 @end ignore