[gnu.emacs.bug] lpr.el bugs for System V

kayvan@APPLE.COM (Kayvan Sylvan) (12/01/88)

GNU Emacs version 18.52.

Here's a fix for lpr.el on System V systems. The lpr commands do not work
as distributed. This fix has been marginally tested. If there are errors,
please fix them and mail me (satyr!kayvan@apple.com).

Repeat-By:
   On Unix System V (which uses the "lp" command). Visit a buffer
   and do M-x lpr-buffer. There is no output.

   The lp command syntax differs from the lpr command syntax.

Fix:
   The new variable lpr-default-switches is a list of switches (to
   concatenate with the name) and pass on to lpr-command. It is conditionally
   set to '("-J" "-T") for BSD systems and to '("-t") for SysV.
   The function lpr-default-list makes the argument list for the
   appropriate lpr-command.

*** lpr.el.orig	Wed Nov 30 21:56:44 1988
--- lpr.el	Wed Nov 30 22:43:24 1988
***************
*** 19,22 ****
--- 19,24 ----
  ;; and this notice must be preserved on all copies.
  
+ ;; Modified by Kayvan Aghaiepour (satyr!kayvan@apple.com) Wed Nov 30 1988
+ ;; Support for Unix System V lp command syntax.
  
  ;(defconst lpr-switches nil
***************
*** 27,30 ****
--- 29,37 ----
    "Shell command for printing a file")
  
+ (defvar lpr-default-switches (if (eq system-type 'usg-unix-v)
+ 				 '("-t") '("-J" "-T"))
+   "List of default strings to pass as switches to lpr-command.
+ These are interspersed with the buffer name to create the command line.")
+ 
  (defun lpr-buffer ()
    "Print buffer contents as with Unix command `lpr'.
***************
*** 65,71 ****
  	  (setq start (point-min) end (point-max))))
       (apply 'call-process-region
! 	    (nconc (list start end lpr-command
! 			 nil nil nil
! 			 "-J" name "-T" name)
  		   switches))
       (message "Spooling...done"))))
--- 72,86 ----
  	  (setq start (point-min) end (point-max))))
       (apply 'call-process-region
! 	    (nconc (list start end lpr-command nil nil nil)
! 		   (lpr-default-list name)
  		   switches))
       (message "Spooling...done"))))
+ 
+ (defun lpr-default-list (name)
+   "Takes BUFFERNAME and creates a list for print-region-1."
+   (let ((new-list nil) (old-list lpr-default-switches) next-switch)
+     (while old-list			; traverse old-list
+       (setq next-switch (car old-list))	; get first member
+       (setq new-list (append new-list (list (concat next-switch name))))
+       (setq old-list (cdr old-list)))	; cdr down the list
+     new-list))				; return the list