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