Mercurial > emacs
comparison lisp/dos-w32.el @ 23802:4052a2875390
(direct-print-region-function): Try to ensure that
printer-name is expanded to a file name on a local drive;
sometimes printing a file loaded from a network volume fails.
(direct-print-region-function): Add a function to
write-region-annotate-functions to append a formfeed character to
the region being printed, if the region doesn't end with a
formfeed already. This avoids creating a second print job
containing a blank page when print spooling is enabled on Windows.
author | Geoff Voelker <voelker@cs.washington.edu> |
---|---|
date | Wed, 02 Dec 1998 23:01:50 +0000 |
parents | 8d1cbb6f0fb9 |
children | d98712ec1252 |
comparison
equal
deleted
inserted
replaced
23801:119fd94ae526 | 23802:4052a2875390 |
---|---|
271 ;; DOS printers need the lines to end with CR-LF pairs, so make | 271 ;; DOS printers need the lines to end with CR-LF pairs, so make |
272 ;; sure it always happens that way, unless the buffer is binary. | 272 ;; sure it always happens that way, unless the buffer is binary. |
273 (let* ((coding coding-system-for-write) | 273 (let* ((coding coding-system-for-write) |
274 (coding-base | 274 (coding-base |
275 (if (null coding) 'undecided (coding-system-base coding))) | 275 (if (null coding) 'undecided (coding-system-base coding))) |
276 (eol-type (coding-system-eol-type coding-base))) | 276 (eol-type (coding-system-eol-type coding-base)) |
277 (write-region-annotate-functions | |
278 (cons | |
279 (lambda (start end) | |
280 ;; Make each print-out start on a new page, but don't waste | |
281 ;; paper if there was a form-feed at the end of this file. | |
282 (if (not (char-equal (char-after (1- end)) ?\C-l)) | |
283 `((,end . "\f")))) | |
284 write-region-annotate-functions))) | |
277 (or (eq coding-system-for-write 'no-conversion) | 285 (or (eq coding-system-for-write 'no-conversion) |
278 (setq coding-system-for-write | 286 (setq coding-system-for-write |
279 (aref eol-type 1))) ; force conversion to DOS EOLs | 287 (aref eol-type 1))) ; force conversion to DOS EOLs |
280 (write-region start end | 288 (let ((printer (or (and (boundp 'dos-printer) |
281 (or (and (boundp 'dos-printer) dos-printer) | 289 (stringp (symbol-value 'dos-printer)) |
282 printer-name) | 290 (symbol-value 'dos-printer)) |
283 t 0) | 291 printer-name)) |
284 ;; Make each print-out start on a new page, but don't waste | 292 ;; It seems that we must be careful about the directory name |
285 ;; paper if there was a form-feed at the end of this file. | 293 ;; that gets added by write-region when using the standard |
286 (if (not (char-equal (char-after (1- end)) ?\C-l)) | 294 ;; "PRN" or "LPTx" ports. The call can fail if the directory |
287 (write-region "\f" nil | 295 ;; is on a network drive. |
288 (or (and (boundp 'dos-printer) dos-printer) | 296 (safe-dir (or (getenv "windir") (getenv "TMPDIR") "c:/"))) |
289 printer-name) | 297 (write-region start end |
290 t 0)))) | 298 (expand-file-name printer safe-dir) t 0)))) |
291 | 299 |
292 ;; Set this to nil if you have a port of the `lpr' program and | 300 ;; Set this to nil if you have a port of the `lpr' program and |
293 ;; you want to use it for printing. If the default setting is | 301 ;; you want to use it for printing. If the default setting is |
294 ;; in effect, `lpr-command' and its switches are ignored when | 302 ;; in effect, `lpr-command' and its switches are ignored when |
295 ;; printing with `lpr-xxx' and `print-xxx'. | 303 ;; printing with `lpr-xxx' and `print-xxx'. |