Subject: NT Printing problem solved.

From: Anders Lindgren <[email-masked]>
Date: 03 Feb 1998 11:02:54 +0100

Hi!

Until now, there has been no satisfactory solution on how to print
from NT-Emacs.

Several attempts have been made, they can be categorized into two
groups:

* Defining a new set of commands used to print.

* Creating a "lpr" command in some language (like perl or unix shells)
  that is not present in a pure Windows + Emacs environment.

The first solution will fail since quite a few third-party packages
use the standard printing functions.  The second is not very practical
since most users doesn't have perl or a Unix shell laying around.

Below is a batch file named "lpr.bat" that is only based on command
found the standard Windows and in the Emacs distribution.  When placed
in the exec path the printing facilities of Emacs should work straigh
out of the box.

	-- Anders Lindgren

==============================8<------------------------------
@REM  lpr.bat --- Simple print command for Windows.
@ECHO OFF

REM  Copyright (C) 1998 Anders Lindgren
REM
REM  Author: Anders Lindgren <[email-masked]>
REM  Keywords: print
REM  Date: 1998-01-29

REM  This program is free software; you can redistribute it and/or modify
REM  it under the terms of the GNU General Public License as published by
REM  the Free Software Foundation; either version 2, or (at your option)
REM  any later version.

REM  This program is distributed in the hope that it will be useful,
REM  but WITHOUT ANY WARRANTY; without even the implied warranty of
REM  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
REM  GNU General Public License for more details.

REM  You should have received a copy of the GNU General Public License
REM  along with GNU Emacs; see the file COPYING.  If not, write to the
REM  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
REM  Boston, MA 02111-1307, USA.

REM Commentary:

REM  Print program for Windows.
REM
REM  Usage:
REM     lpr [file]
REM
REM  Should no argument be given the input is read from stdin.
REM
REM  The output is always sent to LPT1:
REM
REM  The problem with the combination Windows and Emacs is that Emacs
REM  assumes that the print command (specified by `lpr-command') can
REM  accept input on stdin.  Unfortunately, there is no command in
REM  Windows that can read from stdin and copy the input to a file or
REM  stdout.
REM
REM  Fortunately, there is a program named `hexl' that is part of the
REM  standard Emacs distribution.  It is normally used to convert a
REM  file to and from hexadecimal form.  In this program we exploit the
REM  fact that it can read input from stdin.
REM  
REM
REM  Personally I think that the lack of features to support creation of
REM  small automatic program is _the_ major design flaw in Windows.

if "%1" == ""      hexl | hexl -de > lpt1:

if not "%1" == ""  type %1 > lpt1:

REM  lpr.bat ends here.