home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / elisp / misc / enscript.el < prev    next >
Encoding:
Text File  |  1992-06-16  |  7.8 KB  |  221 lines

  1. ;; enscript.el
  2. ;;
  3. ;;
  4. ;; LCD Archive Entry:
  5. ;; enscript|Graham Gough|graham@cs.man.ac.uk|
  6. ;; Version of lpr.el for use with enscript.|
  7. ;; 92-06-05|1.1|~/misc/enscript.el.Z|
  8. ;;
  9. ;; Written by Graham Gough  graham@cs.man.ac.uk
  10. ;; Send all bugs/suggestions to author
  11. ;;
  12. ;; Copyright (C) 1990 Graham D. Gough
  13. ;;
  14. ;; This file is not  part of GNU Emacs, however, GNU copyleft applies
  15. ;;
  16. ;; GNU Emacs is distributed in the hope that it will be useful,
  17. ;; but WITHOUT ANY WARRANTY.  No author or distributor
  18. ;; accepts responsibility to anyone for the consequences of using it
  19. ;; or for whether it serves any particular purpose or works at all,
  20. ;; unless he says so in writing.  Refer to the GNU Emacs General Public
  21. ;; License for full details.
  22.  
  23. ;; Everyone is granted permission to copy, modify and redistribute
  24. ;; GNU Emacs, but only under the conditions described in the
  25. ;; GNU Emacs General Public License.   A copy of this license is
  26. ;; supposed to have been given to you along with GNU Emacs so you
  27. ;; can know your rights and responsibilities.  It should be in a
  28. ;; file named COPYING.  Among other things, the copyright notice
  29. ;; and this notice must be preserved on all copies.
  30. ;;
  31. ;; Copied shamelessly from lpr.el
  32. ;;
  33. ;; Revision 1.1
  34. ;; 4/5/92
  35. ;; Modified after suggestions from Murali Raju,
  36. ;; (raju@antares.mcs.anl.gov) to include prompt for header modification
  37. ;; and message including feedback form enscript.
  38. ;;
  39.  
  40.  
  41. (defconst enscript-switches nil
  42.   "*List of strings to pass as extra switch args to enscript when it is invoked.")
  43.  
  44. (defvar enscript-prompt-for-heads nil
  45.   "*If non-nil enscript commands prompt for headers")
  46.  
  47. (defvar enscript-command "enscript"
  48.   "Shell command for printing a file")
  49.  
  50. (defun enscript-buffer (two-up)
  51.   "Enscript buffer contents as with Unix command `enscript'.
  52.   -2r switch added if prefix arg given
  53. `enscript-switches' is a list of extra switches (strings) to pass to enscript."
  54.   (interactive "P")
  55.   (if two-up
  56.       (enscript-region-1 (point-min) (point-max) (cons "-2r" enscript-switches))
  57.     (enscript-region-1 (point-min) (point-max)  enscript-switches)))
  58.  
  59. (defun enscript-region (start end)
  60.   "Enscript region contents as with Unix command `enscript'.
  61.   -2r switch added if prefix arg given
  62. `enscript-switches' is a list of extra switches (strings) to pass to enscript."
  63.   (interactive "r")
  64.   (if current-prefix-arg
  65.       (enscript-region-1 start end (cons "-2r" enscript-switches))
  66.          (enscript-region-1 start end  enscript-switches)))
  67.  
  68. (defun enscript-region-1 (start end switches)
  69. ;;; Prompts
  70.   (let ((name (concat (buffer-name) " Emacs buffer  " (current-time-string)))
  71.     (width tab-width)
  72.     (job (concat (buffer-name) " Emacs buffer")))
  73.     (if (not enscript-prompt-for-heads)
  74.     t
  75.       (read-from-minibuffer "Page Header: " name)
  76.       (read-from-minibuffer "Burst Page Job Description: " job))
  77.     (save-excursion
  78.      (message "Spooling...")
  79.      (if (/= tab-width 8)
  80.      (let ((oldbuf (current-buffer)))
  81.       (set-buffer (get-buffer-create " *spool temp*"))
  82.       (widen) (erase-buffer)
  83.       (insert-buffer-substring oldbuf)
  84.       (setq tab-width width)
  85.       (untabify (point-min) (point-max))
  86.       (setq start (point-min) end (point-max))))
  87. ;;; Allows for storage of the output of enscript
  88.      (apply 'call-process-region 
  89.         (nconc (list start end enscript-command
  90.              nil (get-buffer-create "*enscript-info*") nil
  91.              "-b" name
  92.              "-J" job)
  93.            switches))
  94.      (message "Spooling...done")
  95.      (sit-for 2)
  96.      (set-buffer (get-buffer "*enscript-info*"))
  97. ;;; Prints message to minibuffer
  98.      (message (buffer-substring (point-min) (- (point-max) 1)))
  99.      (widen) 
  100.      (erase-buffer))))
  101.  
  102.  
  103. From graham@computer-science.manchester.ac.uk  Fri Jun  5 04:58:04 1992
  104. Return-Path: <graham@computer-science.manchester.ac.uk>
  105. Received: from hal.com (hal-backbone) by halaus (4.1/SMI-4.1.2)
  106.     id AA20124; Fri, 5 Jun 92 04:58:04 CDT
  107. Received: from mail.cis.ohio-state.edu by hal.com (4.1/SMI-4.1.1)
  108.     id AA13245; Fri, 5 Jun 92 02:58:02 PDT
  109. Received: from sun2.nsfnet-relay.ac.uk by mail.cis.ohio-state.edu (5.61-kk/5.911008)
  110.     id AA27850; Fri, 5 Jun 92 05:57:53 -0400
  111. Via: computer-science.manchester.ac.uk; Fri, 5 Jun 1992 10:57:16 +0100
  112. Date: Fri, 5 Jun 92 10:57:00 BST
  113. From: Graham Gough <graham@computer-science.manchester.ac.uk>
  114. Message-Id: <9206050957.AA05013@r8e.cs.man.ac.uk>
  115. To: elisp-archive@cis.ohio-state.edu
  116. Subject: enscript
  117. Status: OR
  118.  
  119. ;; enscript.el
  120. ;;
  121. ;;
  122. ;; LCD Archive Entry:
  123. ;; enscript|Graham Gough|graham@cs.man.ac.uk
  124. ;; |Version of lpr.el for use with enscript
  125. ;; Fri Jun  5 10:45:31 1992|1.1||
  126. ;;
  127. ;; Written by Graham Gough  graham@cs.man.ac.uk
  128. ;; Send all bugs/suggestions to author
  129. ;;
  130. ;; Copyright (C) 1990 Graham D. Gough
  131. ;;
  132. ;; This file is not  part of GNU Emacs, however, GNU copyleft applies
  133. ;;
  134. ;; GNU Emacs is distributed in the hope that it will be useful,
  135. ;; but WITHOUT ANY WARRANTY.  No author or distributor
  136. ;; accepts responsibility to anyone for the consequences of using it
  137. ;; or for whether it serves any particular purpose or works at all,
  138. ;; unless he says so in writing.  Refer to the GNU Emacs General Public
  139. ;; License for full details.
  140.  
  141. ;; Everyone is granted permission to copy, modify and redistribute
  142. ;; GNU Emacs, but only under the conditions described in the
  143. ;; GNU Emacs General Public License.   A copy of this license is
  144. ;; supposed to have been given to you along with GNU Emacs so you
  145. ;; can know your rights and responsibilities.  It should be in a
  146. ;; file named COPYING.  Among other things, the copyright notice
  147. ;; and this notice must be preserved on all copies.
  148. ;;
  149. ;; Copied shamelessly from lpr.el
  150. ;;
  151. ;; Revision 1.1
  152. ;; 4/5/92
  153. ;; Modified after suggestions from Murali Raju,
  154. ;; (raju@antares.mcs.anl.gov) to include prompt for header modification
  155. ;; and message including feedback form enscript.
  156. ;;
  157.  
  158.  
  159. (defconst enscript-switches nil
  160.   "*List of strings to pass as extra switch args to enscript when it is invoked.")
  161.  
  162. (defvar enscript-prompt-for-heads nil
  163.   "*If non-nil enscript commands prompt for headers")
  164.  
  165. (defvar enscript-command "enscript"
  166.   "Shell command for printing a file")
  167.  
  168. (defun enscript-buffer (two-up)
  169.   "Enscript buffer contents as with Unix command `enscript'.
  170.   -2r switch added if prefix arg given
  171. `enscript-switches' is a list of extra switches (strings) to pass to enscript."
  172.   (interactive "P")
  173.   (if two-up
  174.       (enscript-region-1 (point-min) (point-max) (cons "-2r" enscript-switches))
  175.     (enscript-region-1 (point-min) (point-max)  enscript-switches)))
  176.  
  177. (defun enscript-region (start end)
  178.   "Enscript region contents as with Unix command `enscript'.
  179.   -2r switch added if prefix arg given
  180. `enscript-switches' is a list of extra switches (strings) to pass to enscript."
  181.   (interactive "r")
  182.   (if current-prefix-arg
  183.       (enscript-region-1 start end (cons "-2r" enscript-switches))
  184.          (enscript-region-1 start end  enscript-switches)))
  185.  
  186. (defun enscript-region-1 (start end switches)
  187. ;;; Prompts
  188.   (let ((name (concat (buffer-name) " Emacs buffer  " (current-time-string)))
  189.     (width tab-width)
  190.     (job (concat (buffer-name) " Emacs buffer")))
  191.     (if (not enscript-prompt-for-heads)
  192.     t
  193.       (read-from-minibuffer "Page Header: " name)
  194.       (read-from-minibuffer "Burst Page Job Description: " job))
  195.     (save-excursion
  196.      (message "Spooling...")
  197.      (if (/= tab-width 8)
  198.      (let ((oldbuf (current-buffer)))
  199.       (set-buffer (get-buffer-create " *spool temp*"))
  200.       (widen) (erase-buffer)
  201.       (insert-buffer-substring oldbuf)
  202.       (setq tab-width width)
  203.       (untabify (point-min) (point-max))
  204.       (setq start (point-min) end (point-max))))
  205. ;;; Allows for storage of the output of enscript
  206.      (apply 'call-process-region 
  207.         (nconc (list start end enscript-command
  208.              nil (get-buffer-create "*enscript-info*") nil
  209.              "-b" name
  210.              "-J" job)
  211.            switches))
  212.      (message "Spooling...done")
  213.      (sit-for 2)
  214.      (set-buffer (get-buffer "*enscript-info*"))
  215. ;;; Prints message to minibuffer
  216.      (message (buffer-substring (point-min) (- (point-max) 1)))
  217.      (widen) 
  218.      (erase-buffer))))
  219.  
  220.  
  221.