Article View: gnu.emacs.bug
Article #100044lpr changes to work properly on SysV (FIX)
From: Eric S. Raymond
Date: Fri, 16 Mar 1990 09:15
Date: Fri, 16 Mar 1990 09:15
106 lines
4474 bytes
4474 bytes
The lpr.el mode distributed with 18.55 loses on SysV systems through not
setting the right switches (`-o nobanner') to suppress headers, and because
SysV lp doesn't have a -p option.
Diffs to fix this are nearly larger than the (rather small) mode source. Here
is the entire replacement mode.
------------------------------- CUT HERE -----------------------------------
;; Print Emacs buffer on line printer.
;; Copyright (C) 1985, 1988 Free Software Foundation, Inc.
;; System V support added by Eric S. Raymond (eric@snark.uu.net), March 1990
;; 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 (eq system-type 'usg-unix-v)
"lp" "lpr")
"Shell command for printing a file")
(defun lpr-buffer ()
"Print buffer contents through the Unix print spooler.
`lpr-switches' is a list of extra switches (strings) to pass to the spooler."
(interactive)
(print-region-1 (point-min) (point-max)
(if (eq system-type 'usg-unix-v)
(cons "-o" (cons "nobanner" lpr-switches))
lpr-switches
)
))
(defun print-buffer ()
"Print buffer contents through the Unix print spooler, with a banner page.
`lpr-switches' is a list of extra switches (strings) to pass to the spooler."
(interactive)
(print-region-1 (point-min) (point-max)
(if (eq system-type 'usg-unix-v)
lpr-switches
(cons "-p" lpr-switches)
)
))
(defun lpr-region (start end)
"Print region contents through the Unix print spooler.
`lpr-switches' is a list of extra switches (strings) to pass to lpr."
(interactive "r")
(print-region-1 start end
(if (eq system-type 'usg-unix-v)
(cons "-o" (cons "nobanner" lpr-switches))
lpr-switches
)
))
(defun print-region (start end)
"Print region contents through the Unix print spooler, with a banner page.
`lpr-switches' is a list of extra switches (strings) to pass to the spooler."
(interactive "r")
(print-region-1 start end
(if (eq system-type 'usg-unix-v)
lpr-switches
(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 start end)
(setq tab-width width)
(untabify (point-min) (point-max))
(setq start (point-min) end (point-max))))
(apply 'call-process-region
(nconc (list start end lpr-command
nil nil nil)
(nconc (and (eq system-type 'berkeley-unix)
(list "-J" name "-T" name))
switches)))
(message "Spooling...done"))))
------------------------------- CUT HERE -----------------------------------
Enjoy!
--
Eric S. Raymond = eric@snark.uu.net (mad mastermind of TMN-Netnews)
Technical Details
Message-ID:
<1VnZB4#1p0lyj9H8nHO6GyB697F3BxB=eric@snark.uu.net>Path:
arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!bu.edu!snorkelwacker!usc!cs.utexas.edu!mailrus!rutgers!cbmvax!snark!ericShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,21fc0929d2704054,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1990-03-16 01:15:08 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!mcsun!uunet!bu.edu!snorkelwacker!usc!cs.utexas.edu!mailrus!rutgers!cbmvax!snark!eric From: eric@snark.uu.net (Eric S. Raymond) Newsgroups: gnu.emacs.bug Subject: lpr changes to work properly on SysV (FIX) Message-ID: <1VnZB4#1p0lyj9H8nHO6GyB697F3BxB=eric@snark.uu.net> Date: 16 Mar 90 09:15:08 GMT Lines: 106 Posted: Fri Mar 16 10:15:08 1990