]> code.delx.au - gnu-emacs/blob - man/msdog.texi
(Getting Started, Junk, Bug Reports)
[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 MS-DOS, Manifesto, Mac OS, Top
6 @appendix Emacs and Microsoft Systems
7 @cindex MS-DOG
8 @cindex Microsoft Windows
9 @cindex MS-DOS peculiarities
10
11 This section briefly describes the peculiarities of using Emacs on
12 the MS-DOS ``operating system'' (also known as ``MS-DOG'') and on
13 Microsoft Windows.
14
15 If you build Emacs for MS-DOS, the binary will also run on Windows
16 3.X, Windows NT, Windows 9X/ME, Windows 2000, or OS/2 as a DOS
17 application; all the of this chapter applies for all of those systems,
18 if you use an Emacs that was built for MS-DOS.
19
20 However, if you want to use Emacs on Windows, you would normally
21 build Emacs specifically for Windows. If you do that, most of this
22 chapter does not apply; instead, you get behavior much closer to what
23 is documented in the rest of the manual, including support for long
24 file names, multiple frames, scroll bars, mouse menus, and
25 subprocesses. However, the section on text files and binary files
26 does still apply. There are also two sections at the end of this
27 chapter which apply specifically for the Windows version.
28
29 @menu
30 * Keyboard: MS-DOS Keyboard. Keyboard conventions on MS-DOS.
31 * Mouse: MS-DOS Mouse. Mouse conventions on MS-DOS.
32 * Display: MS-DOS Display. Fonts, frames and display size on MS-DOS.
33 * Files: MS-DOS File Names. File name conventions on MS-DOS.
34 * Text and Binary:: Text files on MS-DOS use CRLF to separate lines.
35 * Printing: MS-DOS Printing. How to specify the printer on MS-DOS.
36 * I18N: MS-DOS and MULE. Support for internationalization on MS-DOS.
37 * Processes: MS-DOS Processes. Running subprocesses on MS-DOS.
38 * Windows Processes:: Running subprocesses on Windows.
39 * Windows System Menu:: Controlling what the ALT key does.
40 @end menu
41
42 @node MS-DOS Keyboard
43 @section Keyboard Usage on MS-DOS
44
45 @kindex DEL @r{(MS-DOS)}
46 @kindex BS @r{(MS-DOS)}
47 The key that is called @key{DEL} in Emacs (because that's how it is
48 designated on most workstations) is known as @key{BS} (backspace) on a
49 PC. That is why the PC-specific terminal initialization remaps the
50 @key{BS} key to act as @key{DEL}; the @key{DELETE} key is remapped to act
51 as @kbd{C-d} for the same reasons.
52
53 @kindex C-g @r{(MS-DOS)}
54 @kindex C-BREAK @r{(MS-DOS)}
55 @cindex quitting on MS-DOS
56 Emacs built for MS-DOS recognizes @kbd{C-@key{BREAK}} as a quit
57 character, just like @kbd{C-g}. This is because Emacs cannot detect
58 that you have typed @kbd{C-g} until it is ready for more input. As a
59 consequence, you cannot use @kbd{C-g} to stop a running command
60 (@pxref{Quitting}). By contrast, @kbd{C-@key{BREAK}} @emph{is} detected
61 as soon as you type it (as @kbd{C-g} is on other systems), so it can be
62 used to stop a running command and for emergency escape
63 (@pxref{Emergency Escape}).
64
65 @cindex Meta (under MS-DOS)
66 @cindex Hyper (under MS-DOS)
67 @cindex Super (under MS-DOS)
68 @vindex dos-super-key
69 @vindex dos-hyper-key
70 The PC keyboard maps use the left @key{ALT} key as the @key{META} key.
71 You have two choices for emulating the @key{SUPER} and @key{HYPER} keys:
72 choose either the right @key{CTRL} key or the right @key{ALT} key by
73 setting the variables @code{dos-hyper-key} and @code{dos-super-key} to 1
74 or 2 respectively. If neither @code{dos-super-key} nor
75 @code{dos-hyper-key} is 1, then by default the right @key{ALT} key is
76 also mapped to the @key{META} key. However, if the MS-DOS international
77 keyboard support program @file{KEYB.COM} is installed, Emacs will
78 @emph{not} map the right @key{ALT} to @key{META}, since it is used for
79 accessing characters like @kbd{~} and @kbd{@@} on non-US keyboard
80 layouts; in this case, you may only use the left @key{ALT} as @key{META}
81 key.
82
83 @kindex C-j @r{(MS-DOS)}
84 @vindex dos-keypad-mode
85 The variable @code{dos-keypad-mode} is a flag variable that controls
86 what key codes are returned by keys in the numeric keypad. You can also
87 define the keypad @key{ENTER} key to act like @kbd{C-j}, by putting the
88 following line into your @file{_emacs} file:
89
90 @smallexample
91 ;; @r{Make the @key{ENTER} key from the numeric keypad act as @kbd{C-j}.}
92 (define-key function-key-map [kp-enter] [?\C-j])
93 @end smallexample
94
95 @node MS-DOS Mouse
96 @section Mouse Usage on MS-DOS
97
98 @cindex mouse support under MS-DOS
99 Emacs on MS-DOS supports a mouse (on the default terminal only).
100 The mouse commands work as documented, including those that use menus
101 and the menu bar (@pxref{Menu Bar}). Scroll bars don't work in
102 MS-DOS Emacs. PC mice usually have only two buttons; these act as
103 @kbd{Mouse-1} and @kbd{Mouse-2}, but if you press both of them
104 together, that has the effect of @kbd{Mouse-3}. If the mouse does have
105 3 buttons, Emacs detects that at startup, and all the 3 buttons function
106 normally, as on X.
107
108 Help strings for menu-bar and pop-up menus are displayed in the echo
109 area when the mouse pointer moves across the menu items.
110 Highlighting of mouse-sensitive text (@pxref{Mouse References}) is also
111 supported.
112
113 @cindex mouse, set number of buttons
114 @findex msdos-set-mouse-buttons
115 Some versions of mouse drivers don't report the number of mouse
116 buttons correctly. For example, mice with a wheel report that they
117 have 3 buttons, but only 2 of them are passed to Emacs; the clicks on
118 the wheel, which serves as the middle button, are not passed. In
119 these cases, you can use the @kbd{M-x msdos-set-mouse-buttons} command
120 to tell Emacs how many mouse buttons to expect. You could make such a
121 setting permanent by adding this fragment to your @file{_emacs} init
122 file:
123
124 @example
125 ;; @r{Treat the mouse like a 2-button mouse.}
126 (msdos-set-mouse-buttons 2)
127 @end example
128
129 @cindex Windows clipboard support
130 Emacs built for MS-DOS supports clipboard operations when it runs on
131 Windows. Commands that put text on the kill ring, or yank text from the
132 ring, check the Windows clipboard first, just as Emacs does on the X
133 Window System (@pxref{Mouse Commands}). Only the primary selection and
134 the cut buffer are supported by MS-DOS Emacs on Windows; the secondary
135 selection always appears as empty.
136
137 Due to the way clipboard access is implemented by Windows, the
138 length of text you can put into the clipboard is limited by the amount
139 of free DOS memory that is available to Emacs. Usually, up to 620KB of
140 text can be put into the clipboard, but this limit depends on the system
141 configuration and is lower if you run Emacs as a subprocess of
142 another program. If the killed text does not fit, Emacs outputs a
143 message saying so, and does not put the text into the clipboard.
144
145 Null characters also cannot be put into the Windows clipboard. If the
146 killed text includes null characters, Emacs does not put such text into
147 the clipboard, and displays in the echo area a message to that effect.
148
149 @vindex dos-display-scancodes
150 The variable @code{dos-display-scancodes}, when non-@code{nil},
151 directs Emacs to display the @acronym{ASCII} value and the keyboard scan code of
152 each keystroke; this feature serves as a complement to the
153 @code{view-lossage} command, for debugging.
154
155 @node MS-DOS Display
156 @section Display on MS-DOS
157 @cindex faces under MS-DOS
158 @cindex fonts, emulating under MS-DOS
159
160 Display on MS-DOS cannot use font variants, like bold or italic,
161 but it does support
162 multiple faces, each of which can specify a foreground and a background
163 color. Therefore, you can get the full functionality of Emacs packages
164 that use fonts (such as @code{font-lock}, Enriched Text mode, and
165 others) by defining the relevant faces to use different colors. Use the
166 @code{list-colors-display} command (@pxref{Frame Parameters}) and the
167 @code{list-faces-display} command (@pxref{Faces}) to see what colors and
168 faces are available and what they look like.
169
170 @xref{MS-DOS and MULE}, later in this chapter, for information on
171 how Emacs displays glyphs and characters that aren't supported by the
172 native font built into the DOS display.
173
174 @cindex cursor shape on MS-DOS
175 When Emacs starts, it changes the cursor shape to a solid box. This
176 is for compatibility with other systems, where the box cursor is the
177 default in Emacs. This default shape can be changed to a bar by
178 specifying the @code{cursor-type} parameter in the variable
179 @code{default-frame-alist} (@pxref{Creating Frames}). The MS-DOS
180 terminal doesn't support a vertical-bar cursor, so the bar cursor is
181 horizontal, and the @code{@var{width}} parameter, if specified by the
182 frame parameters, actually determines its height. For this reason,
183 the @code{bar} and @code{hbar} cursor types produce the same effect on
184 MS-DOS. As an extension, the bar cursor specification can include the
185 starting scan line of the cursor as well as its width, like this:
186
187 @example
188 '(cursor-type bar @var{width} . @var{start})
189 @end example
190
191 @noindent
192 In addition, if the @var{width} parameter is negative, the cursor bar
193 begins at the top of the character cell.
194
195 @cindex frames on MS-DOS
196 The MS-DOS terminal can only display a single frame at a time. The
197 Emacs frame facilities work on MS-DOS much as they do on text-only
198 terminals (@pxref{Frames}). When you run Emacs from a DOS window on
199 MS-Windows, you can make the visible frame smaller than the full
200 screen, but Emacs still cannot display more than a single frame at a
201 time.
202
203 @cindex frame size under MS-DOS
204 @findex mode4350
205 @findex mode25
206 The @code{mode4350} command switches the display to 43 or 50
207 lines, depending on your hardware; the @code{mode25} command switches
208 to the default 80x25 screen size.
209
210 By default, Emacs only knows how to set screen sizes of 80 columns by
211 25, 28, 35, 40, 43 or 50 rows. However, if your video adapter has
212 special video modes that will switch the display to other sizes, you can
213 have Emacs support those too. When you ask Emacs to switch the frame to
214 @var{n} rows by @var{m} columns dimensions, it checks if there is a
215 variable called @code{screen-dimensions-@var{n}x@var{m}}, and if so,
216 uses its value (which must be an integer) as the video mode to switch
217 to. (Emacs switches to that video mode by calling the BIOS @code{Set
218 Video Mode} function with the value of
219 @code{screen-dimensions-@var{n}x@var{m}} in the @code{AL} register.)
220 For example, suppose your adapter will switch to 66x80 dimensions when
221 put into video mode 85. Then you can make Emacs support this screen
222 size by putting the following into your @file{_emacs} file:
223
224 @example
225 (setq screen-dimensions-66x80 85)
226 @end example
227
228 Since Emacs on MS-DOS can only set the frame size to specific
229 supported dimensions, it cannot honor every possible frame resizing
230 request. When an unsupported size is requested, Emacs chooses the next
231 larger supported size beyond the specified size. For example, if you
232 ask for 36x80 frame, you will get 40x80 instead.
233
234 The variables @code{screen-dimensions-@var{n}x@var{m}} are used only
235 when they exactly match the specified size; the search for the next
236 larger supported size ignores them. In the above example, even if your
237 VGA supports 38x80 dimensions and you define a variable
238 @code{screen-dimensions-38x80} with a suitable value, you will still get
239 40x80 screen when you ask for a 36x80 frame. If you want to get the
240 38x80 size in this case, you can do it by setting the variable named
241 @code{screen-dimensions-36x80} with the same video mode value as
242 @code{screen-dimensions-38x80}.
243
244 Changing frame dimensions on MS-DOS has the effect of changing all the
245 other frames to the new dimensions.
246
247 @node MS-DOS File Names
248 @section File Names on MS-DOS
249 @cindex file names under MS-DOS
250 @cindex init file, default name under MS-DOS
251
252 MS-DOS normally uses a backslash, @samp{\}, to separate name units
253 within a file name, instead of the slash used on other systems. Emacs
254 on MS-DOS permits use of either slash or backslash, and also knows
255 about drive letters in file names.
256
257 On MS-DOS, file names are case-insensitive and limited to eight
258 characters, plus optionally a period and three more characters. Emacs
259 knows enough about these limitations to handle file names that were
260 meant for other operating systems. For instance, leading dots @samp{.}
261 in file names are invalid in MS-DOS, so Emacs transparently converts
262 them to underscores @samp{_}; thus your default init file (@pxref{Init
263 File}) is called @file{_emacs} on MS-DOS. Excess characters before or
264 after the period are generally ignored by MS-DOS itself; thus, if you
265 visit the file @file{LongFileName.EvenLongerExtension}, you will
266 silently get @file{longfile.eve}, but Emacs will still display the long
267 file name on the mode line. Other than that, it's up to you to specify
268 file names which are valid under MS-DOS; the transparent conversion as
269 described above only works on file names built into Emacs.
270
271 @cindex backup file names on MS-DOS
272 The above restrictions on the file names on MS-DOS make it almost
273 impossible to construct the name of a backup file (@pxref{Backup
274 Names}) without losing some of the original file name characters. For
275 example, the name of a backup file for @file{docs.txt} is
276 @file{docs.tx~} even if single backup is used.
277
278 @cindex file names under Windows 95/NT
279 @cindex long file names in DOS box under Windows 95/NT
280 If you run Emacs as a DOS application under Windows 9X, Windows ME, or
281 Windows 2000, you can turn on support for long file names. If you do
282 that, Emacs doesn't truncate file names or convert them to lower case;
283 instead, it uses the file names that you specify, verbatim. To enable
284 long file name support, set the environment variable @env{LFN} to
285 @samp{y} before starting Emacs. Unfortunately, Windows NT doesn't allow
286 DOS programs to access long file names, so Emacs built for MS-DOS will
287 only see their short 8+3 aliases.
288
289 @cindex @env{HOME} directory under MS-DOS
290 MS-DOS has no notion of home directory, so Emacs on MS-DOS pretends
291 that the directory where it is installed is the value of the @env{HOME}
292 environment variable. That is, if your Emacs binary,
293 @file{emacs.exe}, is in the directory @file{c:/utils/emacs/bin}, then
294 Emacs acts as if @env{HOME} were set to @samp{c:/utils/emacs}. In
295 particular, that is where Emacs looks for the init file @file{_emacs}.
296 With this in mind, you can use @samp{~} in file names as an alias for
297 the home directory, as you would on GNU or Unix. You can also set
298 @env{HOME} variable in the environment before starting Emacs; its
299 value will then override the above default behavior.
300
301 Emacs on MS-DOS handles the directory name @file{/dev} specially,
302 because of a feature in the emulator libraries of DJGPP that pretends
303 I/O devices have names in that directory. We recommend that you avoid
304 using an actual directory named @file{/dev} on any disk.
305
306 @node Text and Binary
307 @section Text Files and Binary Files
308 @cindex text and binary files on MS-DOS/MS-Windows
309
310 GNU Emacs uses newline characters to separate text lines. This is the
311 convention used on GNU and Unix.
312
313 @cindex end-of-line conversion on MS-DOS/MS-Windows
314 MS-DOS and MS-Windows normally use carriage-return linefeed, a
315 two-character sequence, to separate text lines. (Linefeed is the same
316 character as newline.) Therefore, convenient editing of typical files
317 with Emacs requires conversion of these end-of-line (EOL) sequences.
318 And that is what Emacs normally does: it converts carriage-return
319 linefeed into newline when reading files, and converts newline into
320 carriage-return linefeed when writing files. The same mechanism that
321 handles conversion of international character codes does this conversion
322 also (@pxref{Coding Systems}).
323
324 @cindex cursor location, on MS-DOS
325 @cindex point location, on MS-DOS
326 One consequence of this special format-conversion of most files is
327 that character positions as reported by Emacs (@pxref{Position Info}) do
328 not agree with the file size information known to the operating system.
329
330 In addition, if Emacs recognizes from a file's contents that it uses
331 newline rather than carriage-return linefeed as its line separator, it
332 does not perform EOL conversion when reading or writing that file.
333 Thus, you can read and edit files from GNU and Unix systems on MS-DOS
334 with no special effort, and they will retain their Unix-style
335 end-of-line convention after you edit them.
336
337 The mode line indicates whether end-of-line translation was used for
338 the current buffer. If MS-DOS end-of-line translation is in use for the
339 buffer, a backslash @samp{\} is displayed after the coding system
340 mnemonic near the beginning of the mode line (@pxref{Mode Line}). If no
341 EOL translation was performed, the string @samp{(Unix)} is displayed
342 instead of the backslash, to alert you that the file's EOL format is not
343 the usual carriage-return linefeed.
344
345 @cindex DOS-to-Unix conversion of files
346 To visit a file and specify whether it uses DOS-style or Unix-style
347 end-of-line, specify a coding system (@pxref{Text Coding}). For
348 example, @kbd{C-x @key{RET} c unix @key{RET} C-x C-f foobar.txt}
349 visits the file @file{foobar.txt} without converting the EOLs; if some
350 line ends with a carriage-return linefeed pair, Emacs will display
351 @samp{^M} at the end of that line. Similarly, you can direct Emacs to
352 save a buffer in a specified EOL format with the @kbd{C-x @key{RET} f}
353 command. For example, to save a buffer with Unix EOL format, type
354 @kbd{C-x @key{RET} f unix @key{RET} C-x C-s}. If you visit a file
355 with DOS EOL conversion, then save it with Unix EOL format, that
356 effectively converts the file to Unix EOL style, like @code{dos2unix}.
357
358 @cindex untranslated file system
359 @findex add-untranslated-filesystem
360 When you use NFS or Samba to access file systems that reside on
361 computers using GNU or Unix systems, Emacs should not perform
362 end-of-line translation on any files in these file systems---not even
363 when you create a new file. To request this, designate these file
364 systems as @dfn{untranslated} file systems by calling the function
365 @code{add-untranslated-filesystem}. It takes one argument: the file
366 system name, including a drive letter and optionally a directory. For
367 example,
368
369 @example
370 (add-untranslated-filesystem "Z:")
371 @end example
372
373 @noindent
374 designates drive Z as an untranslated file system, and
375
376 @example
377 (add-untranslated-filesystem "Z:\\foo")
378 @end example
379
380 @noindent
381 designates directory @file{\foo} on drive Z as an untranslated file
382 system.
383
384 Most often you would use @code{add-untranslated-filesystem} in your
385 @file{_emacs} file, or in @file{site-start.el} so that all the users at
386 your site get the benefit of it.
387
388 @findex remove-untranslated-filesystem
389 To countermand the effect of @code{add-untranslated-filesystem}, use
390 the function @code{remove-untranslated-filesystem}. This function takes
391 one argument, which should be a string just like the one that was used
392 previously with @code{add-untranslated-filesystem}.
393
394 Designating a file system as untranslated does not affect character
395 set conversion, only end-of-line conversion. Essentially, it directs
396 Emacs to create new files with the Unix-style convention of using
397 newline at the end of a line. @xref{Coding Systems}.
398
399 @vindex file-name-buffer-file-type-alist
400 @cindex binary files, on MS-DOS/MS-Windows
401 Some kinds of files should not be converted at all, because their
402 contents are not really text. Therefore, Emacs on MS-DOS distinguishes
403 certain files as @dfn{binary files}. (This distinction is not part of
404 MS-DOS; it is made by Emacs only.) Binary files include executable
405 programs, compressed archives, etc. Emacs uses the file name to decide
406 whether to treat a file as binary: the variable
407 @code{file-name-buffer-file-type-alist} defines the file-name patterns
408 that indicate binary files. If a file name matches one of the patterns
409 for binary files (those whose associations are of the type
410 @code{(@var{pattern} . t)}, Emacs reads and writes that file using the
411 @code{no-conversion} coding system (@pxref{Coding Systems}) which turns
412 off @emph{all} coding-system conversions, not only the EOL conversion.
413 @code{file-name-buffer-file-type-alist} also includes file-name patterns
414 for files which are known to be DOS-style text files with
415 carriage-return linefeed EOL format, such as @file{CONFIG.SYS}; Emacs
416 always writes those files with DOS-style EOLs.
417
418 If a file which belongs to an untranslated file system matches one of
419 the file-name patterns in @code{file-name-buffer-file-type-alist}, the
420 EOL conversion is determined by @code{file-name-buffer-file-type-alist}.
421
422 @node MS-DOS Printing
423 @section Printing and MS-DOS
424
425 Printing commands, such as @code{lpr-buffer} (@pxref{Printing}) and
426 @code{ps-print-buffer} (@pxref{PostScript}) can work in MS-DOS and
427 MS-Windows by sending the output to one of the printer ports, if a
428 Posix-style @code{lpr} program is unavailable. The same Emacs
429 variables control printing on all systems, but in some cases they have
430 different default values on MS-DOS and MS-Windows.
431
432 @vindex printer-name @r{(MS-DOS)}
433 If you want to use your local printer, printing on it in the usual DOS
434 manner, then set the Lisp variable @code{lpr-command} to @code{""} (its
435 default value) and @code{printer-name} to the name of the printer
436 port---for example, @code{"PRN"}, the usual local printer port (that's
437 the default), or @code{"LPT2"}, or @code{"COM1"} for a serial printer.
438 You can also set @code{printer-name} to a file name, in which case
439 ``printed'' output is actually appended to that file. If you set
440 @code{printer-name} to @code{"NUL"}, printed output is silently
441 discarded (sent to the system null device).
442
443 On MS-Windows, when the Windows network software is installed, you can
444 also use a printer shared by another machine by setting
445 @code{printer-name} to the UNC share name for that printer---for example,
446 @code{"//joes_pc/hp4si"}. (It doesn't matter whether you use forward
447 slashes or backslashes here.) To find out the names of shared printers,
448 run the command @samp{net view} at a DOS command prompt to obtain a list
449 of servers, and @samp{net view @var{server-name}} to see the names of printers
450 (and directories) shared by that server. Alternatively, click the
451 @samp{Network Neighborhood} icon on your desktop, and look for machines
452 which share their printers via the network.
453
454 @cindex @samp{net use}, and printing on MS-Windows
455 @cindex networked printers (MS-Windows)
456 If the printer doesn't appear in the output of @samp{net view}, or
457 if setting @code{printer-name} to the UNC share name doesn't produce a
458 hardcopy on that printer, you can use the @samp{net use} command to
459 connect a local print port such as @code{"LPT2"} to the networked
460 printer. For example, typing @kbd{net use LPT2:
461 \\joes_pc\hp4si}@footnote{
462 Note that the @samp{net use} command requires the UNC share name to be
463 typed with the Windows-style backslashes, while the value of
464 @code{printer-name} can be set with either forward- or backslashes.}
465 causes Windows to @dfn{capture} the LPT2 port and redirect the printed
466 material to the printer connected to the machine @code{joes_pc}.
467 After this command, setting @code{printer-name} to @code{"LPT2"}
468 should produce the hardcopy on the networked printer.
469
470 With some varieties of Windows network software, you can instruct
471 Windows to capture a specific printer port such as @code{"LPT2"}, and
472 redirect it to a networked printer via the @w{@code{Control
473 Panel->Printers}} applet instead of @samp{net use}.
474
475 Some printers expect DOS codepage encoding of non-@acronym{ASCII} text, even
476 though they are connected to a Windows machine which uses a different
477 encoding for the same locale. For example, in the Latin-1 locale, DOS
478 uses codepage 850 whereas Windows uses codepage 1252. @xref{MS-DOS and
479 MULE}. When you print to such printers from Windows, you can use the
480 @kbd{C-x RET c} (@code{universal-coding-system-argument}) command before
481 @kbd{M-x lpr-buffer}; Emacs will then convert the text to the DOS
482 codepage that you specify. For example, @kbd{C-x RET c cp850-dos RET
483 M-x lpr-region RET} will print the region while converting it to the
484 codepage 850 encoding. You may need to create the @code{cp@var{nnn}}
485 coding system with @kbd{M-x codepage-setup}.
486
487 If you set @code{printer-name} to a file name, it's best to use an
488 absolute file name. Emacs changes the working directory according to
489 the default directory of the current buffer, so if the file name in
490 @code{printer-name} is relative, you will end up with several such
491 files, each one in the directory of the buffer from which the printing
492 was done.
493
494 @findex print-buffer @r{(MS-DOS)}
495 @findex print-region @r{(MS-DOS)}
496 @vindex lpr-headers-switches @r{(MS-DOS)}
497 The commands @code{print-buffer} and @code{print-region} call the
498 @code{pr} program, or use special switches to the @code{lpr} program, to
499 produce headers on each printed page. MS-DOS and MS-Windows don't
500 normally have these programs, so by default, the variable
501 @code{lpr-headers-switches} is set so that the requests to print page
502 headers are silently ignored. Thus, @code{print-buffer} and
503 @code{print-region} produce the same output as @code{lpr-buffer} and
504 @code{lpr-region}, respectively. If you do have a suitable @code{pr}
505 program (for example, from GNU Textutils), set
506 @code{lpr-headers-switches} to @code{nil}; Emacs will then call
507 @code{pr} to produce the page headers, and print the resulting output as
508 specified by @code{printer-name}.
509
510 @vindex print-region-function @r{(MS-DOS)}
511 @cindex lpr usage under MS-DOS
512 @vindex lpr-command @r{(MS-DOS)}
513 @vindex lpr-switches @r{(MS-DOS)}
514 Finally, if you do have an @code{lpr} work-alike, you can set the
515 variable @code{lpr-command} to @code{"lpr"}. Then Emacs will use
516 @code{lpr} for printing, as on other systems. (If the name of the
517 program isn't @code{lpr}, set @code{lpr-command} to specify where to
518 find it.) The variable @code{lpr-switches} has its standard meaning
519 when @code{lpr-command} is not @code{""}. If the variable
520 @code{printer-name} has a string value, it is used as the value for the
521 @code{-P} option to @code{lpr}, as on Unix.
522
523 @findex ps-print-buffer @r{(MS-DOS)}
524 @findex ps-spool-buffer @r{(MS-DOS)}
525 @vindex ps-printer-name @r{(MS-DOS)}
526 @vindex ps-lpr-command @r{(MS-DOS)}
527 @vindex ps-lpr-switches @r{(MS-DOS)}
528 A parallel set of variables, @code{ps-lpr-command},
529 @code{ps-lpr-switches}, and @code{ps-printer-name} (@pxref{PostScript
530 Variables}), defines how PostScript files should be printed. These
531 variables are used in the same way as the corresponding variables
532 described above for non-PostScript printing. Thus, the value of
533 @code{ps-printer-name} is used as the name of the device (or file) to
534 which PostScript output is sent, just as @code{printer-name} is used for
535 non-PostScript printing. (There are two distinct sets of variables in
536 case you have two printers attached to two different ports, and only one
537 of them is a PostScript printer.)
538
539 The default value of the variable @code{ps-lpr-command} is @code{""},
540 which causes PostScript output to be sent to the printer port specified
541 by @code{ps-printer-name}, but @code{ps-lpr-command} can also be set to
542 the name of a program which will accept PostScript files. Thus, if you
543 have a non-PostScript printer, you can set this variable to the name of
544 a PostScript interpreter program (such as Ghostscript). Any switches
545 that need to be passed to the interpreter program are specified using
546 @code{ps-lpr-switches}. (If the value of @code{ps-printer-name} is a
547 string, it will be added to the list of switches as the value for the
548 @code{-P} option. This is probably only useful if you are using
549 @code{lpr}, so when using an interpreter typically you would set
550 @code{ps-printer-name} to something other than a string so it is
551 ignored.)
552
553 For example, to use Ghostscript for printing on an Epson printer
554 connected to the @samp{LPT2} port, put this in your @file{_emacs} file:
555
556 @example
557 (setq ps-printer-name t) ; Ghostscript doesn't understand -P
558 (setq ps-lpr-command "c:/gs/gs386")
559 (setq ps-lpr-switches '("-q" "-dNOPAUSE"
560 "-sDEVICE=epson"
561 "-r240x72"
562 "-sOutputFile=LPT2"
563 "-Ic:/gs"))
564 @end example
565
566 @noindent
567 (This assumes that Ghostscript is installed in the @file{"c:/gs"}
568 directory.)
569
570 @vindex dos-printer
571 @vindex dos-ps-printer
572 For backwards compatibility, the value of @code{dos-printer}
573 (@code{dos-ps-printer}), if it has a value, overrides the value of
574 @code{printer-name} (@code{ps-printer-name}), on MS-DOS and MS-Windows
575 only.
576
577
578 @node MS-DOS and MULE
579 @section International Support on MS-DOS
580 @cindex international support @r{(MS-DOS)}
581
582 Emacs on MS-DOS supports the same international character sets as it
583 does on GNU, Unix and other platforms (@pxref{International}), including
584 coding systems for converting between the different character sets.
585 However, due to incompatibilities between MS-DOS/MS-Windows and other systems,
586 there are several DOS-specific aspects of this support that you should
587 be aware of. This section describes these aspects.
588
589 The description below is largely specific to the MS-DOS port of
590 Emacs, especially where it talks about practical implications for
591 Emacs users. For other operating systems, see the @file{code-pages.el}
592 package, which implements support for MS-DOS- and MS-Windows-specific
593 encodings for all platforms other than MS-DOS.
594
595 @table @kbd
596 @item M-x dos-codepage-setup
597 Set up Emacs display and coding systems as appropriate for the current
598 DOS codepage.
599
600 @item M-x codepage-setup
601 Create a coding system for a certain DOS codepage.
602 @end table
603
604 @cindex codepage, MS-DOS
605 @cindex DOS codepages
606 MS-DOS is designed to support one character set of 256 characters at
607 any given time, but gives you a variety of character sets to choose
608 from. The alternative character sets are known as @dfn{DOS codepages}.
609 Each codepage includes all 128 @acronym{ASCII} characters, but the other 128
610 characters (codes 128 through 255) vary from one codepage to another.
611 Each DOS codepage is identified by a 3-digit number, such as 850, 862,
612 etc.
613
614 In contrast to X, which lets you use several fonts at the same time,
615 MS-DOS normally doesn't allow use of several codepages in a single
616 session. MS-DOS was designed to load a single codepage at system
617 startup, and require you to reboot in order to change
618 it@footnote{Normally, one particular codepage is burnt into the
619 display memory, while other codepages can be installed by modifying
620 system configuration files, such as @file{CONFIG.SYS}, and rebooting.
621 While there is third-party software that allows changing the codepage
622 without rebooting, we describe here how a stock MS-DOS system
623 behaves.}. Much the same limitation applies when you run DOS
624 executables on other systems such as MS-Windows.
625
626 @cindex unibyte operation @r{(MS-DOS)}
627 If you invoke Emacs on MS-DOS with the @samp{--unibyte} option
628 (@pxref{Initial Options}), Emacs does not perform any conversion of
629 non-@acronym{ASCII} characters. Instead, it reads and writes any non-@acronym{ASCII}
630 characters verbatim, and sends their 8-bit codes to the display
631 verbatim. Thus, unibyte Emacs on MS-DOS supports the current codepage,
632 whatever it may be, but cannot even represent any other characters.
633
634 @vindex dos-codepage
635 For multibyte operation on MS-DOS, Emacs needs to know which
636 characters the chosen DOS codepage can display. So it queries the
637 system shortly after startup to get the chosen codepage number, and
638 stores the number in the variable @code{dos-codepage}. Some systems
639 return the default value 437 for the current codepage, even though the
640 actual codepage is different. (This typically happens when you use the
641 codepage built into the display hardware.) You can specify a different
642 codepage for Emacs to use by setting the variable @code{dos-codepage} in
643 your init file.
644
645 @cindex language environment, automatic selection on @r{MS-DOS}
646 Multibyte Emacs supports only certain DOS codepages: those which can
647 display Far-Eastern scripts, like the Japanese codepage 932, and those
648 that encode a single ISO 8859 character set.
649
650 The Far-Eastern codepages can directly display one of the MULE
651 character sets for these countries, so Emacs simply sets up to use the
652 appropriate terminal coding system that is supported by the codepage.
653 The special features described in the rest of this section mostly
654 pertain to codepages that encode ISO 8859 character sets.
655
656 For the codepages which correspond to one of the ISO character sets,
657 Emacs knows the character set name based on the codepage number. Emacs
658 automatically creates a coding system to support reading and writing
659 files that use the current codepage, and uses this coding system by
660 default. The name of this coding system is @code{cp@var{nnn}}, where
661 @var{nnn} is the codepage number.@footnote{The standard Emacs coding
662 systems for ISO 8859 are not quite right for the purpose, because
663 typically the DOS codepage does not match the standard ISO character
664 codes. For example, the letter @samp{@,{c}} (@samp{c} with cedilla) has
665 code 231 in the standard Latin-1 character set, but the corresponding
666 DOS codepage 850 uses code 135 for this glyph.}
667
668 @cindex mode line @r{(MS-DOS)}
669 All the @code{cp@var{nnn}} coding systems use the letter @samp{D} (for
670 ``DOS'') as their mode-line mnemonic. Since both the terminal coding
671 system and the default coding system for file I/O are set to the proper
672 @code{cp@var{nnn}} coding system at startup, it is normal for the mode
673 line on MS-DOS to begin with @samp{-DD\-}. @xref{Mode Line}.
674 Far-Eastern DOS terminals do not use the @code{cp@var{nnn}} coding
675 systems, and thus their initial mode line looks like the Emacs default.
676
677 Since the codepage number also indicates which script you are using,
678 Emacs automatically runs @code{set-language-environment} to select the
679 language environment for that script (@pxref{Language Environments}).
680
681 If a buffer contains a character belonging to some other ISO 8859
682 character set, not the one that the chosen DOS codepage supports, Emacs
683 displays it using a sequence of @acronym{ASCII} characters. For example, if the
684 current codepage doesn't have a glyph for the letter @samp{@`o} (small
685 @samp{o} with a grave accent), it is displayed as @samp{@{`o@}}, where
686 the braces serve as a visual indication that this is a single character.
687 (This may look awkward for some non-Latin characters, such as those from
688 Greek or Hebrew alphabets, but it is still readable by a person who
689 knows the language.) Even though the character may occupy several
690 columns on the screen, it is really still just a single character, and
691 all Emacs commands treat it as one.
692
693 @cindex IBM graphics characters (MS-DOS)
694 @cindex box-drawing characters (MS-DOS)
695 @cindex line-drawing characters (MS-DOS)
696 Not all characters in DOS codepages correspond to ISO 8859
697 characters---some are used for other purposes, such as box-drawing
698 characters and other graphics. Emacs maps these characters to two
699 special character sets called @code{eight-bit-control} and
700 @code{eight-bit-graphic}, and displays them as their IBM glyphs.
701 However, you should be aware that other systems might display these
702 characters differently, so you should avoid them in text that might be
703 copied to a different operating system, or even to another DOS machine
704 that uses a different codepage.
705
706 @vindex dos-unsupported-character-glyph
707 Emacs supports many other characters sets aside from ISO 8859, but it
708 cannot display them on MS-DOS. So if one of these multibyte characters
709 appears in a buffer, Emacs on MS-DOS displays them as specified by the
710 @code{dos-unsupported-character-glyph} variable; by default, this glyph
711 is an empty triangle. Use the @kbd{C-u C-x =} command to display the
712 actual code and character set of such characters. @xref{Position Info}.
713
714 @findex codepage-setup
715 By default, Emacs defines a coding system to support the current
716 codepage. To define a coding system for some other codepage (e.g., to
717 visit a file written on a DOS machine in another country), use the
718 @kbd{M-x codepage-setup} command. It prompts for the 3-digit code of
719 the codepage, with completion, then creates the coding system for the
720 specified codepage. You can then use the new coding system to read and
721 write files, but you must specify it explicitly for the file command
722 when you want to use it (@pxref{Text Coding}).
723
724 These coding systems are also useful for visiting a file encoded using
725 a DOS codepage, using Emacs running on some other operating system.
726
727 @cindex MS-Windows codepages
728 MS-Windows provides its own codepages, which are different from the
729 DOS codepages for the same locale. For example, DOS codepage 850
730 supports the same character set as Windows codepage 1252; DOS codepage
731 855 supports the same character set as Windows codepage 1251, etc.
732 The MS-Windows version of Emacs uses the current codepage for display
733 when invoked with the @samp{-nw} option. Support for codepages in the
734 Windows port of Emacs is part of the @file{code-pages.el} package.
735
736 @node MS-DOS Processes
737 @section Subprocesses on MS-DOS
738
739 @cindex compilation under MS-DOS
740 @cindex inferior processes under MS-DOS
741 @findex compile @r{(MS-DOS)}
742 @findex grep @r{(MS-DOS)}
743 Because MS-DOS is a single-process ``operating system,''
744 asynchronous subprocesses are not available. In particular, Shell
745 mode and its variants do not work. Most Emacs features that use
746 asynchronous subprocesses also don't work on MS-DOS, including
747 Shell mode and GUD. When in doubt, try and see; commands that
748 don't work output an error message saying that asynchronous processes
749 aren't supported.
750
751 Compilation under Emacs with @kbd{M-x compile}, searching files with
752 @kbd{M-x grep} and displaying differences between files with @kbd{M-x
753 diff} do work, by running the inferior processes synchronously. This
754 means you cannot do any more editing until the inferior process
755 finishes.
756
757 Spell checking also works, by means of special support for synchronous
758 invocation of the @code{ispell} program. This is slower than the
759 asynchronous invocation on other platforms
760
761 Instead of the Shell mode, which doesn't work on MS-DOS, you can use
762 the @kbd{M-x eshell} command. This invokes the Eshell package that
763 implements a Posix-like shell entirely in Emacs Lisp.
764
765 By contrast, Emacs compiled as a native Windows application
766 @strong{does} support asynchronous subprocesses. @xref{Windows
767 Processes}.
768
769 @cindex printing under MS-DOS
770 Printing commands, such as @code{lpr-buffer} (@pxref{Printing}) and
771 @code{ps-print-buffer} (@pxref{PostScript}), work in MS-DOS by sending
772 the output to one of the printer ports. @xref{MS-DOS Printing}.
773
774 When you run a subprocess synchronously on MS-DOS, make sure the
775 program terminates and does not try to read keyboard input. If the
776 program does not terminate on its own, you will be unable to terminate
777 it, because MS-DOS provides no general way to terminate a process.
778 Pressing @kbd{C-c} or @kbd{C-@key{BREAK}} might sometimes help in these
779 cases.
780
781 Accessing files on other machines is not supported on MS-DOS. Other
782 network-oriented commands such as sending mail, Web browsing, remote
783 login, etc., don't work either, unless network access is built into
784 MS-DOS with some network redirector.
785
786 @cindex directory listing on MS-DOS
787 @vindex dired-listing-switches @r{(MS-DOS)}
788 Dired on MS-DOS uses the @code{ls-lisp} package where other
789 platforms use the system @code{ls} command. Therefore, Dired on
790 MS-DOS supports only some of the possible options you can mention in
791 the @code{dired-listing-switches} variable. The options that work are
792 @samp{-A}, @samp{-a}, @samp{-c}, @samp{-i}, @samp{-r}, @samp{-S},
793 @samp{-s}, @samp{-t}, and @samp{-u}.
794
795 @node Windows Processes
796 @section Subprocesses on Windows 9X/ME and Windows NT/2K
797
798 Emacs compiled as a native Windows application (as opposed to the DOS
799 version) includes full support for asynchronous subprocesses.
800 In the Windows version, synchronous and asynchronous subprocesses work
801 fine on both
802 Windows 9X and Windows NT/2K as long as you run only 32-bit Windows
803 applications. However, when you run a DOS application in a subprocess,
804 you may encounter problems or be unable to run the application at all;
805 and if you run two DOS applications at the same time in two
806 subprocesses, you may have to reboot your system.
807
808 Since the standard command interpreter (and most command line utilities)
809 on Windows 95 are DOS applications, these problems are significant when
810 using that system. But there's nothing we can do about them; only
811 Microsoft can fix them.
812
813 If you run just one DOS application subprocess, the subprocess should
814 work as expected as long as it is ``well-behaved'' and does not perform
815 direct screen access or other unusual actions. If you have a CPU
816 monitor application, your machine will appear to be 100% busy even when
817 the DOS application is idle, but this is only an artifact of the way CPU
818 monitors measure processor load.
819
820 You must terminate the DOS application before you start any other DOS
821 application in a different subprocess. Emacs is unable to interrupt or
822 terminate a DOS subprocess. The only way you can terminate such a
823 subprocess is by giving it a command that tells its program to exit.
824
825 If you attempt to run two DOS applications at the same time in separate
826 subprocesses, the second one that is started will be suspended until the
827 first one finishes, even if either or both of them are asynchronous.
828
829 If you can go to the first subprocess, and tell it to exit, the second
830 subprocess should continue normally. However, if the second subprocess
831 is synchronous, Emacs itself will be hung until the first subprocess
832 finishes. If it will not finish without user input, then you have no
833 choice but to reboot if you are running on Windows 9X. If you are
834 running on Windows NT/2K, you can use a process viewer application to kill
835 the appropriate instance of ntvdm instead (this will terminate both DOS
836 subprocesses).
837
838 If you have to reboot Windows 9X in this situation, do not use the
839 @code{Shutdown} command on the @code{Start} menu; that usually hangs the
840 system. Instead, type @kbd{CTL-ALT-@key{DEL}} and then choose
841 @code{Shutdown}. That usually works, although it may take a few minutes
842 to do its job.
843
844 @node Windows System Menu
845 @section Using the System Menu on Windows
846
847 Emacs compiled as a native Windows application normally turns off the
848 Windows feature that tapping the @key{ALT}
849 key invokes the Windows menu. The reason is that the @key{ALT} also
850 serves as @key{META} in Emacs. When using Emacs, users often press the
851 @key{META} key temporarily and then change their minds; if this has the
852 effect of bringing up the Windows menu, it alters the meaning of
853 subsequent commands. Many users find this frustrating.
854
855 @vindex w32-pass-alt-to-system
856 You can re-enable Windows' default handling of tapping the @key{ALT} key
857 by setting @code{w32-pass-alt-to-system} to a non-@code{nil} value.
858
859 @ignore
860 arch-tag: f39d2590-5dcc-4318-88d9-0eb73ca10fa2
861 @end ignore