Go to the first, previous, next, last section, table of contents.

Printing and MS-DOS

Printing commands, such as lpr-buffer (see section Hardcopy Output) and ps-print-buffer (see section Postscript Hardcopy) can work in MS-DOS by sending the output to one of the printer ports, if a Unix-style lpr program is unavailable. A few DOS-specific variables control how this works.

If you want to use your local printer, printing on it in the usual DOS manner, then set the Lisp variable dos-printer to the name of the printer port--for example, "PRN", the usual local printer port (that's the default), or "LPT2" or "COM1" for a serial printer. You can also set dos-printer to a file name, in which case "printed" output is actually appended to that file. If you set dos-printer to "NUL", printed output is silently discarded (sent to the system null device).

If you set dos-printer to a file name, it's best to use an absolute file name. Emacs changes the working directory according to the default directory of the current buffer, so if the file name in dos-printer is relative, you will end up with several such files, each one in the directory of the buffer from which the printing was done.

The commands print-buffer and print-region call the pr program, or use special switches to the lpr program, to produce headers on each printed page. MS-DOS doesn't normally have these programs, so by default, the variable lpr-headers-switches is set so that the requests to print page headers are silently ignored. Thus, print-buffer and print-region produce the same output as lpr-buffer and lpr-region, respectively. If you do have a suitable pr program (for example, from GNU Textutils), set lpr-headers-switches to nil; Emacs will then call pr to produce the page headers, and print the resulting output as specified by dos-printer.

Finally, if you do have an lpr work-alike, you can set print-region-function to nil. Then Emacs uses lpr for printing, as on other systems. (If the name of the program isn't lpr, set the lpr-command variable to specify where to find it.)

A separate variable, dos-ps-printer, defines how PostScript files should be printed. If its value is a string, it is used as the name of the device (or file) to which PostScript output is sent, just as dos-printer is used for non-PostScript printing. (These are two distinct variables in case you have two printers attached to two different ports, and only one of them is a PostScript printer.) If the value of dos-ps-printer is not a string, then the variables ps-lpr-command and ps-lpr-switches (see section Postscript Hardcopy) control how to print PostScript files. Thus, if you have a non-PostScript printer, you can set these variables to the name and the switches appropriate for a PostScript interpreter program (such as Ghostscript).

For example, to use Ghostscript for printing on an Epson printer connected to `LPT2' port, put this on your `.emacs' file:

(setq dos-ps-printer t)  ; Anything but a string.
(setq ps-lpr-command "c:/gs/gs386")
(setq ps-lpr-switches '("-q" "-dNOPAUSE"

(This assumes that Ghostscript is installed in the `"c:/gs"' directory.)

Go to the first, previous, next, last section, table of contents.