warren@UUNET.UU.NET (06/13/89)
I am using Emacs 18.52 on Xenix 386 2.3.1. M-x lpr-buffer didn't print anything, so I took a look into lpr.el and found that lpr-command was being defined as "lpr" because system-type was not equal to 'usr-unix-v (it is 'xenix by me). That's ok, because on xenix lpr is a symbolic link to lp. But what's not ok is that lpr is being called with -J and -T arguments. This causes lpr (or lp for that matter) to print a message (which is not displayed because call-process-region has BUFFER set to nil) and to terminate without printing. I suspect that people may be having similar problems on other system V's, "Portable C and UNIX System Programming" by "J.E. Lapin" says that -J and -T are only supported on BSD4.2. The following is my update to lpr.el which works for me. It uses lp on xenix (sounds better to me, xenix is more usg-ish than berkeley-ish) and does not use the -J and -T if lp is used, instead it uses '-tnmame' (causes the name to appear in the banner page) which should be checked to see if it works on all usg's because the "Portable" book doesn't mention it. I think it does exist, I looked in a printout of a usg source of lp from several years ago and it has it. My changes are surrounded by comments ; start change by WB ; end change by WB print-region and print-buffer still don't work because lp doesn't recognize -p. If you answer two quick questions I'll do that, too: 1) is the correct way to get call-proccess-region to pipe pr thru lp to set PROGRAM to "sh" and pass it args "-c pr | lp"? (I know this works, but is there a way to pipe within emacs w/o using an extra shell?) 2) Do you have a delete-from-list or some such function to make it easier to get the -p out of switches? I'm sure I could write the lisp for this in less than an entire morning but not by much, I'm not all that much of a lisp hacker and there's no elisp manual yet. (is that still the case? I'm not complaining, just justifying my asking instead of reading the manual) ------------- ;; Print Emacs buffer on line printer. ;; Copyright (C) 1985, 1988 Free Software Foundation, Inc. ;; This file is part of GNU Emacs. ;; GNU Emacs is distributed in the hope that it will be useful, ;; but WITHOUT ANY WARRANTY. No author or distributor ;; accepts responsibility to anyone for the consequences of using it ;; or for whether it serves any particular purpose or works at all, ;; unless he says so in writing. Refer to the GNU Emacs General Public ;; License for full details. ;; Everyone is granted permission to copy, modify and redistribute ;; GNU Emacs, but only under the conditions described in the ;; GNU Emacs General Public License. A copy of this license is ;; supposed to have been given to you along with GNU Emacs so you ;; can know your rights and responsibilities. It should be in a ;; file named COPYING. Among other things, the copyright notice ;; and this notice must be preserved on all copies. ;(defconst lpr-switches nil ; "*List of strings to pass as extra switch args to lpr when it is invoked.") (defvar lpr-command (if ; start change by WB (or (eq system-type 'usg-unix-v) (eq system-type 'xenix)) "lp" "lpr") ; end change by WB "Shell command for printing a file") (defvar lpr-args (cond ((eq system-type 'usg-unix-v) "lp") ((eq system-type 'xenix) "lp") (t "lpr")) "Shell command for printing a file") (defun lpr-buffer () "Print buffer contents as with Unix command `lpr'. `lpr-switches' is a list of extra switches (strings) to pass to lpr." (interactive) (print-region-1 (point-min) (point-max) lpr-switches)) (defun print-buffer () "Print buffer contents as with Unix command `lpr -p'. `lpr-switches' is a list of extra switches (strings) to pass to lpr." (interactive) (print-region-1 (point-min) (point-max) (cons "-p" lpr-switches))) (defun lpr-region (start end) "Print region contents as with Unix command `lpr'. `lpr-switches' is a list of extra switches (strings) to pass to lpr." (interactive "r") (print-region-1 start end lpr-switches)) (defun print-region (start end) "Print region contents as with Unix command `lpr -p'. `lpr-switches' is a list of extra switches (strings) to pass to lpr." (interactive "r") (print-region-1 start end (cons "-p" lpr-switches))) (defun print-region-1 (start end switches) (let ((name (concat (buffer-name) " Emacs buffer")) (width tab-width)) (save-excursion (message "Spooling...") (if (/= tab-width 8) (let ((oldbuf (current-buffer))) (set-buffer (get-buffer-create " *spool temp*")) (widen) (erase-buffer) (insert-buffer-substring oldbuf) (setq tab-width width) (untabify (point-min) (point-max)) (setq start (point-min) end (point-max)))) (apply 'call-process-region ; start change by WB (nconc (list start end lpr-command nil nil nil) (if (eq lpr-command "lpr") (list "-J" name "-T" name) (list (concat "-t" name))) ; end change by WB switches)) (message "Spooling...done"))))