aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2013-07-24 00:37:11 -0400
committerStefan Monnier2013-07-24 00:37:11 -0400
commit2cdeb903c57126d3ad5f0cbd72e182584b76ee29 (patch)
tree2475b4233da4f4e9cd8e54dab9cea3779349767a
parent73600831f34b22ea82c02b2f2005c1ab6004f39c (diff)
downloademacs-2cdeb903c57126d3ad5f0cbd72e182584b76ee29.tar.gz
emacs-2cdeb903c57126d3ad5f0cbd72e182584b76ee29.zip
* lisp/lpr.el: Signal print errors more prominently.
(print-region-function): Don't default to nil. (lpr-print-region): New function, extracted from print-region-1. Check lpr's return value and signal an error in case of problem. (print-region-1): Use it. * lisp/ps-print.el (ps-windows-system, ps-lp-system): Remove. Use the lpr-* versions instead. (ps-printer-name): Default to nil. (ps-printer-name-option): Default to lpr-printer-switch. (ps-print-region-function): Don't default to nil. (ps-postscript-code-directory): Simplify default. (ps-do-despool): Use lpr-print-region to properly check the outcome. (ps-string-list, ps-eval-switch, ps-flatten-list) (ps-flatten-list-1): Remove. (ps-multibyte-buffer): Avoid setq. * lisp/dos-w32.el (direct-print-region-helper): Use proper regexp operators. (print-region-function, ps-print-region-function): Don't set them here.
-rw-r--r--lisp/ChangeLog20
-rw-r--r--lisp/dos-w32.el21
-rw-r--r--lisp/lpr.el116
-rw-r--r--lisp/ps-mule.el1
-rw-r--r--lisp/ps-print.el138
5 files changed, 123 insertions, 173 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 141c3fc6344..4c115d8435a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,23 @@
12013-07-24 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * lpr.el: Signal print errors more prominently.
4 (print-region-function): Don't default to nil.
5 (lpr-print-region): New function, extracted from print-region-1.
6 Check lpr's return value and signal an error in case of problem.
7 (print-region-1): Use it.
8 * ps-print.el (ps-windows-system, ps-lp-system): Remove. Use the lpr-*
9 versions instead.
10 (ps-printer-name): Default to nil.
11 (ps-printer-name-option): Default to lpr-printer-switch.
12 (ps-print-region-function): Don't default to nil.
13 (ps-postscript-code-directory): Simplify default.
14 (ps-do-despool): Use lpr-print-region to properly check the outcome.
15 (ps-string-list, ps-eval-switch, ps-flatten-list)
16 (ps-flatten-list-1): Remove.
17 (ps-multibyte-buffer): Avoid setq.
18 * dos-w32.el (direct-print-region-helper): Use proper regexp operators.
19 (print-region-function, ps-print-region-function): Don't set them here.
20
12013-07-24 Xue Fuqiao <xfq.free@gmail.com> 212013-07-24 Xue Fuqiao <xfq.free@gmail.com>
2 22
3 * ansi-color.el: Fix old URL. 23 * ansi-color.el: Fix old URL.
diff --git a/lisp/dos-w32.el b/lisp/dos-w32.el
index ff4a3ad66f0..0573caa6c23 100644
--- a/lisp/dos-w32.el
+++ b/lisp/dos-w32.el
@@ -257,10 +257,10 @@ filesystem mounted on drive Z:, FILESYSTEM could be \"Z:\"."
257;; Function to actually send data to the printer port. 257;; Function to actually send data to the printer port.
258;; Supports writing directly, and using various programs. 258;; Supports writing directly, and using various programs.
259(defun direct-print-region-helper (printer 259(defun direct-print-region-helper (printer
260 start end 260 start end
261 lpr-prog 261 lpr-prog
262 _delete-text _buf _display 262 _delete-text _buf _display
263 rest) 263 rest)
264 (let* (;; Ignore case when matching known external program names. 264 (let* (;; Ignore case when matching known external program names.
265 (case-fold-search t) 265 (case-fold-search t)
266 ;; Convert / to \ in printer name, for sake of external programs. 266 ;; Convert / to \ in printer name, for sake of external programs.
@@ -295,12 +295,14 @@ filesystem mounted on drive Z:, FILESYSTEM could be \"Z:\"."
295 (unwind-protect 295 (unwind-protect
296 (cond 296 (cond
297 ;; nprint.exe is the standard print command on Netware 297 ;; nprint.exe is the standard print command on Netware
298 ((string-match-p "^nprint\\(\\.exe\\)?$" (file-name-nondirectory lpr-prog)) 298 ((string-match-p "\\`nprint\\(\\.exe\\)?\\'"
299 (file-name-nondirectory lpr-prog))
299 (write-region start end tempfile nil 0) 300 (write-region start end tempfile nil 0)
300 (call-process lpr-prog nil errbuf nil 301 (call-process lpr-prog nil errbuf nil
301 tempfile (concat "P=" printer))) 302 tempfile (concat "P=" printer)))
302 ;; print.exe is a standard command on NT 303 ;; print.exe is a standard command on NT
303 ((string-match-p "^print\\(\\.exe\\)?$" (file-name-nondirectory lpr-prog)) 304 ((string-match-p "\\`print\\(\\.exe\\)?\\'"
305 (file-name-nondirectory lpr-prog))
304 ;; Be careful not to invoke print.exe on MS-DOS or Windows 9x 306 ;; Be careful not to invoke print.exe on MS-DOS or Windows 9x
305 ;; though, because it is a TSR program there (hangs Emacs). 307 ;; though, because it is a TSR program there (hangs Emacs).
306 (or (and (eq system-type 'windows-nt) 308 (or (and (eq system-type 'windows-nt)
@@ -369,7 +371,7 @@ indicates a specific program should be invoked."
369 (write-region-annotate-functions 371 (write-region-annotate-functions
370 (cons 372 (cons
371 (lambda (_start end) 373 (lambda (_start end)
372 (if (not (char-equal (char-before end) ?\C-l)) 374 (if (not (char-equal (char-before end) ?\f))
373 `((,end . "\f")))) 375 `((,end . "\f"))))
374 write-region-annotate-functions)) 376 write-region-annotate-functions))
375 (printer (or (and (boundp 'dos-printer) 377 (printer (or (and (boundp 'dos-printer)
@@ -383,9 +385,7 @@ indicates a specific program should be invoked."
383 (direct-print-region-helper printer start end lpr-prog 385 (direct-print-region-helper printer start end lpr-prog
384 delete-text buf display rest))) 386 delete-text buf display rest)))
385 387
386(defvar print-region-function)
387(defvar lpr-headers-switches) 388(defvar lpr-headers-switches)
388(setq print-region-function 'direct-print-region-function)
389 389
390;; Set this to nil if you have a port of the `pr' program 390;; Set this to nil if you have a port of the `pr' program
391;; (e.g., from GNU Textutils), or if you have an `lpr' 391;; (e.g., from GNU Textutils), or if you have an `lpr'
@@ -416,9 +416,6 @@ indicates a specific program should be invoked."
416 (direct-print-region-helper printer start end lpr-prog 416 (direct-print-region-helper printer start end lpr-prog
417 delete-text buf display rest))) 417 delete-text buf display rest)))
418 418
419(defvar ps-print-region-function)
420(setq ps-print-region-function 'direct-ps-print-region-function)
421
422;(setq ps-lpr-command "gs") 419;(setq ps-lpr-command "gs")
423 420
424;(setq ps-lpr-switches '("-q" "-dNOPAUSE" "-sDEVICE=epson" "-r240x60" 421;(setq ps-lpr-switches '("-q" "-dNOPAUSE" "-sDEVICE=epson" "-r240x60"
diff --git a/lisp/lpr.el b/lisp/lpr.el
index 0b860ed07f1..5aed3bcc484 100644
--- a/lisp/lpr.el
+++ b/lisp/lpr.el
@@ -130,10 +130,13 @@ and print the result."
130 (repeat :tag "Multiple arguments" (string :tag "Argument"))) 130 (repeat :tag "Multiple arguments" (string :tag "Argument")))
131 :group 'lpr) 131 :group 'lpr)
132 132
133(defcustom print-region-function nil 133(defcustom print-region-function
134 (if (memq system-type '(ms-dos windows-nt))
135 #'direct-print-region-function
136 #'call-process-region)
134 "Function to call to print the region on a printer. 137 "Function to call to print the region on a printer.
135See definition of `print-region-1' for calling conventions." 138See definition of `print-region-1' for calling conventions."
136 :type '(choice (const nil) function) 139 :type 'function
137 :group 'lpr) 140 :group 'lpr)
138 141
139(defcustom lpr-page-header-program "pr" 142(defcustom lpr-page-header-program "pr"
@@ -212,35 +215,24 @@ for further customization of the printer command."
212 (print-region-1 start end lpr-switches t)) 215 (print-region-1 start end lpr-switches t))
213 216
214(defun print-region-1 (start end switches page-headers) 217(defun print-region-1 (start end switches page-headers)
218 (and page-headers lpr-headers-switches
219 ;; It's possible to use an lpr option to get page headers.
220 (setq switches (append (if (stringp lpr-headers-switches)
221 (list lpr-headers-switches)
222 lpr-headers-switches)
223 switches)))
215 ;; On some MIPS system, having a space in the job name 224 ;; On some MIPS system, having a space in the job name
216 ;; crashes the printer demon. But using dashes looks ugly 225 ;; crashes the printer demon. But using dashes looks ugly
217 ;; and it seems to annoying to do for that MIPS system. 226 ;; and it seems to annoying to do for that MIPS system.
218 (let ((name (concat (buffer-name) " Emacs buffer")) 227 (save-excursion
219 (title (concat (buffer-name) " Emacs buffer")) 228 (let ((name (concat (buffer-name) " Emacs buffer"))
220 ;; Make pipes use the same coding system as 229 ;; Make pipes use the same coding system as
221 ;; writing the buffer to a file would. 230 ;; writing the buffer to a file would.
222 (coding-system-for-write (or coding-system-for-write 231 (coding-system-for-write (or coding-system-for-write
223 buffer-file-coding-system)) 232 buffer-file-coding-system))
224 (coding-system-for-read (or coding-system-for-read 233 (coding-system-for-read (or coding-system-for-read
225 buffer-file-coding-system)) 234 buffer-file-coding-system))
226 (width tab-width) 235 (width tab-width))
227 nswitches
228 switch-string)
229 (save-excursion
230 (and page-headers lpr-headers-switches
231 ;; It's possible to use an lpr option to get page headers.
232 (setq switches (append (if (stringp lpr-headers-switches)
233 (list lpr-headers-switches)
234 lpr-headers-switches)
235 switches)))
236 (setq nswitches (lpr-flatten-list
237 (mapcar 'lpr-eval-switch ; Dynamic evaluation
238 switches))
239 switch-string (if switches
240 (concat " with options "
241 (mapconcat 'identity switches " "))
242 ""))
243 (message "Spooling%s..." switch-string)
244 (if (/= tab-width 8) 236 (if (/= tab-width 8)
245 (let ((new-coords (print-region-new-buffer start end))) 237 (let ((new-coords (print-region-new-buffer start end)))
246 (setq start (car new-coords) 238 (setq start (car new-coords)
@@ -258,34 +250,48 @@ for further customization of the printer command."
258 (let ((new-coords (print-region-new-buffer start end))) 250 (let ((new-coords (print-region-new-buffer start end)))
259 (apply 'call-process-region (car new-coords) (cdr new-coords) 251 (apply 'call-process-region (car new-coords) (cdr new-coords)
260 lpr-page-header-program t t nil 252 lpr-page-header-program t t nil
261 (mapcar (lambda (e) (format e title)) 253 (mapcar (lambda (e) (format e name))
262 lpr-page-header-switches))) 254 lpr-page-header-switches)))
263 (setq start (point-min) 255 (setq start (point-min)
264 end (point-max)))) 256 end (point-max))))
265 (let ((buf (current-buffer))) 257 (lpr-print-region start end switches name))))
266 (with-temp-buffer 258
267 (let ((tempbuf (current-buffer))) 259(defun lpr-print-region (start end switches name)
268 (with-current-buffer buf 260 (let ((buf (current-buffer))
269 (apply (or print-region-function 'call-process-region) 261 (nswitches (lpr-flatten-list
270 (nconc (list start end lpr-command 262 (mapcar #'lpr-eval-switch ; Dynamic evaluation
271 nil tempbuf nil) 263 switches)))
272 (and lpr-add-switches 264 (switch-string (if switches
273 (list "-J" name)) 265 (concat " with options "
274 ;; These belong in pr if we are using that. 266 (mapconcat #'identity switches " "))
275 (and lpr-add-switches lpr-headers-switches 267 "")))
276 (list "-T" title)) 268 (message "Spooling%s..." switch-string)
277 (and (stringp printer-name) 269 (with-temp-buffer
278 (list (concat lpr-printer-switch 270 (let ((retval
279 printer-name))) 271 (let ((tempbuf (current-buffer)))
280 nswitches)))) 272 (with-current-buffer buf
281 (if (markerp end) 273 (apply (or print-region-function 'call-process-region)
282 (set-marker end nil)) 274 start end lpr-command
283 (message "Spooling%s...done%s%s" switch-string 275 nil tempbuf nil
284 (pcase (count-lines (point-min) (point-max)) 276 (nconc (and name lpr-add-switches
285 (0 "") 277 (list "-J" name))
286 (1 ": ") 278 ;; These belong in pr if we are using that.
287 (_ ":\n")) 279 (and name lpr-add-switches lpr-headers-switches
288 (buffer-string))))))) 280 (list "-T" name))
281 (and (stringp printer-name)
282 (string< "" printer-name)
283 (list (concat lpr-printer-switch
284 printer-name)))
285 nswitches))))))
286 (if (markerp end)
287 (set-marker end nil))
288 (funcall (if (memq retval '(nil 0)) #'message #'user-error)
289 "Spooling%s...done%s%s" switch-string
290 (pcase (count-lines (point-min) (point-max))
291 (0 "")
292 (1 ": ")
293 (_ ":\n"))
294 (buffer-string))))))
289 295
290;; This function copies the text between start and end 296;; This function copies the text between start and end
291;; into a new buffer, makes that buffer current. 297;; into a new buffer, makes that buffer current.
@@ -325,7 +331,7 @@ The characters tab, linefeed, space, return and formfeed are not affected."
325;; Dynamic evaluation 331;; Dynamic evaluation
326(defun lpr-eval-switch (arg) 332(defun lpr-eval-switch (arg)
327 (cond ((stringp arg) arg) 333 (cond ((stringp arg) arg)
328 ((functionp arg) (apply arg nil)) 334 ((functionp arg) (funcall arg))
329 ((symbolp arg) (symbol-value arg)) 335 ((symbolp arg) (symbol-value arg))
330 ((consp arg) (apply (car arg) (cdr arg))) 336 ((consp arg) (apply (car arg) (cdr arg)))
331 (t nil))) 337 (t nil)))
@@ -342,7 +348,7 @@ The characters tab, linefeed, space, return and formfeed are not affected."
342 348
343(defun lpr-flatten-list-1 (list) 349(defun lpr-flatten-list-1 (list)
344 (cond 350 (cond
345 ((null list) (list)) 351 ((null list) nil)
346 ((consp list) 352 ((consp list)
347 (append (lpr-flatten-list-1 (car list)) 353 (append (lpr-flatten-list-1 (car list))
348 (lpr-flatten-list-1 (cdr list)))) 354 (lpr-flatten-list-1 (cdr list))))
diff --git a/lisp/ps-mule.el b/lisp/ps-mule.el
index 059261ac0ac..7f30700bee8 100644
--- a/lisp/ps-mule.el
+++ b/lisp/ps-mule.el
@@ -1058,6 +1058,7 @@ It checks if all multi-byte characters in the region are printable or not."
1058 (= (skip-chars-forward "\x00-\x7F" to) to))) 1058 (= (skip-chars-forward "\x00-\x7F" to) to)))
1059 ;; All characters can be printed by normal PostScript fonts. 1059 ;; All characters can be printed by normal PostScript fonts.
1060 (setq ps-basic-plot-string-function 'ps-basic-plot-string 1060 (setq ps-basic-plot-string-function 'ps-basic-plot-string
1061 ;; FIXME: Doesn't ps-encode-header-string-function take 2 args?
1061 ps-encode-header-string-function 'identity) 1062 ps-encode-header-string-function 'identity)
1062 (setq ps-basic-plot-string-function 'ps-mule-plot-string 1063 (setq ps-basic-plot-string-function 'ps-mule-plot-string
1063 ps-encode-header-string-function 'ps-mule-encode-header-string 1064 ps-encode-header-string-function 'ps-mule-encode-header-string
diff --git a/lisp/ps-print.el b/lisp/ps-print.el
index b5961064cb4..8369afcbbc7 100644
--- a/lisp/ps-print.el
+++ b/lisp/ps-print.el
@@ -1472,12 +1472,6 @@ Please send all bug fixes and enhancements to
1472 (error "`ps-print' only supports Emacs 23 and higher"))) 1472 (error "`ps-print' only supports Emacs 23 and higher")))
1473 1473
1474 1474
1475(defconst ps-windows-system
1476 (memq system-type '(ms-dos windows-nt)))
1477(defconst ps-lp-system
1478 (memq system-type '(usg-unix-v hpux irix)))
1479
1480
1481;; Load XEmacs/Emacs definitions 1475;; Load XEmacs/Emacs definitions
1482(require 'ps-def) 1476(require 'ps-def)
1483 1477
@@ -1676,8 +1670,7 @@ For more information about PostScript document comments, see:
1676 :version "20" 1670 :version "20"
1677 :group 'ps-print-miscellany) 1671 :group 'ps-print-miscellany)
1678 1672
1679(defcustom ps-printer-name (and (boundp 'printer-name) 1673(defcustom ps-printer-name nil
1680 (symbol-value 'printer-name))
1681 "The name of a local printer for printing PostScript files. 1674 "The name of a local printer for printing PostScript files.
1682 1675
1683On Unix-like systems, a string value should be a name understood by lpr's -P 1676On Unix-like systems, a string value should be a name understood by lpr's -P
@@ -1709,12 +1702,8 @@ See also `ps-printer-name-option' for documentation."
1709 :group 'ps-print-printer) 1702 :group 'ps-print-printer)
1710 1703
1711(defcustom ps-printer-name-option 1704(defcustom ps-printer-name-option
1712 (cond (ps-windows-system 1705 (cond (lpr-windows-system "/D:")
1713 "/D:") 1706 (t lpr-printer-switch))
1714 (ps-lp-system
1715 "-d")
1716 (t
1717 "-P" ))
1718 "Option for `ps-printer-name' variable (see it). 1707 "Option for `ps-printer-name' variable (see it).
1719 1708
1720On Unix-like systems, if `lpr' is in use, this should be the string 1709On Unix-like systems, if `lpr' is in use, this should be the string
@@ -1729,8 +1718,6 @@ Set this to \"\" or nil, if the utility given by `ps-lpr-command'
1729needs an empty printer name option--that is, pass the printer name 1718needs an empty printer name option--that is, pass the printer name
1730with no special option preceding it. 1719with no special option preceding it.
1731 1720
1732Any value that is not a string is treated as nil.
1733
1734This variable is used only when `ps-printer-name' is a non-empty string." 1721This variable is used only when `ps-printer-name' is a non-empty string."
1735 :type '(choice :menu-tag "Printer Name Option" 1722 :type '(choice :menu-tag "Printer Name Option"
1736 :tag "Printer Name Option" 1723 :tag "Printer Name Option"
@@ -1782,11 +1769,14 @@ See `ps-lpr-command'."
1782 :version "20" 1769 :version "20"
1783 :group 'ps-print-printer) 1770 :group 'ps-print-printer)
1784 1771
1785(defcustom ps-print-region-function nil 1772(defcustom ps-print-region-function
1773 (if (memq system-type '(ms-dos windows-nt))
1774 #'direct-ps-print-region-function
1775 #'call-process-region)
1786 "Specify a function to print the region on a PostScript printer. 1776 "Specify a function to print the region on a PostScript printer.
1787See definition of `call-process-region' for calling conventions. The fourth 1777See definition of `call-process-region' for calling conventions. The fourth
1788and the sixth arguments are both nil." 1778and the sixth arguments are both nil."
1789 :type '(choice (const nil) function) 1779 :type 'function
1790 :version "20" 1780 :version "20"
1791 :group 'ps-print-printer) 1781 :group 'ps-print-printer)
1792 1782
@@ -1798,7 +1788,7 @@ If it's nil, automatic feeding takes place."
1798 :version "20" 1788 :version "20"
1799 :group 'ps-print-printer) 1789 :group 'ps-print-printer)
1800 1790
1801(defcustom ps-end-with-control-d (and ps-windows-system t) 1791(defcustom ps-end-with-control-d (and lpr-windows-system t)
1802 "Non-nil means insert C-d at end of PostScript file generated." 1792 "Non-nil means insert C-d at end of PostScript file generated."
1803 :version "21.1" 1793 :version "21.1"
1804 :type 'boolean 1794 :type 'boolean
@@ -2636,7 +2626,7 @@ NOTE: page numbers are displayed as part of headers,
2636 :group 'ps-print-headers) 2626 :group 'ps-print-headers)
2637 2627
2638(defcustom ps-spool-config 2628(defcustom ps-spool-config
2639 (if ps-windows-system 2629 (if lpr-windows-system
2640 nil 2630 nil
2641 'lpr-switches) 2631 'lpr-switches)
2642 "Specify who is responsible for setting duplex and page size. 2632 "Specify who is responsible for setting duplex and page size.
@@ -3389,15 +3379,12 @@ It's like the very first character of buffer (or region) is ^L (\\014)."
3389 :group 'ps-print-headers) 3379 :group 'ps-print-headers)
3390 3380
3391(defcustom ps-postscript-code-directory 3381(defcustom ps-postscript-code-directory
3392 (or (if (featurep 'xemacs) 3382 (cond ((fboundp 'locate-data-directory) ; XEmacs
3393 (cond ((fboundp 'locate-data-directory) ; XEmacs 3383 (locate-data-directory "ps-print"))
3394 (funcall 'locate-data-directory "ps-print")) 3384 ((boundp 'data-directory) ; XEmacs and Emacs.
3395 ((boundp 'data-directory) ; XEmacs 3385 data-directory)
3396 (symbol-value 'data-directory)) 3386 (t ; don't know what to do
3397 (t ; don't know what to do 3387 (error "`ps-postscript-code-directory' isn't set properly")))
3398 nil))
3399 data-directory) ; Emacs
3400 (error "`ps-postscript-code-directory' isn't set properly"))
3401 "Directory where it's located the PostScript prologue file used by ps-print. 3388 "Directory where it's located the PostScript prologue file used by ps-print.
3402By default, this directory is the same as in the variable `data-directory'." 3389By default, this directory is the same as in the variable `data-directory'."
3403 :type 'directory 3390 :type 'directory
@@ -3646,8 +3633,7 @@ The table depends on the current ps-print setup."
3646 ") ps-print version " ps-print-version "\n") 3633 ") ps-print version " ps-print-version "\n")
3647 ";; internal vars" 3634 ";; internal vars"
3648 (ps-comment-string "emacs-version " emacs-version) 3635 (ps-comment-string "emacs-version " emacs-version)
3649 (ps-comment-string "ps-windows-system " ps-windows-system) 3636 (ps-comment-string "lpr-windows-system" lpr-windows-system)
3650 (ps-comment-string "ps-lp-system " ps-lp-system)
3651 nil 3637 nil
3652 '(25 . ps-print-color-p) 3638 '(25 . ps-print-color-p)
3653 '(25 . ps-lpr-command) 3639 '(25 . ps-lpr-command)
@@ -5426,8 +5412,8 @@ XSTART YSTART are the relative position for the first page in a sheet.")
5426 "%%Title: " (buffer-name) ; Take job name from name of 5412 "%%Title: " (buffer-name) ; Take job name from name of
5427 ; first buffer printed 5413 ; first buffer printed
5428 "\n%%Creator: ps-print v" ps-print-version 5414 "\n%%Creator: ps-print v" ps-print-version
5429 "\n%%For: " (user-full-name) 5415 "\n%%For: " (user-full-name) ;FIXME: may need encoding!
5430 "\n%%CreationDate: " (format-time-string "%T %b %d %Y") 5416 "\n%%CreationDate: " (format-time-string "%T %b %d %Y") ;FIXME: encoding!
5431 "\n%%Orientation: " 5417 "\n%%Orientation: "
5432 (if ps-landscape-mode "Landscape" "Portrait") 5418 (if ps-landscape-mode "Landscape" "Portrait")
5433 "\n%%DocumentNeededResources: font Times-Roman Times-Italic\n%%+ font " 5419 "\n%%DocumentNeededResources: font Times-Roman Times-Italic\n%%+ font "
@@ -6569,96 +6555,36 @@ If FACE is not a valid face name, use default face."
6569 (write-region (point-min) (point-max) filename)) 6555 (write-region (point-min) (point-max) filename))
6570 (and ps-razzle-dazzle (message "Wrote %s" filename))) 6556 (and ps-razzle-dazzle (message "Wrote %s" filename)))
6571 ;; Else, spool to the printer 6557 ;; Else, spool to the printer
6572 (and ps-razzle-dazzle (message "Printing..."))
6573 (with-current-buffer ps-spool-buffer 6558 (with-current-buffer ps-spool-buffer
6574 (let* ((coding-system-for-write 'raw-text-unix) 6559 (let* ((coding-system-for-write 'raw-text-unix)
6575 (ps-printer-name (or ps-printer-name 6560 (printer-name (or ps-printer-name printer-name))
6576 (and (boundp 'printer-name) 6561 (lpr-printer-switch ps-printer-name-option)
6577 (symbol-value 'printer-name)))) 6562 (print-region-function ps-print-region-function)
6578 (ps-lpr-switches 6563 (lpr-command ps-lpr-command))
6579 (append ps-lpr-switches 6564 (lpr-print-region (point-min) (point-max) ps-lpr-switches nil))))
6580 (and (stringp ps-printer-name)
6581 (string< "" ps-printer-name)
6582 (list (concat
6583 (and (stringp ps-printer-name-option)
6584 ps-printer-name-option)
6585 ps-printer-name))))))
6586 (or (stringp ps-printer-name)
6587 (setq ps-printer-name nil))
6588 (apply (or ps-print-region-function 'call-process-region)
6589 (point-min) (point-max) ps-lpr-command nil
6590 (and (fboundp 'start-process) 0)
6591 nil
6592 (ps-flatten-list ; dynamic evaluation
6593 (ps-string-list
6594 (mapcar 'ps-eval-switch ps-lpr-switches))))))
6595 (and ps-razzle-dazzle (message "Printing...done")))
6596 (kill-buffer ps-spool-buffer))) 6565 (kill-buffer ps-spool-buffer)))
6597 6566
6598(defun ps-string-list (arg)
6599 (let (lstr)
6600 (dolist (elm arg)
6601 (cond ((stringp elm)
6602 (setq lstr (cons elm lstr)))
6603 ((listp elm)
6604 (let ((s (ps-string-list elm)))
6605 (when s
6606 (setq lstr (cons s lstr)))))
6607 (t ))) ; ignore any other value
6608 (nreverse lstr)))
6609
6610;; Dynamic evaluation
6611(defun ps-eval-switch (arg)
6612 (cond ((stringp arg) arg)
6613 ((functionp arg) (apply arg nil))
6614 ((symbolp arg) (symbol-value arg))
6615 ((consp arg) (apply (car arg) (cdr arg)))
6616 (t nil)))
6617
6618;; `ps-flatten-list' is defined here (copied from "message.el" and
6619;; enhanced to handle dotted pairs as well) until we can get some
6620;; sensible autoloads, or `flatten-list' gets put somewhere decent.
6621
6622;; (ps-flatten-list '((a . b) c (d . e) (f g h) i . j))
6623;; => (a b c d e f g h i j)
6624
6625(defun ps-flatten-list (&rest list)
6626 (ps-flatten-list-1 list))
6627
6628(defun ps-flatten-list-1 (list)
6629 (cond ((null list) nil)
6630 ((consp list) (append (ps-flatten-list-1 (car list))
6631 (ps-flatten-list-1 (cdr list))))
6632 (t (list list))))
6633
6634(defun ps-kill-emacs-check () 6567(defun ps-kill-emacs-check ()
6635 (let (ps-buffer) 6568 (let ((ps-buffer (get-buffer ps-spool-buffer-name)))
6636 (and (setq ps-buffer (get-buffer ps-spool-buffer-name)) 6569 (and (buffer-live-p ps-buffer)
6637 (buffer-name ps-buffer) ; check if it's not killed
6638 (buffer-modified-p ps-buffer) 6570 (buffer-modified-p ps-buffer)
6639 (y-or-n-p "Unprinted PostScript waiting; print now? ") 6571 (y-or-n-p "Unprinted PostScript waiting; print now? ")
6640 (ps-despool)) 6572 (ps-despool)))
6641 (and (setq ps-buffer (get-buffer ps-spool-buffer-name)) 6573 (let ((ps-buffer (get-buffer ps-spool-buffer-name)))
6642 (buffer-name ps-buffer) ; check if it's not killed 6574 (and (buffer-live-p ps-buffer)
6643 (buffer-modified-p ps-buffer) 6575 (buffer-modified-p ps-buffer)
6644 (not (yes-or-no-p "Unprinted PostScript waiting; exit anyway? ")) 6576 (not (yes-or-no-p "Unprinted PostScript waiting; exit anyway? "))
6645 (error "Unprinted PostScript")))) 6577 (error "Unprinted PostScript"))))
6646 6578
6647(cond ((fboundp 'add-hook) 6579(unless noninteractive
6648 (unless noninteractive 6580 (add-hook 'kill-emacs-hook #'ps-kill-emacs-check))
6649 (funcall 'add-hook 'kill-emacs-hook 'ps-kill-emacs-check)))
6650 (kill-emacs-hook
6651 (message "Won't override existing `kill-emacs-hook'"))
6652 (t
6653 (setq kill-emacs-hook 'ps-kill-emacs-check)))
6654 6581
6655 6582
6656;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 6583;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
6657;; To make this file smaller, some commands go in a separate file. 6584;; To make this file smaller, some commands go in a separate file.
6658;; But autoload them here to make the separation invisible. 6585;; But autoload them here to make the separation invisible.
6659 6586
6660;;;### (autoloads (ps-mule-end-job ps-mule-begin-job ps-mule-initialize 6587;;;### (autoloads nil "ps-mule" "ps-mule.el" "a90e8414a27ac8fdf093251ac648d761")
6661;;;;;; ps-multibyte-buffer) "ps-mule" "ps-mule.el" "b39f881d3a029049994ef6aa3de93c89")
6662;;; Generated autoloads from ps-mule.el 6588;;; Generated autoloads from ps-mule.el
6663 6589
6664(defvar ps-multibyte-buffer nil "\ 6590(defvar ps-multibyte-buffer nil "\