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