Mercurial > emacs
annotate lisp/lpr.el @ 496:dcdf0a92df40
*** empty log message ***
author | Jim Blandy <jimb@redhat.com> |
---|---|
date | Wed, 15 Jan 1992 19:43:09 +0000 |
parents | 2ca8cdb96a9f |
children | cde1f15848c6 |
rev | line source |
---|---|
155 | 1 ;; Print Emacs buffer on line printer. |
2 ;; Copyright (C) 1985, 1988 Free Software Foundation, Inc. | |
3 | |
4 ;; This file is part of GNU Emacs. | |
5 | |
6 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
7 ;; it under the terms of the GNU General Public License as published by | |
8 ;; the Free Software Foundation; either version 1, or (at your option) | |
9 ;; any later version. | |
10 | |
11 ;; GNU Emacs is distributed in the hope that it will be useful, | |
12 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 ;; GNU General Public License for more details. | |
15 | |
16 ;; You should have received a copy of the GNU General Public License | |
17 ;; along with GNU Emacs; see the file COPYING. If not, write to | |
18 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. | |
19 | |
20 | |
269 | 21 ;;;###autoload |
22 (defconst lpr-switches nil "\ | |
23 *List of strings to pass as extra switch args to lpr when it is invoked.") | |
155 | 24 |
25 (defvar lpr-command (if (eq system-type 'usg-unix-v) | |
26 "lp" "lpr") | |
27 "Shell command for printing a file") | |
28 | |
29 (defvar print-region-function nil | |
30 "Function to call to print the region on a printer. | |
216
2c663336acaf
*** empty log message ***
Richard M. Stallman <rms@gnu.org>
parents:
155
diff
changeset
|
31 See definition of `print-region-1' for calling conventions.") |
155 | 32 |
256 | 33 ;;;###autoload |
155 | 34 (defun lpr-buffer () |
35 "Print buffer contents as with Unix command `lpr'. | |
36 `lpr-switches' is a list of extra switches (strings) to pass to lpr." | |
37 (interactive) | |
38 (print-region-1 (point-min) (point-max) lpr-switches nil)) | |
39 | |
256 | 40 ;;;###autoload |
155 | 41 (defun print-buffer () |
42 "Print buffer contents as with Unix command `lpr -p'. | |
43 `lpr-switches' is a list of extra switches (strings) to pass to lpr." | |
44 (interactive) | |
45 (print-region-1 (point-min) (point-max) lpr-switches t)) | |
46 | |
256 | 47 ;;;###autoload |
155 | 48 (defun lpr-region (start end) |
49 "Print region contents as with Unix command `lpr'. | |
50 `lpr-switches' is a list of extra switches (strings) to pass to lpr." | |
51 (interactive "r") | |
52 (print-region-1 start end lpr-switches nil)) | |
53 | |
256 | 54 ;;;###autoload |
155 | 55 (defun print-region (start end) |
56 "Print region contents as with Unix command `lpr -p'. | |
57 `lpr-switches' is a list of extra switches (strings) to pass to lpr." | |
58 (interactive "r") | |
59 (print-region-1 start end lpr-switches t)) | |
60 | |
61 (defun print-region-1 (start end switches page-headers) | |
62 (let ((name (concat (buffer-name) " Emacs buffer")) | |
63 (width tab-width)) | |
64 (save-excursion | |
65 (message "Spooling...") | |
66 (if (/= tab-width 8) | |
67 (progn | |
68 (print-region-new-buffer start end) | |
69 (setq tab-width width) | |
70 (untabify (point-min) (point-max)))) | |
71 (if page-headers | |
72 (if (eq system-type 'usg-unix-v) | |
73 (progn | |
74 (print-region-new-buffer) | |
75 (call-process-region start end "pr" t t nil)) | |
76 ;; On BSD, use an option to get page headers. | |
77 (setq switches (cons "-p" switches)))) | |
78 (apply (or print-region-function 'call-process-region) | |
79 (nconc (list start end lpr-command | |
80 nil nil nil) | |
81 (nconc (and (eq system-type 'berkeley-unix) | |
82 (list "-J" name "-T" name)) | |
83 switches))) | |
84 (message "Spooling...done")))) | |
85 | |
86 ;; This function copies the text between start and end | |
87 ;; into a new buffer, makes that buffer current, | |
88 ;; and sets start and end to the buffer bounds. | |
89 ;; start and end are used free. | |
90 (defun print-region-new-buffer () | |
91 (or (string= (buffer-name) " *spool temp*") | |
92 (let ((oldbuf (current-buffer))) | |
93 (set-buffer (get-buffer-create " *spool temp*")) | |
94 (widen) (erase-buffer) | |
95 (insert-buffer-substring oldbuf start end) | |
96 (setq start (point-min) end (point-max))))) |