Mercurial > emacs
comparison lisp/ps-print.el @ 24090:3a9da940e5f2
(ps-printer-name): Update docstring about usage on
MS-DOS and MS-Windows.
(ps-lpr-command): Update docstring as for lpr-command.
(ps-print-region-function): New variable.
(ps-do-despool): Use it.
(ps-do-despool) [ms-dos, windows-nt]: Remove special case code for
DOS/Windows.
author | Andrew Innes <andrewi@gnu.org> |
---|---|
date | Sun, 17 Jan 1999 18:57:20 +0000 |
parents | 32a60498137c |
children | 971efbc0ac2c |
comparison
equal
deleted
inserted
replaced
24089:70954a8be49b | 24090:3a9da940e5f2 |
---|---|
1025 (defcustom ps-printer-name (and (boundp 'printer-name) | 1025 (defcustom ps-printer-name (and (boundp 'printer-name) |
1026 printer-name) | 1026 printer-name) |
1027 "*The name of a local printer for printing PostScript files. | 1027 "*The name of a local printer for printing PostScript files. |
1028 | 1028 |
1029 On Unix-like systems, a string value should be a name understood by | 1029 On Unix-like systems, a string value should be a name understood by |
1030 lpr's -P option; otherwise the value should be nil. | 1030 lpr's -P option; a value of nil means use the value of `printer-name' |
1031 | 1031 instead. Any other value will be ignored. |
1032 On MS-DOS and MS-Windows systems, if the value is a string, then it is | 1032 |
1033 taken as the name of the device to which PostScript files are written. | 1033 On MS-DOS and MS-Windows systems, a string value is taken as the name of |
1034 By default it is the same as `printer-name'; typical non-default | 1034 the printer device or port to which PostScript files are written, |
1035 settings would be \"LPT1\" to \"LPT3\" for parallel printers, or | 1035 provided `ps-lpr-command' is \"\". By default it is the same as |
1036 \"COM1\" to \"COM4\" or \"AUX\" for serial printers, or | 1036 `printer-name'; typical non-default settings would be \"LPT1\" to |
1037 \"//hostname/printer\" for a shared network printer. You can also set | 1037 \"LPT3\" for parallel printers, or \"COM1\" to \"COM4\" or \"AUX\" for |
1038 it to a name of a file, in which case the output gets appended to that | 1038 serial printers, or \"//hostname/printer\" for a shared network printer. |
1039 file. \(Note that `ps-print' package already has facilities for | 1039 You can also set it to a name of a file, in which case the output gets |
1040 printing to a file, so you might as well use them instead of changing | 1040 appended to that file. \(Note that `ps-print' package already has |
1041 the setting of this variable.\) If you want to silently discard the | 1041 facilities for printing to a file, so you might as well use them instead |
1042 printed output, set this to \"NUL\". | 1042 of changing the setting of this variable.\) If you want to silently |
1043 | 1043 discard the printed output, set this to \"NUL\"." |
1044 On DOS/Windows, if the value is anything but a string, PostScript files | 1044 :type '(choice file) |
1045 will be piped to the program given by `ps-lpr-command', with switches | |
1046 given by `ps-lpr-switches', which see." | |
1047 :type '(choice file (other :tag "Pipe to ps-lpr-command" pipe)) | |
1048 :group 'ps-print) | 1045 :group 'ps-print) |
1049 | 1046 |
1050 (defcustom ps-lpr-command lpr-command | 1047 (defcustom ps-lpr-command lpr-command |
1051 "*The shell command for printing a PostScript file." | 1048 "*Name of program for printing a PostScript file. |
1049 | |
1050 On MS-DOS and MS-Windows systems, if the value is an empty string then | |
1051 Emacs will write directly to the printer port named by `ps-printer-name'. | |
1052 The programs `print' and `nprint' (the standard print programs on Windows | |
1053 NT and Novell Netware respectively) are handled specially, using | |
1054 `ps-printer-name' as the destination for output; any other program is | |
1055 treated like `lpr' except that an explicit filename is given as the last | |
1056 argument." | |
1052 :type 'string | 1057 :type 'string |
1053 :group 'ps-print) | 1058 :group 'ps-print) |
1054 | 1059 |
1055 (defcustom ps-lpr-switches lpr-switches | 1060 (defcustom ps-lpr-switches lpr-switches |
1056 "*A list of extra switches to pass to `ps-lpr-command'." | 1061 "*A list of extra switches to pass to `ps-lpr-command'." |
1057 :type '(repeat string) | 1062 :type '(repeat string) |
1063 :group 'ps-print) | |
1064 | |
1065 (defcustom ps-print-region-function nil | |
1066 "Function to call to print the region on a PostScript printer. | |
1067 See definition of `ps-do-despool' for calling conventions." | |
1068 :type 'function | |
1058 :group 'ps-print) | 1069 :group 'ps-print) |
1059 | 1070 |
1060 ;;; Page layout | 1071 ;;; Page layout |
1061 | 1072 |
1062 ;; All page dimensions are in PostScript points. | 1073 ;; All page dimensions are in PostScript points. |
4227 (ps-lpr-switches | 4238 (ps-lpr-switches |
4228 (append | 4239 (append |
4229 (and (stringp ps-printer-name) | 4240 (and (stringp ps-printer-name) |
4230 (list (concat "-P" ps-printer-name))) | 4241 (list (concat "-P" ps-printer-name))) |
4231 ps-lpr-switches))) | 4242 ps-lpr-switches))) |
4232 (if (and (memq system-type '(ms-dos windows-nt)) | 4243 (apply (or ps-print-region-function 'call-process-region) |
4233 (or (and (boundp 'dos-ps-printer) | 4244 (point-min) (point-max) ps-lpr-command nil |
4234 (stringp (symbol-value 'dos-ps-printer))) | 4245 (and (fboundp 'start-process) 0) |
4235 (stringp ps-printer-name))) | 4246 nil |
4236 (let ((printer (or (and (boundp 'dos-ps-printer) | 4247 (ps-flatten-list ; dynamic evaluation |
4237 (stringp (symbol-value 'dos-ps-printer)) | 4248 (mapcar 'ps-eval-switch ps-lpr-switches))))) |
4238 (symbol-value 'dos-ps-printer)) | |
4239 ps-printer-name)) | |
4240 ;; It seems that we must be careful about the | |
4241 ;; directory name that gets added by write-region | |
4242 ;; when using the standard "PRN" or "LPTx" ports. | |
4243 ;; The call can fail if the directory is on a | |
4244 ;; network drive. | |
4245 (safe-dir (or (getenv "windir") (getenv "TMPDIR") "c:/"))) | |
4246 (write-region (point-min) (point-max) | |
4247 (expand-file-name printer safe-dir) t 0)) | |
4248 (apply 'call-process-region | |
4249 (point-min) (point-max) ps-lpr-command nil | |
4250 (and (fboundp 'start-process) 0) | |
4251 nil | |
4252 (ps-flatten-list ; dynamic evaluation | |
4253 (mapcar 'ps-eval-switch ps-lpr-switches)))))) | |
4254 (and ps-razzle-dazzle (message "Printing...done"))) | 4249 (and ps-razzle-dazzle (message "Printing...done"))) |
4255 (kill-buffer ps-spool-buffer))) | 4250 (kill-buffer ps-spool-buffer))) |
4256 | 4251 |
4257 ;; Dynamic evaluation | 4252 ;; Dynamic evaluation |
4258 (defun ps-eval-switch (arg) | 4253 (defun ps-eval-switch (arg) |