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