setting the lpr-switches variable

setting the lpr-switches variable

Post by william l kl » Sat, 04 May 1996 04:00:00

i am using "enscript" to print my buffers/regions via

  (setq lpr-command "enscript")
  (setq lpr-switches '("-h2rgG"))

lines in my .emacs file.  the one, small, annoying thing is
that i can't get the name of the buffer passed to the
enscript header option, "-b".  on the command line, the proper
command would be something like;

  enscript -h2rgGb"*post-news* Emacs buffer"
but i can't get the string passed to the lpr-switches variable properly.

the relevant bits of lpr.el appear to use things like

  (concat (buffer-name) " Emacs buffer")

to combine the current buffer-name and the string, " Emacs buffer",
viz, the lpr-buffer command;

(defun lpr-buffer ()
  "Print buffer contents as with Unix command `lpr'.
`lpr-switches' is a list of extra switches (strings) to pass to lpr."
  (print-region-1 (point-min) (point-max) lpr-switches nil))

which calls print-region-1;

(defun print-region-1 (start end switches page-headers)
  ;; On some MIPS system, having a space in the job name
  ;; crashes the printer demon.  But using dashes looks ugly
  ;; and it seems to annoying to do for that MIPS system.
  (let ((name (concat (buffer-name) " Emacs buffer"))
        (title (concat (buffer-name) " Emacs buffer"))
        (width tab-width)
      (if page-headers
          (if lpr-headers-switches
              ;; It is possible to use an lpr option
              ;; to get page headers.
              (setq switches (append (if (stringp lpr-headers-switches)
                                         (list lpr-headers-switches)
      (setq switch-string
            (if switches (concat " with options "
                                 (mapconcat 'identity switches " "))
      (message "Spooling%s..." switch-string)
      (if (/= tab-width 8)
          (let ((new-coords (print-region-new-buffer start end)))
            (setq start (car new-coords) end (cdr new-coords))
            (setq tab-width width)
              (goto-char end)
              (setq end (point-marker)))
            (untabify (point-min) (point-max))))
      (if page-headers
          (if lpr-headers-switches
              ;; We handled this above by modifying SWITCHES.
            ;; Run a separate program to get page headers.
            (let ((new-coords (print-region-new-buffer start end)))
              (setq start (car new-coords) end (cdr new-coords)))
            (apply 'call-process-region start end lpr-page-header-program
                                 t t nil
                                 (nconc (and lpr-add-switches
                                             (list "-h" title))
            (setq start (point-min) end (point-max))))
      (apply (or print-region-function 'call-process-region)
             (nconc (list start end lpr-command
                          nil nil nil)
                    (nconc (and lpr-add-switches
                                (list "-J" name))
                           ;; These belong in pr if we are using that.
                           (and lpr-add-switches lpr-headers-switches
                                (list "-T" title))
      (if (markerp end)
          (set-marker end nil))
      (message "Spooling%s...done" switch-string))))

any help, or pointers to help, would be appreciated.


NASA Langley Research Center    WWW URL:
Hampton, VA  23681-0001  USA    Phone: 804 864 4364    Fax: 804 864 8670


1. lpr-command lpr-switches lpr-buffer rnews

Version 18.59 of Jan 29 1993
<M-x describe-variable> shows both lpr-command and lpr-switches as variables.
But, <M-x set-variable> does not permit setting lpr-command.
Version 19.19.1 of Sep 28 1993 permits setting both.

My .emacs file has the following lines:
  (setq lpr-switches '( "-2rG" "-Pyp") )
  (setq lpr-command '"/usr/sww/bin/enscript")
where "yp" is my printer.  I am on a DECstation 5000/133 on an Ethernet.
When I do <M-x lpr-buffer>, it does say ``Spooling...done'', but nothing is
actually spooled and nothing is printed out.

Also, <M-x rnews> looks through the ~/.newsrc file, and scans each newsgroup,
but ends up saying ``No news is good news'' even when rn or trn gets 100's.

Any help is appreciated.  Please send a copy of reply posts to my email.


2. Manual for NEC Monitor

3. setting the value of lpr-switches

4. Cabling help, please...

5. lpr-switches is set as a string by the menus

6. urgent question

7. How do I make the new lpr.el package take dynamic variables in the switches.

8. why are blank pages *always* deleted?

9. Problems with passing printer switches via the variables "lpr-*"

10. lpr-switches

11. lpr-switches and .xemacs-options problem

12. print-buffer zaps my lpr-switches (bug?)

13. Trouble switching lpr-buffer from lpr to lp