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