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