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