Subject: Print-NT.el : printing under ntemacs.

From: Frederic Corne <[email-masked]>
Date: Thu, 17 Oct 96 09:54:08 +0200

Hi all,

As I can see some news users of ntemacs meet problems with printing
under emacs, here is a slightly modified version of the print-NT.el package
I have written and posted this summer. 

Hope this helps.

FC

;;; print-NT.el --- Special printing fonctions for Windows NT
;;
;; Author: Frederic Corne <[email-masked]> 
;; Created: jul 1996
;; Version: 1.0  1996/10/02 
;; Keywords: print, PostScript
;;
;;; Commentary:
;; 
;;  This file is based on the example of Pascal Obry (in the ntemacs FAQ).
;;
;;  This file overwrites the items of the Tools menu, so it must be loaded 
;;  before any use of the menu.
;;
;;  It alows to print with faces or not.
;;
;; USAGE: Byte-compile this file, and add the following line to your
;;  emacs initialization file (.emacs/_emacs) according to the type 
;;  of printer command (print or lpr):
;; 
;;  if you use print.exe command (The UNC style location for regular print jobs):
;;  Remember to escape the backslashes(use '\\\\' for each '\\') for emacs.
;;  
;;  (setq lpr-command                "print"
;;  			lpr-destination               '("/D:\\\\host\\share-name") ;; for normal printer
;;  			ps-lpr-destination            '("/D:\\\\host\\share-name") ;; for postscript printer
;;  
;;  (setq  ps-paper-type              'ps-a4 ) ; the type of paper (if needed)
;;  
;;  (load "print-NT"() t)
;;  
;;  
;;  
;;  if you use lpr.exe command, add :
;;  
;;  (setq lpr-command                "lpr"
;;  			lpr-destination           '("-S host -P share-name")  ;; for normal printer
;;  			ps-lpr-destination        '("-S host -P share-name")) ;; for postscript printer
;;  			
;;  (setq  ps-paper-type              'ps-a4 ) ; the type of paper (if needed)
;;  
;;  (load "print-NT"() t)
;;  
;;
;;  You can also change the temporary buffers values ps-lpr-buffer and txt-lpr-buffer
;;;;;  
;;;;; Change log:
;;
;; Revision 1.0  1996/10/02 fcorne
;; Initial revision
;;
;; Credit for suggestions, patches and bug-fixes:
;; David J. Fiande <[email-masked]>
;; Brad Sileo <[email-masked]> 

;;; Code:

(defvar  lpr-destination    '("-S host -P share-name"))
(defvar  ps-lpr-destination '("-S host -P share-name"))

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

;;;;;;; print simple
(defun print-lpr-buffer ()
  (let ((shell-file-name "cmd.exe")	; switch back to cmd.exe temporarily
				(win32-quote-process-args nil)
				(shell-command-switch "/c"))
		(shell-command
		 (apply 'concat (append (list lpr-command " ")
														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 ()
  (let ((shell-file-name "cmd.exe")	; switch back to cmd.exe temporarily
				(win32-quote-process-args nil)
				(shell-command-switch "/c"))
		(shell-command
		 (apply 'concat (append (list ps-lpr-command " ")
														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 enabled"))
)
(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)

;;;;;;;;;;