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