Subject: Printing from ntemacs in Win95

From: Mark Masse <[email-masked]>
Date: Wed, 18 Sep 1996 19:17:47 -0600 (MDT)

Hello,

  I'm not sure if anyone needs this, but I thought I would post my 
*simple* method for printing buffers/files with ntemacs under Win95.  I 
have not tested this under NT, but it may work there as well.  I am sure 
there are better, cleaner and simpler ways to do this, but it was a quick 
hack :)  Here is what I added to my "_emacs" file:

;; This should be set to your printer's port, mine is LPT1.
(setq printer-port "LPT1:")

;; My Win 95 printing hack.  NOTE: *ALWAYS* saves buffer to file before 
;; printing.
(defun win95-print-buffer-file ()
  "Print the current buffer's file by copying the associated file to the
   printer port. Saves the buffer if has been modified and/or never saved."
  (interactive)
  (save-buffer)
  (setq file (buffer-file-name))
  (message (concat "Printing " file " on " printer-port))
  (copy-file file "lpt1:"))

;; Make "Ctrl-c p" print the current buffer
(define-key global-map "\C-cp" 'win95-print-buffer-file)

That's it, I hope that its useful...

- Mark

***********************************************************************
Mark Masse                                       Undergraduate Student
                                        Department of Computer Science
[email-masked]                       University of Colorado  
http://www-ugrad.cs.colorado.edu/~masse                    Boulder, CO
***********************************************************************

---

From: Paul Mitchell <[email-masked]>
Date: Thu, 19 Sep 1996 12:54:18 -0400

>hack :)  Here is what I added to my "_emacs" file:
Hi Mark.

Your win95 printing hack worked fine for me except that it wouldn't scroll
up the paper after the printing was completed.  The solution is to send a ^L
to the printer after the file has been sent.  

Here's the modified code:

;; My Win 95 printing hack.  NOTE: *ALWAYS* saves buffer to file before 
;; printing.
(defun win95-print-buffer-file ()
  "Print the current buffer's file by copying the associated file to the
   printer port. Saves the buffer if has been modified and/or never saved."
  (interactive)
  (save-buffer)
  (setq file (buffer-file-name))
  (copy-file file printer-port)
  (save-excursion
    (set-buffer (get-buffer-create "*ControlL*"))
    (insert "") ;; this needs to be a real control-l. type C-q C-l inside
the quotes
    (write-file printer-port)
    (kill-buffer printer-port))
  (message (concat "Printing " file " on " printer-port)))

****     Paul Mitchell - NeoCortek, Inc.     ****
****       [email-masked]       ****
**** Tel: (508) 779-0355 Fax: (508) 779-2941 ****