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