Muli Ben-Yehuda's journal

October 10, 2005

adventures with emacs printing

Filed under: Uncategorized — Muli Ben-Yehuda @ 1:24 PM

When I started working at HRL, one of the first things I set up was
printing from Linux. It turned out to be pretty simple: create
postscript, and use a proprietary “pdpr” program on Linux to send the
postscript file to the printer. All was good and well, until while I
was abroad, new printers were installed that didn’t work with pdpr any
more, thus leading me to experiment with printing the modern
way. After installing the necessary packages and running a script to
set everything up (all thoughtfully provided by our system team!)
printing from mozilla, openoffice and the command line worked. I was a
happy camper.

Then I decided to go all the way and get printing from (x)emacs
working directly (rather than C-u M-x ps-print-buffer -> create a .ps
file -> print from the command line). A couple of hours spent
debugging ps-print.el, I had a script called “emacsprint”
which worked. Its contents?

muli@rhun:~$ cat bin/emacsprint

lpr $*

That’s all. Naturally, just calling lpr directly did not work. I
decided to leave it for the night and wait for
inspiration. Inspiration came today.

Compare and contrast:

"lpr" "-P [printername]"


"lpr" "-P[printername]"

If it’s not obvious, consider:

"lpr" "-P" "[printername]"

“-P [printername]” was getting passed to lpr as one argument, rather
than two, which lpr then did not know what to do with. When expanding
it via the wrapper script and $*, it was properly passed as two

Blog at