skip to content

Emacs Printing

Emacs has two Print commands in its File menu.

  • "Print Buffer" will print the current buffer (i.e. the file you are editing) as a plain text file, with a text header on each page giving the date and the name of the file.
  • "Postscript Print Buffer" will "pretty-print" the buffer - the header is a banner and the highlighting shown on the screen will be replicated in the output.

Choosing a different printer

To set the printer name variable in a running emacs:

M-x set-variable<RET>

You might also want to set ps-printer-name if you are using the ps-print* commands.

Note: This page uses the standard abbreviations for emacs commands. C-char means Ctrl-char. M-x means Meta-char, which under XUbuntu/X will usually be Alt-char unless you have odd settings, in which case pressing Esc followed by "char" will work.

Checking the resulting postscript

For each ps-print-... command there is a ps-spool-... command, which saves the resulting ps to an emacs buffer, which you can then examine/save/print as you like. e.g.


enter M-x (meta-X), and enter: ps-spool-buffer-with-faces


this will create a buffer called '*PostScript*' which you can switch to, save etc.


Possibly more practically you can tell ps-print-buffer* to save to a file by setting a prefix-argument (it will prompt for the filename), e.g. you would type something like:


C-u M-x ps-print-buffer-with-faces


it will prompt with:


Save PostScript to file: ...


you enter the filename and it will save it. Many interactive commands behave differently when given a 'prefix argument' (with C-u).


Further information in the emacs online manual.