Subject: Re: Print-NT.el

From: Brad Sileo <[email-masked]>
Date: Tue, 27 Aug 1996 09:58:05 -0600

Here is a slightly modified version of this code. I changed it to use the
shell command print, which accepts a device specifier(i.e. a UNC) and file
name as its arguments.  This allows me to use native NT printers from
emacs(is there an easier way to do this?).  It also lets users easily set
the variables lpr-destination and ps-lpr-destination to the UNC of their
favorite printer.  Thanks for the code bit Frederic, as I have needed to fix
my NT->emacs printing for some time!!

At 09:38 AM 8/27/96 +0200, you wrote:
>
>
>This is my little contribution to the use of Emacs under NT.
>
>This file is based on the exemple of Pascal Obry.
>It overwrites the items of the Tools menu.
>
>This works with lpr.exe and a dos shell-command
>

------------------- .emacs file (of default.el) --------------
;;; Setup printing for NT's using print-NT.el
(setq lpr-command     "print"
      ps-paper-type   'ps-a4)
;;;; Lots of nice docs so users can figure it out...
(defvar      lpr-destination    '("\\\\host\\share-name")
  "*The UNC style location for regular print jobs\nThe default is
\\\\host\\share-name.\nRemember to escape the backslashes(use '\\\\' for
each '\\') for emacs.")
(defvar      ps-lpr-destination '("\\\\host\\share-name_ps")
  "*The UNC style location for Postscript print jobs\nThe default is
\\\\host\\share-name_ps.\nRemember to escape the backslashes(use '\\\\' for
each '\\') for emacs.")

-------------------- Slightly modified print-NT.el ---------------
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; print-NT.el
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; The variables lpr-switches and ps-lpr-switches have been replaced by
;;  lpr-destination and ps-lpr-destination, which must be defined. It would
;;  be cleaner if these could be null and the system default used, but 
;;  I'm too new to emacs Lisp to know how to do that without lots of thought
;;  :-)

(defvar ps-lpr-buffer "c:\\temp\\psspool.ps")
(defvar txt-lpr-buffer "c:\\temp\\psspool.txt")

;;;;;;; simple print

(defun print-lpr-buffer ()
	(shell-command
   (apply 'concat (append (list lpr-command " /D:")
                          lpr-destination
                          (list " " txt-lpr-buffer))))
	(delete-file txt-lpr-buffer)
)
(defun nt-print-buffer ()
  (interactive)
	(write-region (point-min) (point-max) txt-lpr-buffer)
	(print-lpr-buffer )
)
(defun nt-print-region ()
  (interactive)
	(write-region (point) (mark) txt-lpr-buffer)
	(print-lpr-buffer )
)

(define-key menu-bar-tools-menu [print-region]
  '("Print Region" . nt-print-region))
(define-key menu-bar-tools-menu [print-buffer]
  '("Print Buffer" . nt-print-buffer))

;;;;;;; ps-print 

(require 'ps-print)

(defun ps-print-lpr-buffer ()
	(shell-command
   (apply 'concat (append (list ps-lpr-command " /D:")
                          ps-lpr-destination
                          (list " " ps-lpr-buffer))))
	(delete-file  ps-lpr-buffer)
)

(defvar ps-print-use-faces nil
	"*Non-nil means alway print with faces.")

(defun toggle-use-face ()
	(interactive)
	(if ps-print-use-faces 
			(progn (setq ps-print-use-faces nil)
						 (message "ps-print-use-faces disabled"))
		(setq ps-print-use-faces t)
		(message "ps-print-use-faces unabled"))
)
(define-key menu-bar-tools-menu [toggle-use-face]
  '("Toggle on/off print-with-faces" . toggle-use-face))

(defun nt-ps-print-buffer ()
  (interactive)
	(if ps-print-use-faces 
			(ps-print-buffer-with-faces ps-lpr-buffer)
		(ps-print-buffer ps-lpr-buffer)
		)
  (ps-print-lpr-buffer)
)
(define-key menu-bar-tools-menu [ps-print-buffer]
  '("Postscript Print Buffer" . nt-ps-print-buffer))
(define-key global-map "\C-cp" 'nt-ps-print-buffer)

(defun nt-ps-print-region ()
  (interactive)
	(if ps-print-use-faces 
			(ps-print-region-with-faces (point) (mark) ps-lpr-buffer)
		(ps-print-region (point) (mark) ps-lpr-buffer)
		)
  (ps-print-lpr-buffer)
)
(define-key menu-bar-tools-menu [ps-print-region]
  '("Postscript Print Region" . nt-ps-print-region))
(define-key global-map "\C-crp" 'nt-ps-print-region)

;;;;;;;;;;
======================================================
                   Brad Sileo
              GeoData Solutions, Inc.		
Network Engineer                     GIS Consultant
Voice:(303)650-1600                 Fax:(303)650-1795 
             http://www.geodata-gis.com
======================================================