From owner-ntemacs-users@june  Tue Oct  1 22:43:55 1996
X-VM-v5-Data: ([nil nil nil nil nil nil nil nil nil]
	[nil "Tue" " 1" "October" "1996" "23:14:13" "-0600" "Charles S. Henkel" "csh@henktech.com" nil "12" "RE: command line enscript" "^From:" nil nil "10" nil nil nil nil]
	nil)
Received: from joker.cs.washington.edu (joker.cs.washington.edu [128.95.1.42]) by june.cs.washington.edu (8.7.6/7.2ju) with SMTP id WAA11348 for <voelker@june.cs.washington.edu>; Tue, 1 Oct 1996 22:43:55 -0700
Received: from june.cs.washington.edu (june.cs.washington.edu [128.95.1.4]) by joker.cs.washington.edu (8.6.12/7.2ws+) with ESMTP id WAA30453 for <voelker@joker.cs.washington.edu>; Tue, 1 Oct 1996 22:43:53 -0700
Received: from Rt66.com (mack.rt66.com [198.59.162.1]) by june.cs.washington.edu (8.7.6/7.2ju) with ESMTP id WAA09332 for <ntemacs-users@cs.washington.edu>; Tue, 1 Oct 1996 22:05:25 -0700
Received: from pmh29.rt66.com (transitory132.lanl.gov [128.165.7.100]) by Rt66.com (8.7.5/8.7.3) with SMTP id XAA10385; Tue, 1 Oct 1996 23:03:59 -0600 (MDT)
Received: by pmh29.rt66.com with Microsoft Mail 	id <01BBAFEE.45156D50@pmh29.rt66.com>; Tue, 1 Oct 1996 23:14:17 -0600
Message-ID: <01BBAFEE.45156D50@pmh29.rt66.com>
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
From: "Charles S. Henkel" <csh@henktech.com>
To: "'ntemacs-users@cs.washington.edu'" <ntemacs-users@cs.washington.edu>,         "'Chris McMahan'" <cmcmahan@Teknowledge.COM>
Subject: RE: command line enscript
Date: Tue, 1 Oct 1996 23:14:13 -0600


>It's a hack, but you can get it at

Sorry, the correct address is:

ftp://mack.rt66.com/users/csh/a2ps.zip


Charles S. Henkel
Henkel Technical Computing
P.O. Box 1396  Los Alamos, NM  87544
(505)662-0442  csh@henktech.com

From owner-ntemacs-users@june  Wed Oct  9 16:50:02 1996
X-VM-v5-Data: ([nil nil nil nil nil nil nil nil nil]
	[nil "Wed" " 9" "October" "1996" "18:16:18" "CDT" "George D. Hadden" "hadden@htc.honeywell.com" nil "70" "command line enscript - follow up" "^From:" nil nil "10" nil nil nil nil]
	nil)
Received: from joker.cs.washington.edu (joker.cs.washington.edu [128.95.1.42]) by june.cs.washington.edu (8.7.6/7.2ju) with SMTP id QAA16639 for <voelker@june.cs.washington.edu>; Wed, 9 Oct 1996 16:50:02 -0700
Received: from june.cs.washington.edu (june.cs.washington.edu [128.95.1.4]) by joker.cs.washington.edu (8.6.12/7.2ws+) with ESMTP id QAA29859 for <voelker@joker.cs.washington.edu>; Wed, 9 Oct 1996 16:50:00 -0700
Received: from moon.htc.honeywell.com (moon.htc.honeywell.com [129.235.16.32]) by june.cs.washington.edu (8.7.6/7.2ju) with SMTP id QAA13546 for <ntemacs-users@cs.washington.edu>; Wed, 9 Oct 1996 16:16:24 -0700
Received: from pulsar.htc.honeywell.com by moon.htc.honeywell.com (4.1/smail2.6.3/SRCv0.25); 	Wed, 9 Oct 96 18:16:22 CDT id AA04990  for ntemacs-users@cs.washington.edu  at cs.washington.edu
Posted-Date: Wed, 9 Oct 96 18:16:18 CDT
Received: from TIBERIUS (red-64.htc.honeywell.com) by pulsar.htc.honeywell.com (4.1/SMI-3.2) 	id AA24267; Wed, 9 Oct 96 18:16:19 CDT
Message-Id: <9610092316.AA24267@pulsar.htc.honeywell.com>
From: "George D. Hadden" <hadden@htc.honeywell.com>
To: ntemacs-users@cs.washington.edu
Cc: csh@henktech.com, cmcmahan@Teknowledge.COM
Subject: command line enscript - follow up
Date: Wed, 9 Oct 96 18:16:18 CDT


thanks to charles henkel for the enscript look-alike a2ps (available
at ftp://mack.rt66.com/users/csh/a2ps.zip).  here's an enscript-buffer
(which i for some reason call "my-print-buffer" ... oh well) that
might be generally useful.  since emacs on w95 only allows one
subprocess, the program checks to see if a shell is up or not before
executing the command.  with a prefix arg, the region is printed.

comments welcome.  have fun.

-geo
---
George D. Hadden, Senior Research Fellow
Honeywell Technology Center, 3660 Technology Drive, Minneapolis, MN 55418
hadden@src.honeywell.com, (612)951-7769(voice), (612)951-7438(fax)

****************
;; enscript-buffer

(setq print-command "a2ps")			; "copy" would work here, too
;(setq print-switches "> lpt1:")		; ok, not really switches ...
(setq print-switches "> \\\\Casper\\big_john_hp5_2515")

(define-key global-map "\M-o" 'my-print-buffer)

(defun my-print-buffer (n)
  "send buffer to printer; with prefix arg, send region"
  (interactive "P")
  (save-window-excursion
    (let* ((temp-file
	    ;; this gets a guaranteed unused filename in the temp directory
	    ;; note, errors may cause this file not to be deleted, but judging
	    ;; from the junk ms and others leave in that directory, it 
	    ;; probably won't be a big problem.
	    (find-unused-filename (concat (getenv "TEMP") "\\") "eprnt"))
	   (command (concat print-command " " temp-file " " print-switches))
	   (del-command (concat "del " temp-file)))
      (write-region
       (if n (min (mark) (point)) (point-min))
       (if n (max (mark) (point)) (point-max))
       temp-file)
      ;; there's a choice here because in my nt-emacs on w95, i can have
      ;; at most one shell process.  this handles the two cases (shell buffer
      ;; or no shell buffer)
      (cond ((get-buffer-process (get-buffer "*shell*"))
	     (set-buffer "*shell*")
	     (comint-simple-send (get-buffer-process (current-buffer))
				 command)
	     ;; we don't use delete-file here so the file is still
	     ;; around by the time we get around to printing it
	     (comint-simple-send (get-buffer-process (current-buffer))
				 del-command))
	    (t (shell-command command)
	       (shell-command del-command))))
    (message "printing done")))

; find an unused temp file name
;  file-exists-p
(defun find-unused-filename (directory prefix)
  (let* ((n 0)
	 (path))
    (while (file-exists-p
	    (setq path (concat directory prefix (int-to-string n))))
      (setq n (1+ n)))
    path))

;;; this isn't used now, but here it is ...

(defun buffer-exists-p (name)
  (member name (mapcar (function buffer-name) (buffer-list))))

