Article View: gnu.emacs.bug
Article #98724Improvement to lpr.el (function print-region-1)
From: Douglas Gray-Stephens
Date: Tue, 19 Mar 1991 14:50
Date: Tue, 19 Mar 1991 14:50
74 lines
3313 bytes
3313 bytes
Two people have recently had problems with "print-buffer", not
producing any output, but claiming that "Spooling...done". The
problem was due to a stray file called "lpr" in their current
directory. (Due to a ">" instead of "|" in a piped command.)
"print-buffer" calls "call-process-region", which uses the "exec-path"
as a search path, and starts in the current directory. Emacs does not
check the execute permissions of the file, and blindly tries to
execute the file. This fails, with a message like:-
Couldn't exec the program /home/platinum1/gray/work/lpr
but the message is not displayed.
I have modified print-region-1 to check on errors, by getting
call-process region to reporting them in a buffer called " *Spool
Messages*", and using the length of the buffer as an indication of the
success.
The new code is (started from lpr.el for emacs 18.55):-
(defun print-region-1 (start end switches)
;;
;; Tue Mar 19 10:36:49 1991; D.Gray Stephens (gray@scr.slb.com)
;; Modified function to report error message.
(if
(let ((name (concat (buffer-name) " Emacs buffer"))
(width tab-width))
(save-excursion
(message "Spooling...")
(save-excursion
(set-buffer (get-buffer-create " *Spool Messages*"))
(kill-region (point-min) (point-max))
)
(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 " *Spool Messages*" nil)
(nconc (and (eq system-type 'berkeley-unix)
(list "-J" name "-T" name))
switches)))
(set-buffer (get-buffer " *Spool Messages*"))
(= (count-lines (point-min) (point-max)) 0)
))
(message "Spooling...done")
(switch-to-buffer-other-window " *Spool Messages*")
(message "Spooling...failed")
)
)
Can the next version of emacs be modified to include a similar check?
As a second, and minor, point, I prefer to to include my user name on
the title for print-buffer, as several users access the same printer.
I modify the "name" to be
(let ((name (concat (upcase (getenv "USER")) "\'s " (buffer-name)
" Emacs buffer"))
Maybe a print-hook could be provided to enable user's to customise the
title?
I trust these comments are helpful, and look forward to the next
version of emacs.
Douglas Gray Stephens
Technical Details
Message-ID:
<9103191450.AA02259@plum.scr.slb.com>Path:
arc1-ca.pugleaf.net!gmdzi!unido!fauern!ira.uka.de!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!tut.cis.ohio-state.edu!unreplyable!garbageShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fb2f1,c2bdb00b6b6a537d,start X-Google-Attributes: gidfb2f1,public X-Google-ArrivalTime: 1991-03-19 06:50:55 PST Path: arc1-ca.pugleaf.net!gmdzi!unido!fauern!ira.uka.de!sol.ctr.columbia.edu!zaphod.mps.ohio-state.edu!magnus.acs.ohio-state.edu!tut.cis.ohio-state.edu!unreplyable!garbage From: gray@scr.slb.com (Douglas Gray-Stephens) Newsgroups: gnu.emacs.bug Subject: Improvement to lpr.el (function print-region-1) Message-ID: <9103191450.AA02259@plum.scr.slb.com> Date: 19 Mar 91 14:50:55 GMT Sender: daemon@tut.cis.ohio-state.edu Distribution: gnu Organization: GNUs Not Usenet Lines: 74 Approved: bug-gnu-emacs@prep.ai.mit.edu