Subject: Print-NT.el

From: Frederic Corne <[email-masked]>
Date: Tue, 27 Aug 96 09:38:53 +0200

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

Add in your .emacs and change your server and printer name:

(setq lpr-command                "lpr"
			lpr-switches               '("-S your-server -P your-printer")
			ps-paper-type              'ps-a4 )

(load "print-NT"() t)
---------------------------------------------------------------

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; print-NT.el
;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

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

;;;;;;; simple print

(defun print-lpr-buffer ()
	(shell-command
   (apply 'concat (append (list lpr-command " ")
                          lpr-switches
                          (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 " ")
                          ps-lpr-switches
                          (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)

;;;;;;;;;;
----------------------------------------------------------------

-- 

--- Frederic Corne --- ERLI --- [email-masked] ---