annotate lisp/lpr.el @ 23249:2df8a4a5e284

(redisplay_internal): Use TEMP_SET_PT_BOTH instead of SET_PT_BOTH. (try_window_id, display_text_line): Likewise.
author Karl Heuer <kwzh@gnu.org>
date Sun, 13 Sep 1998 03:54:01 +0000
parents 08902da4c832
children 359e6eb97e11
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
7300
cc7cd83ccf3f Update copyright.
Karl Heuer <kwzh@gnu.org>
parents: 5462
diff changeset
3 ;; Copyright (C) 1985, 1988, 1992, 1994 Free Software Foundation, Inc.
846
20674ae6bf52 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 811
diff changeset
4
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
5 ;; Maintainer: FSF
811
e694e0879463 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 807
diff changeset
6 ;; Keywords: unix
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
7
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
9
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
11 ;; 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
12 ;; the Free Software Foundation; either version 2, or (at your option)
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
13 ;; any later version.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
14
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
19
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
14169
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13894
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13894
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
83f275dcd93a Update FSF's address.
Erik Naggum <erik@naggum.no>
parents: 13894
diff changeset
23 ;; Boston, MA 02111-1307, USA.
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
24
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1671
diff changeset
25 ;;; Commentary:
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1671
diff changeset
26
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1671
diff changeset
27 ;; Commands to send the region or a buffer your printer. Entry points
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1671
diff changeset
28 ;; are `lpr-buffer', `print-buffer', lpr-region', or `print-region'; option
22679
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
29 ;; variables include `printer-name', `lpr-switches' and `lpr-command'.
2307
10e417efb12a Added or corrected Commentary sections
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 1671
diff changeset
30
807
4f28bd14272c *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 659
diff changeset
31 ;;; Code:
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
32
17414
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
33 (defgroup lpr nil
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
34 "Print Emacs buffer on line printer"
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
35 :group 'wp)
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
36
22679
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
37 ;;;###autoload
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
38 (defcustom printer-name
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
39 (if (memq system-type '(ms-dos windows-nt)) "PRN")
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
40 "*The name of a local printer to which data is sent for printing.
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
41 \(Note that PostScript files are sent to `ps-printer-name', which see.\)
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
42
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
43 On Unix-like systems, a string value should be a name understood by
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
44 lpr's -P option.
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
45
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
46 On MS-DOS and MS-Windows systems, it is the name of a printer device or
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
47 port. Typical non-default settings would be \"LPT1\" to \"LPT3\" for
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
48 parallel printers, or \"COM1\" to \"COM4\" or \"AUX\" for serial
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
49 printers, or \"//hostname/printer\" for a shared network printer. You
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
50 can also set it to a name of a file, in which case the output gets
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
51 appended to that file. If you want to discard the printed output, set
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
52 this to \"NUL\"."
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
53 :type 'file ; could use string but then we lose completion for files.
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
54 :group 'lpr)
17414
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
55
269
2ca8cdb96a9f *** empty log message ***
Jim Blandy <jimb@redhat.com>
parents: 262
diff changeset
56 ;;;###autoload
17414
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
57 (defcustom lpr-switches nil
13803
e0bae9f528fe (lpr-switches, lpr-add-switches): Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 11831
diff changeset
58 "*List of strings to pass as extra options for the printer program.
22679
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
59 It is recommended to set `printer-name' instead of including an explicit
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
60 switch on this list.
17414
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
61 See `lpr-command'."
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
62 :type '(repeat (string :tag "Argument"))
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
63 :group 'lpr)
5267
f7ea27a729b8 (lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents: 5004
diff changeset
64
17414
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
65 (defcustom lpr-add-switches (eq system-type 'berkeley-unix)
13803
e0bae9f528fe (lpr-switches, lpr-add-switches): Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 11831
diff changeset
66 "*Non-nil means construct -T and -J options for the printer program.
e0bae9f528fe (lpr-switches, lpr-add-switches): Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 11831
diff changeset
67 These are made assuming that the program is `lpr';
e0bae9f528fe (lpr-switches, lpr-add-switches): Doc fixes.
Karl Heuer <kwzh@gnu.org>
parents: 11831
diff changeset
68 if you are using some other incompatible printer program,
17414
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
69 this variable should be nil."
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
70 :type 'boolean
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
71 :group 'lpr)
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
72
1068
2fee5d1fe47e entered into RCS
Richard M. Stallman <rms@gnu.org>
parents: 922
diff changeset
73 ;;;###autoload
17414
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
74 (defcustom lpr-command
8566
ce5ba216927d (lpr-command, lpr-headers-switches): Undo previous change.
Richard M. Stallman <rms@gnu.org>
parents: 8562
diff changeset
75 (if (memq system-type '(usg-unix-v dgux hpux irix))
1615
21e2defc55c0 * lpr.el (lpr-command, lpr-switches): Removed strings starting
Jim Blandy <jimb@redhat.com>
parents: 1463
diff changeset
76 "lp" "lpr")
17414
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
77 "*Name of program for printing a file."
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
78 :type 'string
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
79 :group 'lpr)
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
80
10637
6e25c10f6fe8 (lpr-headers-switches): Default is nil.
Richard M. Stallman <rms@gnu.org>
parents: 10054
diff changeset
81 ;; Default is nil, because that enables us to use pr -f
6e25c10f6fe8 (lpr-headers-switches): Default is nil.
Richard M. Stallman <rms@gnu.org>
parents: 10054
diff changeset
82 ;; which is more reliable than pr with no args, which is what lpr -p does.
17414
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
83 (defcustom lpr-headers-switches nil
13894
eeee95f4d989 (lpr-page-header-switches, lpr-headers-switches): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13803
diff changeset
84 "*List of strings of options to request page headings in the printer program.
10637
6e25c10f6fe8 (lpr-headers-switches): Default is nil.
Richard M. Stallman <rms@gnu.org>
parents: 10054
diff changeset
85 If nil, we run `lpr-page-header-program' to make page headings
17414
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
86 and print the result."
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
87 :type '(repeat (string :tag "Argument"))
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
88 :group 'lpr)
5267
f7ea27a729b8 (lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents: 5004
diff changeset
89
17414
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
90 (defcustom print-region-function nil
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
91 "Function to call to print the region on a printer.
17414
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
92 See definition of `print-region-1' for calling conventions."
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
93 :type 'function
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
94 :group 'lpr)
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
95
17414
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
96 (defcustom lpr-page-header-program "pr"
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
97 "*Name of program for adding page headers to a file."
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
98 :type 'string
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
99 :group 'lpr)
9187
8cf9181c119e (print-region-1): Use them instead of just pr.
Richard M. Stallman <rms@gnu.org>
parents: 8598
diff changeset
100
17813
2e13bced7aff (lpr-page-header-switches): Use -F, not -f.
Richard M. Stallman <rms@gnu.org>
parents: 17695
diff changeset
101 ;; Berkeley systems support -F, and GNU pr supports both -f and -F,
2e13bced7aff (lpr-page-header-switches): Use -F, not -f.
Richard M. Stallman <rms@gnu.org>
parents: 17695
diff changeset
102 ;; So it looks like -F is a better default.
17865
bbcdcb97c227 (lpr-page-header-switches): Remove extra paren.
Richard M. Stallman <rms@gnu.org>
parents: 17813
diff changeset
103 (defcustom lpr-page-header-switches '("-F")
13894
eeee95f4d989 (lpr-page-header-switches, lpr-headers-switches): Doc fixes.
Richard M. Stallman <rms@gnu.org>
parents: 13803
diff changeset
104 "*List of strings to use as options for the page-header-generating program.
17414
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
105 The variable `lpr-page-header-program' specifies the program to use."
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
106 :type '(repeat string)
f967f12c8ec8 Add defgroup's; use defcustom for user vars.
Richard M. Stallman <rms@gnu.org>
parents: 14188
diff changeset
107 :group 'lpr)
9187
8cf9181c119e (print-region-1): Use them instead of just pr.
Richard M. Stallman <rms@gnu.org>
parents: 8598
diff changeset
108
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 216
diff changeset
109 ;;;###autoload
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
110 (defun lpr-buffer ()
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
111 "Print buffer contents as with Unix command `lpr'.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
112 `lpr-switches' is a list of extra switches (strings) to pass to lpr."
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
113 (interactive)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
114 (print-region-1 (point-min) (point-max) lpr-switches nil))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
115
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 216
diff changeset
116 ;;;###autoload
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
117 (defun print-buffer ()
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
118 "Print buffer contents as with Unix command `lpr -p'.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
119 `lpr-switches' is a list of extra switches (strings) to pass to lpr."
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
120 (interactive)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
121 (print-region-1 (point-min) (point-max) lpr-switches t))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
122
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 216
diff changeset
123 ;;;###autoload
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
124 (defun lpr-region (start end)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
125 "Print region contents as with Unix command `lpr'.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
126 `lpr-switches' is a list of extra switches (strings) to pass to lpr."
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
127 (interactive "r")
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
128 (print-region-1 start end lpr-switches nil))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
129
256
7e4c7ef44243 *** empty log message ***
Roland McGrath <roland@gnu.org>
parents: 216
diff changeset
130 ;;;###autoload
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
131 (defun print-region (start end)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
132 "Print region contents as with Unix command `lpr -p'.
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
133 `lpr-switches' is a list of extra switches (strings) to pass to lpr."
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
134 (interactive "r")
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
135 (print-region-1 start end lpr-switches t))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
136
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
137 (defun print-region-1 (start end switches page-headers)
8113
6a12a2845ccc (print-region-1): Essentially undo previous change.
Richard M. Stallman <rms@gnu.org>
parents: 8021
diff changeset
138 ;; On some MIPS system, having a space in the job name
6a12a2845ccc (print-region-1): Essentially undo previous change.
Richard M. Stallman <rms@gnu.org>
parents: 8021
diff changeset
139 ;; crashes the printer demon. But using dashes looks ugly
6a12a2845ccc (print-region-1): Essentially undo previous change.
Richard M. Stallman <rms@gnu.org>
parents: 8021
diff changeset
140 ;; and it seems to annoying to do for that MIPS system.
6a12a2845ccc (print-region-1): Essentially undo previous change.
Richard M. Stallman <rms@gnu.org>
parents: 8021
diff changeset
141 (let ((name (concat (buffer-name) " Emacs buffer"))
8020
23deb92071c6 (print-region-1): Don't include a space in the job name.
Richard M. Stallman <rms@gnu.org>
parents: 7300
diff changeset
142 (title (concat (buffer-name) " Emacs buffer"))
21569
c1f86e273a38 (print-region-1): Stop using binary-process-{in,out}put,
Eli Zaretskii <eliz@gnu.org>
parents: 20278
diff changeset
143 ;; Make pipes use the same coding system as
c1f86e273a38 (print-region-1): Stop using binary-process-{in,out}put,
Eli Zaretskii <eliz@gnu.org>
parents: 20278
diff changeset
144 ;; writing the buffer to a file would.
c1f86e273a38 (print-region-1): Stop using binary-process-{in,out}put,
Eli Zaretskii <eliz@gnu.org>
parents: 20278
diff changeset
145 (coding-system-for-write
c1f86e273a38 (print-region-1): Stop using binary-process-{in,out}put,
Eli Zaretskii <eliz@gnu.org>
parents: 20278
diff changeset
146 (or coding-system-for-write buffer-file-coding-system))
c1f86e273a38 (print-region-1): Stop using binary-process-{in,out}put,
Eli Zaretskii <eliz@gnu.org>
parents: 20278
diff changeset
147 (coding-system-for-read
c1f86e273a38 (print-region-1): Stop using binary-process-{in,out}put,
Eli Zaretskii <eliz@gnu.org>
parents: 20278
diff changeset
148 (or coding-system-for-read buffer-file-coding-system))
10708
8a15461d4f64 (print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents: 10700
diff changeset
149 (width tab-width)
8a15461d4f64 (print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents: 10700
diff changeset
150 switch-string)
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
151 (save-excursion
10708
8a15461d4f64 (print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents: 10700
diff changeset
152 (if page-headers
8a15461d4f64 (print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents: 10700
diff changeset
153 (if lpr-headers-switches
8a15461d4f64 (print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents: 10700
diff changeset
154 ;; It is possible to use an lpr option
8a15461d4f64 (print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents: 10700
diff changeset
155 ;; to get page headers.
8a15461d4f64 (print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents: 10700
diff changeset
156 (setq switches (append (if (stringp lpr-headers-switches)
8a15461d4f64 (print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents: 10700
diff changeset
157 (list lpr-headers-switches)
8a15461d4f64 (print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents: 10700
diff changeset
158 lpr-headers-switches)
8a15461d4f64 (print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents: 10700
diff changeset
159 switches))))
8a15461d4f64 (print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents: 10700
diff changeset
160 (setq switch-string
8a15461d4f64 (print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents: 10700
diff changeset
161 (if switches (concat " with options "
8a15461d4f64 (print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents: 10700
diff changeset
162 (mapconcat 'identity switches " "))
8a15461d4f64 (print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents: 10700
diff changeset
163 ""))
8a15461d4f64 (print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents: 10700
diff changeset
164 (message "Spooling%s..." switch-string)
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
165 (if (/= tab-width 8)
10700
f6f235bc26ba (print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents: 10670
diff changeset
166 (let ((new-coords (print-region-new-buffer start end)))
f6f235bc26ba (print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents: 10670
diff changeset
167 (setq start (car new-coords) end (cdr new-coords))
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
168 (setq tab-width width)
4446
ff1f9d7addd9 (print-region-1): Make END a marker so untabify relocates it.
Richard M. Stallman <rms@gnu.org>
parents: 2382
diff changeset
169 (save-excursion
ff1f9d7addd9 (print-region-1): Make END a marker so untabify relocates it.
Richard M. Stallman <rms@gnu.org>
parents: 2382
diff changeset
170 (goto-char end)
ff1f9d7addd9 (print-region-1): Make END a marker so untabify relocates it.
Richard M. Stallman <rms@gnu.org>
parents: 2382
diff changeset
171 (setq end (point-marker)))
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
172 (untabify (point-min) (point-max))))
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
173 (if page-headers
5267
f7ea27a729b8 (lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents: 5004
diff changeset
174 (if lpr-headers-switches
10708
8a15461d4f64 (print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents: 10700
diff changeset
175 ;; We handled this above by modifying SWITCHES.
8a15461d4f64 (print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents: 10700
diff changeset
176 nil
10637
6e25c10f6fe8 (lpr-headers-switches): Default is nil.
Richard M. Stallman <rms@gnu.org>
parents: 10054
diff changeset
177 ;; Run a separate program to get page headers.
10700
f6f235bc26ba (print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents: 10670
diff changeset
178 (let ((new-coords (print-region-new-buffer start end)))
f6f235bc26ba (print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents: 10670
diff changeset
179 (setq start (car new-coords) end (cdr new-coords)))
10670
f759e91a1654 (lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents: 10643
diff changeset
180 (apply 'call-process-region start end lpr-page-header-program
f759e91a1654 (lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents: 10643
diff changeset
181 t t nil
20278
17c72edb5980 (print-region-1): When running pr, use -h always.
Karl Heuer <kwzh@gnu.org>
parents: 17865
diff changeset
182 (nconc (list "-h" title)
10670
f759e91a1654 (lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents: 10643
diff changeset
183 lpr-page-header-switches))
5267
f7ea27a729b8 (lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents: 5004
diff changeset
184 (setq start (point-min) end (point-max))))
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
185 (apply (or print-region-function 'call-process-region)
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
186 (nconc (list start end lpr-command
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
187 nil nil nil)
10670
f759e91a1654 (lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents: 10643
diff changeset
188 (nconc (and lpr-add-switches
f759e91a1654 (lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents: 10643
diff changeset
189 (list "-J" name))
f759e91a1654 (lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents: 10643
diff changeset
190 ;; These belong in pr if we are using that.
f759e91a1654 (lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents: 10643
diff changeset
191 (and lpr-add-switches lpr-headers-switches
f759e91a1654 (lpr-add-switches): Renamed from lpr-add-options.
Richard M. Stallman <rms@gnu.org>
parents: 10643
diff changeset
192 (list "-T" title))
22679
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
193 (and (stringp printer-name)
08902da4c832 (printer-name): New variable.
Richard M. Stallman <rms@gnu.org>
parents: 21569
diff changeset
194 (list (concat "-P" printer-name)))
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
195 switches)))
4446
ff1f9d7addd9 (print-region-1): Make END a marker so untabify relocates it.
Richard M. Stallman <rms@gnu.org>
parents: 2382
diff changeset
196 (if (markerp end)
ff1f9d7addd9 (print-region-1): Make END a marker so untabify relocates it.
Richard M. Stallman <rms@gnu.org>
parents: 2382
diff changeset
197 (set-marker end nil))
10708
8a15461d4f64 (print-region-1): Include print options in echo area msgs.
Richard M. Stallman <rms@gnu.org>
parents: 10700
diff changeset
198 (message "Spooling%s...done" switch-string))))
155
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
199
5dfb6532c1b1 Initial revision
Richard M. Stallman <rms@gnu.org>
parents:
diff changeset
200 ;; This function copies the text between start and end
10700
f6f235bc26ba (print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents: 10670
diff changeset
201 ;; into a new buffer, makes that buffer current.
f6f235bc26ba (print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents: 10670
diff changeset
202 ;; It returns the new range to print from the new current buffer
f6f235bc26ba (print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents: 10670
diff changeset
203 ;; as (START . END).
f6f235bc26ba (print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents: 10670
diff changeset
204
5267
f7ea27a729b8 (lpr-headers-switches): Treat hpux like usg-unix-v.
Richard M. Stallman <rms@gnu.org>
parents: 5004
diff changeset
205 (defun print-region-new-buffer (ostart oend)
10700
f6f235bc26ba (print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents: 10670
diff changeset
206 (if (string= (buffer-name) " *spool temp*")
f6f235bc26ba (print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents: 10670
diff changeset
207 (cons ostart oend)
f6f235bc26ba (print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents: 10670
diff changeset
208 (let ((oldbuf (current-buffer)))
f6f235bc26ba (print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents: 10670
diff changeset
209 (set-buffer (get-buffer-create " *spool temp*"))
f6f235bc26ba (print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents: 10670
diff changeset
210 (widen) (erase-buffer)
f6f235bc26ba (print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents: 10670
diff changeset
211 (insert-buffer-substring oldbuf ostart oend)
f6f235bc26ba (print-region-new-buffer): Return new start and end.
Richard M. Stallman <rms@gnu.org>
parents: 10670
diff changeset
212 (cons (point-min) (point-max)))))
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 617
diff changeset
213
2382
030b76db285a (printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
214 (defun printify-region (begin end)
17695
5788aa5f0fd0 (printify-region): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17414
diff changeset
215 "Replace nonprinting characters in region with printable representations.
5788aa5f0fd0 (printify-region): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17414
diff changeset
216 The printable representations use ^ (for ASCII control characters) or hex.
5788aa5f0fd0 (printify-region): Doc fix.
Richard M. Stallman <rms@gnu.org>
parents: 17414
diff changeset
217 The characters tab, linefeed, space, return and formfeed are not affected."
2382
030b76db285a (printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
218 (interactive "r")
030b76db285a (printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
219 (save-excursion
030b76db285a (printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
220 (goto-char begin)
030b76db285a (printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
221 (let (c)
030b76db285a (printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
222 (while (re-search-forward "[\^@-\^h\^k\^n-\^_\177-\377]" end t)
030b76db285a (printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
223 (setq c (preceding-char))
030b76db285a (printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
224 (delete-backward-char 1)
030b76db285a (printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
225 (insert
030b76db285a (printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
226 (if (< c ?\ )
030b76db285a (printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
227 (format "\\^%c" (+ c ?@))
030b76db285a (printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
228 (format "\\%02x" c)))))))
030b76db285a (printify-buffer) Added, debugged from Roland McGrath's printify-buffer code
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 2307
diff changeset
229
11831
7e5af94d9527 Add provide call.
Karl Heuer <kwzh@gnu.org>
parents: 10708
diff changeset
230 (provide 'lpr)
7e5af94d9527 Add provide call.
Karl Heuer <kwzh@gnu.org>
parents: 10708
diff changeset
231
659
505130d1ddf8 *** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents: 617
diff changeset
232 ;;; lpr.el ends here