summaryrefslogtreecommitdiff
path: root/lisp/dos-w32.el
diff options
context:
space:
mode:
authorGeoff Voelker <voelker@cs.washington.edu>1998-12-02 23:01:50 +0000
committerGeoff Voelker <voelker@cs.washington.edu>1998-12-02 23:01:50 +0000
commit36f22224e1b22e6a45448ba634cd6ea57e44e152 (patch)
treec0375cb168e7efdb151c050e25de63882b218bd5 /lisp/dos-w32.el
parent83c75055bc8fc08b34422b2976d442f7f8127cc8 (diff)
downloademacs-36f22224e1b22e6a45448ba634cd6ea57e44e152.tar.gz
(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.
Diffstat (limited to 'lisp/dos-w32.el')
-rw-r--r--lisp/dos-w32.el32
1 files changed, 20 insertions, 12 deletions
diff --git a/lisp/dos-w32.el b/lisp/dos-w32.el
index 4adeb7752b4..624519b6ff7 100644
--- a/lisp/dos-w32.el
+++ b/lisp/dos-w32.el
@@ -273,21 +273,29 @@ START and END."
(let* ((coding coding-system-for-write)
(coding-base
(if (null coding) 'undecided (coding-system-base coding)))
- (eol-type (coding-system-eol-type coding-base)))
+ (eol-type (coding-system-eol-type coding-base))
+ (write-region-annotate-functions
+ (cons
+ (lambda (start end)
+ ;; Make each print-out start on a new page, but don't waste
+ ;; paper if there was a form-feed at the end of this file.
+ (if (not (char-equal (char-after (1- end)) ?\C-l))
+ `((,end . "\f"))))
+ write-region-annotate-functions)))
(or (eq coding-system-for-write 'no-conversion)
(setq coding-system-for-write
(aref eol-type 1))) ; force conversion to DOS EOLs
- (write-region start end
- (or (and (boundp 'dos-printer) dos-printer)
- printer-name)
- t 0)
- ;; Make each print-out start on a new page, but don't waste
- ;; paper if there was a form-feed at the end of this file.
- (if (not (char-equal (char-after (1- end)) ?\C-l))
- (write-region "\f" nil
- (or (and (boundp 'dos-printer) dos-printer)
- printer-name)
- t 0))))
+ (let ((printer (or (and (boundp 'dos-printer)
+ (stringp (symbol-value 'dos-printer))
+ (symbol-value 'dos-printer))
+ printer-name))
+ ;; It seems that we must be careful about the directory name
+ ;; that gets added by write-region when using the standard
+ ;; "PRN" or "LPTx" ports. The call can fail if the directory
+ ;; is on a network drive.
+ (safe-dir (or (getenv "windir") (getenv "TMPDIR") "c:/")))
+ (write-region start end
+ (expand-file-name printer safe-dir) t 0))))
;; Set this to nil if you have a port of the `lpr' program and
;; you want to use it for printing. If the default setting is