Mercurial > emacs
comparison lisp/printing.el @ 56390:e97dd6ea9f71
It uses call-process instead shell-command
author | Vinicius Jose Latorre <viniciusjl@ig.com.br> |
---|---|
date | Sat, 10 Jul 2004 22:14:18 +0000 |
parents | 1c61b23bf7f9 |
children | 10b68aa88abe 029a652ac817 |
comparison
equal
deleted
inserted
replaced
56389:8e3ca382cbdb | 56390:e97dd6ea9f71 |
---|---|
1 ;;; printing.el --- printing utilities | 1 ;;; printing.el --- printing utilities |
2 | 2 |
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004 | 3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004 |
4 ;; Free Software Foundation, Inc. | 4 ;; Free Software Foundation, Inc. |
5 | 5 |
6 ;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br> | 6 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br> |
7 ;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br> | 7 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br> |
8 ;; Time-stamp: <2004/04/05 23:41:49 vinicius> | 8 ;; Time-stamp: <2004/07/10 18:48:24 vinicius> |
9 ;; Keywords: wp, print, PostScript | 9 ;; Keywords: wp, print, PostScript |
10 ;; Version: 6.7.4 | 10 ;; Version: 6.8 |
11 ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/ | 11 ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/ |
12 | 12 |
13 (defconst pr-version "6.7.4" | 13 (defconst pr-version "6.8" |
14 "printing.el, v 6.7.4 <2004/03/31 vinicius> | 14 "printing.el, v 6.8 <2004/07/10 vinicius> |
15 | 15 |
16 Please send all bug fixes and enhancements to | 16 Please send all bug fixes and enhancements to |
17 Vinicius Jose Latorre <vinicius@cpqd.com.br> | 17 Vinicius Jose Latorre <viniciusjl@ig.com.br> |
18 ") | 18 ") |
19 | 19 |
20 ;; This file is part of GNU Emacs. | 20 ;; This file is part of GNU Emacs. |
21 | 21 |
22 ;; GNU Emacs is free software; you can redistribute it and/or modify it under | 22 ;; GNU Emacs is free software; you can redistribute it and/or modify it under |
38 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 38 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
39 ;; | 39 ;; |
40 ;; Introduction | 40 ;; Introduction |
41 ;; ------------ | 41 ;; ------------ |
42 ;; | 42 ;; |
43 ;; This package provides some printing utilities that includes | 43 ;; This package provides an user interface to some printing utilities that |
44 ;; previewing/printing a PostScript file, printing a text file and | 44 ;; includes previewing/printing a PostScript file, printing a text file and |
45 ;; previewing/printing some major modes (like mh-folder-mode, | 45 ;; previewing/printing some major modes (like mh-folder-mode, |
46 ;; rmail-summary-mode, gnus-summary-mode, etc). | 46 ;; rmail-summary-mode, gnus-summary-mode, etc). It also includes a |
47 ;; PostScript/text printer database. | |
48 ;; | |
49 ;; Indeed, there are two user interfaces: | |
50 ;; | |
51 ;; * one is via menubar: | |
52 ;; When `printing' is loaded, the menubar is modified to use `printing' | |
53 ;; menu instead of the print options in menubar. | |
54 ;; This is the default user interface. | |
55 ;; | |
56 ;; * other is via buffer interface: | |
57 ;; It is an option of `printing' menu, but it can be binded into another | |
58 ;; key, so user can activate the buffer interface directly without using | |
59 ;; a menu. See `pr-interface' command. | |
47 ;; | 60 ;; |
48 ;; `printing' was inspired on: | 61 ;; `printing' was inspired on: |
49 ;; | 62 ;; |
50 ;; print-nt.el Frederic Corne <frederic.corne@erli.fr> | 63 ;; print-nt.el Frederic Corne <frederic.corne@erli.fr> |
51 ;; Special printing functions for Windows NT | 64 ;; Special printing functions for Windows NT |
170 ;; | 183 ;; |
171 ;; | 184 ;; |
172 ;; Tips | 185 ;; Tips |
173 ;; ---- | 186 ;; ---- |
174 ;; | 187 ;; |
175 ;; 1. If your have a local printer, that is, a printer which is connected | 188 ;; 1. If you have a local printer, that is, a printer which is connected |
176 ;; directly to your computer, don't forget to connect the printer to your | 189 ;; directly to your computer, don't forget to connect the printer to your |
177 ;; computer before printing. | 190 ;; computer before printing. |
178 ;; | 191 ;; |
179 ;; 2. If you try to print a file and it seems that the file was printed, but | 192 ;; 2. If you try to print a file and it seems that the file was printed, but |
180 ;; there is no paper in the printer, then try to set `pr-delete-temp-file' | 193 ;; there is no paper in the printer, then try to set `pr-delete-temp-file' |
185 ;; modifying while `printing' tries to print. Eventually you got an error | 198 ;; modifying while `printing' tries to print. Eventually you got an error |
186 ;; message. Instead, save the dynamic buffer to a file or copy it in | 199 ;; message. Instead, save the dynamic buffer to a file or copy it in |
187 ;; another buffer and, then, print the file or the new static buffer. | 200 ;; another buffer and, then, print the file or the new static buffer. |
188 ;; An example of dynamic buffer is the *Messages* buffer. | 201 ;; An example of dynamic buffer is the *Messages* buffer. |
189 ;; | 202 ;; |
190 ;; 4. When running Emacs on Windows with cygwin, check if the | 203 ;; 4. When running Emacs on Windows (with or without cygwin), check if your |
191 ;; `pr-shell-file-name' variable is set to the proper shell. This shell | 204 ;; printer is a text printer or not by typing in a DOS window: |
192 ;; will execute the commands to preview/print the buffer, file or directory. | 205 ;; |
193 ;; Also check the setting of `pr-path-style' variable. | 206 ;; print /D:\\host\printer somefile.txt |
194 ;; Probably, you should use: | 207 ;; |
195 ;; | 208 ;; Where, `host' is the machine where your printer is directly connected, |
196 ;; (setq pr-shell-file-name "bash") | 209 ;; `printer' is the printer name and `somefile.txt' is a text file. |
197 ;; (setq pr-path-style 'unix) | 210 ;; |
198 ;; | 211 ;; If the printer `\\host\printer' doesn't print the content of |
199 ;; And use / instead of \ when specifying a directory. | 212 ;; `somefile.txt' or, instead, it returns the following message: |
213 ;; | |
214 ;; PostScript Error Handler | |
215 ;; Offending Command = CCC | |
216 ;; Stack = | |
217 ;; | |
218 ;; Where `CCC' is whatever is at the beginning of the text to be printed. | |
219 ;; | |
220 ;; Therefore, the printer `\\host\printer' is not a text printer, but a | |
221 ;; PostScript printer. So, please, don't include this printer in | |
222 ;; `pr-txt-printer-alist' (which see). | |
200 ;; | 223 ;; |
201 ;; | 224 ;; |
202 ;; Using `printing' | 225 ;; Using `printing' |
203 ;; ---------------- | 226 ;; ---------------- |
204 ;; | 227 ;; |
477 ;; ignored in interface buffer. | 500 ;; ignored in interface buffer. |
478 ;; | 501 ;; |
479 ;; `pr-buffer-verbose' Non-nil means to be verbose when editing a | 502 ;; `pr-buffer-verbose' Non-nil means to be verbose when editing a |
480 ;; field in interface buffer. | 503 ;; field in interface buffer. |
481 ;; | 504 ;; |
482 ;; `pr-shell-file-name' Specify file name to load inferior shells | |
483 ;; from. | |
484 ;; | |
485 ;; To set the above options you may: | 505 ;; To set the above options you may: |
486 ;; | 506 ;; |
487 ;; a) insert the code in your ~/.emacs, like: | 507 ;; a) insert the code in your ~/.emacs, like: |
488 ;; | 508 ;; |
489 ;; (setq pr-faces-p t) | 509 ;; (setq pr-faces-p t) |
910 | 930 |
911 (require 'lpr) | 931 (require 'lpr) |
912 (require 'ps-print) | 932 (require 'ps-print) |
913 | 933 |
914 | 934 |
915 (and (string< ps-print-version "6.5.7") | 935 (and (string< ps-print-version "6.6.4") |
916 (error "`printing' requires `ps-print' package version 6.5.7 or later.")) | 936 (error "`printing' requires `ps-print' package version 6.6.4 or later.")) |
917 | 937 |
918 | 938 |
919 (eval-and-compile | 939 (eval-and-compile |
920 (defconst pr-cygwin-system | 940 (defconst pr-cygwin-system |
921 (and ps-windows-system (getenv "OSTYPE") | 941 (and ps-windows-system (getenv "OSTYPE") |
1060 "Replace dos/windows-style directory separator character with unix one." | 1080 "Replace dos/windows-style directory separator character with unix one." |
1061 (interactive "sPath: ") | 1081 (interactive "sPath: ") |
1062 (if (eq pr-path-style 'windows) | 1082 (if (eq pr-path-style 'windows) |
1063 (subst-char-in-string ?\\ ?/ path) | 1083 (subst-char-in-string ?\\ ?/ path) |
1064 path)) | 1084 path)) |
1085 | |
1086 | |
1087 (defun pr-standard-path (path) | |
1088 "Ensure the proper directory separator depending on the OS. | |
1089 That is, if Emacs is running on DOS/Windows, ensure dos/windows-style directory | |
1090 separator; otherwise, ensure unix-style directory separator." | |
1091 (if (or pr-cygwin-system ps-windows-system) | |
1092 (subst-char-in-string ?/ ?\\ path) | |
1093 (subst-char-in-string ?\\ ?/ path))) | |
1065 | 1094 |
1066 | 1095 |
1067 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1096 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1068 ;; User Interface (II) | 1097 ;; User Interface (II) |
1069 | 1098 |
2312 It's used by `pr-interface'." | 2341 It's used by `pr-interface'." |
2313 :type 'boolean | 2342 :type 'boolean |
2314 :group 'printing) | 2343 :group 'printing) |
2315 | 2344 |
2316 | 2345 |
2317 (defcustom pr-shell-file-name | |
2318 (if (and (not pr-cygwin-system) | |
2319 ps-windows-system) | |
2320 "cmdproxy.exe" | |
2321 shell-file-name) | |
2322 "*Specify file name to load inferior shells from." | |
2323 :type 'string | |
2324 :group 'printing) | |
2325 | |
2326 | |
2327 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 2346 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
2328 ;; Internal Variables | 2347 ;; Internal Variables |
2329 | 2348 |
2330 | 2349 |
2331 (defvar pr-txt-command nil | 2350 (defvar pr-txt-command nil |
2408 ((eq ps-print-emacs-type 'emacs) ; GNU Emacs | 2427 ((eq ps-print-emacs-type 'emacs) ; GNU Emacs |
2409 (defsubst pr-region-active-p () | 2428 (defsubst pr-region-active-p () |
2410 (and pr-auto-region transient-mark-mode mark-active))) | 2429 (and pr-auto-region transient-mark-mode mark-active))) |
2411 | 2430 |
2412 ((eq ps-print-emacs-type 'xemacs) ; XEmacs | 2431 ((eq ps-print-emacs-type 'xemacs) ; XEmacs |
2432 (defvar zmacs-region-stays nil) ; to avoid compilation gripes | |
2413 (defsubst pr-region-active-p () | 2433 (defsubst pr-region-active-p () |
2414 (and pr-auto-region (not zmacs-region-stays) (ps-mark-active-p))))) | 2434 (and pr-auto-region (not zmacs-region-stays) (ps-mark-active-p))))) |
2415 | 2435 |
2416 | 2436 |
2417 (defconst pr-menu-spec | 2437 (defconst pr-menu-spec |
3790 ;;;###autoload | 3810 ;;;###autoload |
3791 (defun pr-ps-file-preview (filename) | 3811 (defun pr-ps-file-preview (filename) |
3792 "Preview PostScript file FILENAME." | 3812 "Preview PostScript file FILENAME." |
3793 (interactive (list (pr-ps-infile-preprint "Preview "))) | 3813 (interactive (list (pr-ps-infile-preprint "Preview "))) |
3794 (and (stringp filename) (file-exists-p filename) | 3814 (and (stringp filename) (file-exists-p filename) |
3795 (let ((shell-file-name pr-shell-file-name)) | 3815 (pr-call-process pr-gv-command filename))) |
3796 (start-process-shell-command "PREVIEW" "*Messages*" | |
3797 (pr-command pr-gv-command) filename)))) | |
3798 | 3816 |
3799 | 3817 |
3800 ;;;###autoload | 3818 ;;;###autoload |
3801 (defun pr-ps-file-up-preview (n-up ifilename &optional ofilename) | 3819 (defun pr-ps-file-up-preview (n-up ifilename &optional ofilename) |
3802 "Preview PostScript file FILENAME." | 3820 "Preview PostScript file FILENAME." |
3813 (interactive (list (pr-ps-infile-preprint "Print preview "))) | 3831 (interactive (list (pr-ps-infile-preprint "Print preview "))) |
3814 (and (stringp filename) (file-exists-p filename) | 3832 (and (stringp filename) (file-exists-p filename) |
3815 (let* ((file (pr-expand-file-name filename)) | 3833 (let* ((file (pr-expand-file-name filename)) |
3816 (tempfile (pr-dosify-path (make-temp-name file)))) | 3834 (tempfile (pr-dosify-path (make-temp-name file)))) |
3817 ;; gs use | 3835 ;; gs use |
3818 (pr-shell-command | 3836 (pr-call-process pr-gs-command |
3819 (concat (pr-command pr-gs-command) | 3837 (format "-sDEVICE=%s" pr-gs-device) |
3820 " -sDEVICE=" pr-gs-device | 3838 (format "-r%d" pr-gs-resolution) |
3821 " -r" (int-to-string pr-gs-resolution) | 3839 (pr-switches-string pr-gs-switches "pr-gs-switches") |
3822 " " (pr-switches-string pr-gs-switches "pr-gs-switches") | 3840 (format "-sOutputFile=\"%s\"" tempfile) |
3823 " -sOutputFile=" tempfile " " file " -c quit")) | 3841 file |
3842 "-c quit") | |
3824 ;; printing | 3843 ;; printing |
3825 (pr-ps-file-print tempfile) | 3844 (pr-ps-file-print tempfile) |
3826 ;; deleting | 3845 ;; deleting |
3827 (pr-delete-file tempfile)))) | 3846 (pr-delete-file tempfile)))) |
3828 | 3847 |
3839 (save-excursion | 3858 (save-excursion |
3840 (set-buffer ps-spool-buffer) | 3859 (set-buffer ps-spool-buffer) |
3841 (erase-buffer) | 3860 (erase-buffer) |
3842 (insert-file-contents-literally file)) | 3861 (insert-file-contents-literally file)) |
3843 (pr-despool-print)) | 3862 (pr-despool-print)) |
3844 (pr-shell-command | 3863 (apply 'pr-call-process |
3845 (concat (pr-command pr-ps-command) " " | 3864 pr-ps-command |
3846 (pr-switches-string pr-ps-switches "pr-gs-switches") " " | 3865 (pr-switches-string pr-ps-switches "pr-gs-switches") |
3847 (if (string-match "cp" pr-ps-command) | 3866 (if (string-match "cp" pr-ps-command) |
3848 ;; for "cp" (cmd in out) | 3867 ;; for "cp" (cmd in out) |
3849 (concat "\"" file "\" " | 3868 (list file |
3850 pr-ps-printer-switch pr-ps-printer) | 3869 (concat pr-ps-printer-switch pr-ps-printer)) |
3851 ;; else, for others (cmd out in) | 3870 ;; else, for others (cmd out in) |
3852 (concat pr-ps-printer-switch pr-ps-printer | 3871 (list (concat pr-ps-printer-switch pr-ps-printer) |
3853 " \"" file "\"")))))))) | 3872 file))))))) |
3854 | 3873 |
3855 | 3874 |
3856 ;;;###autoload | 3875 ;;;###autoload |
3857 (defun pr-ps-file-ps-print (filename) | 3876 (defun pr-ps-file-ps-print (filename) |
3858 "Send PostScript file FILENAME to printer or use ghostscript to print it." | 3877 "Send PostScript file FILENAME to printer or use ghostscript to print it." |
4250 (let (ps-prefix-quote) | 4269 (let (ps-prefix-quote) |
4251 (mapconcat | 4270 (mapconcat |
4252 #'ps-print-quote | 4271 #'ps-print-quote |
4253 (list | 4272 (list |
4254 (concat "\n;;; printing.el version " pr-version "\n") | 4273 (concat "\n;;; printing.el version " pr-version "\n") |
4255 '(19 . pr-shell-file-name) | 4274 ";; internal vars" |
4256 '(19 . pr-path-style) | 4275 (ps-comment-string "pr-txt-command " pr-txt-command) |
4257 '(19 . pr-path-alist) | 4276 (ps-comment-string "pr-txt-switches " |
4277 (pr-switches-string pr-txt-switches "pr-txt-switches")) | |
4278 (ps-comment-string "pr-txt-printer " pr-txt-printer) | |
4279 (ps-comment-string "pr-ps-command " pr-ps-command) | |
4280 (ps-comment-string "pr-ps-switches " | |
4281 (pr-switches-string pr-ps-switches "pr-ps-switches")) | |
4282 (ps-comment-string "pr-ps-printer-switch" pr-ps-printer-switch) | |
4283 (ps-comment-string "pr-ps-printer " pr-ps-printer) | |
4284 (ps-comment-string "pr-cygwin-system " pr-cygwin-system) | |
4285 (ps-comment-string "ps-windows-system " ps-windows-system) | |
4286 (ps-comment-string "ps-lp-system " ps-lp-system) | |
4287 nil | |
4288 '(14 . pr-path-style) | |
4289 '(14 . pr-path-alist) | |
4258 nil | 4290 nil |
4259 '(21 . pr-txt-name) | 4291 '(21 . pr-txt-name) |
4260 '(21 . pr-txt-printer-alist) | 4292 '(21 . pr-txt-printer-alist) |
4261 nil | 4293 nil |
4262 '(20 . pr-ps-name) | 4294 '(20 . pr-ps-name) |
4568 | 4600 |
4569 (eval-and-compile | 4601 (eval-and-compile |
4570 (cond | 4602 (cond |
4571 ((eq ps-print-emacs-type 'xemacs) | 4603 ((eq ps-print-emacs-type 'xemacs) |
4572 ;; XEmacs | 4604 ;; XEmacs |
4605 (defvar current-mouse-event nil) ; to avoid compilation gripes | |
4573 (defun pr-menu-position (entry index horizontal) | 4606 (defun pr-menu-position (entry index horizontal) |
4574 (pr-x-make-event | 4607 (pr-x-make-event |
4575 'button-release | 4608 'button-release |
4576 (list 'button 1 | 4609 (list 'button 1 |
4577 'x (- (pr-x-event-x-pixel current-mouse-event) ; X | 4610 'x (- (pr-x-event-x-pixel current-mouse-event) ; X |
4631 (setq pr-menu-position nil)))) | 4664 (setq pr-menu-position nil)))) |
4632 | 4665 |
4633 | 4666 |
4634 ((eq ps-print-emacs-type 'xemacs) | 4667 ((eq ps-print-emacs-type 'xemacs) |
4635 ;; XEmacs | 4668 ;; XEmacs |
4669 (defvar current-menubar nil) ; to avoid compilation gripes | |
4636 (defun pr-menu-lookup (path) | 4670 (defun pr-menu-lookup (path) |
4637 (car (pr-x-find-menu-item current-menubar (cons "Printing" path)))) | 4671 (car (pr-x-find-menu-item current-menubar (cons "Printing" path)))) |
4638 | 4672 |
4639 ;; XEmacs | 4673 ;; XEmacs |
4640 (defun pr-menu-lock (entry index horizontal state path) | 4674 (defun pr-menu-lock (entry index horizontal state path) |
4971 value)) | 5005 value)) |
4972 (setq pr-ps-name value | 5006 (setq pr-ps-name value |
4973 pr-ps-command (pr-dosify-path (nth 0 ps)) | 5007 pr-ps-command (pr-dosify-path (nth 0 ps)) |
4974 pr-ps-switches (nth 1 ps) | 5008 pr-ps-switches (nth 1 ps) |
4975 pr-ps-printer-switch (nth 2 ps) | 5009 pr-ps-printer-switch (nth 2 ps) |
4976 pr-ps-printer (pr-dosify-path (nth 3 ps))) | 5010 pr-ps-printer (nth 3 ps)) |
4977 (or (stringp pr-ps-command) | 5011 (or (stringp pr-ps-command) |
4978 (setq pr-ps-command | 5012 (setq pr-ps-command |
4979 (cond (ps-windows-system "print") | 5013 (cond (ps-windows-system "print") |
4980 (ps-lp-system "lp") | 5014 (ps-lp-system "lp") |
4981 (t "lpr") | 5015 (t "lpr") |
4996 (error "Invalid text printer name `%s' for variable `pr-txt-name'." | 5030 (error "Invalid text printer name `%s' for variable `pr-txt-name'." |
4997 value)) | 5031 value)) |
4998 (setq pr-txt-name value | 5032 (setq pr-txt-name value |
4999 pr-txt-command (pr-dosify-path (nth 0 txt)) | 5033 pr-txt-command (pr-dosify-path (nth 0 txt)) |
5000 pr-txt-switches (nth 1 txt) | 5034 pr-txt-switches (nth 1 txt) |
5001 pr-txt-printer (pr-dosify-path (nth 2 txt)))) | 5035 pr-txt-printer (nth 2 txt))) |
5002 (or (stringp pr-txt-command) | 5036 (or (stringp pr-txt-command) |
5003 (setq pr-txt-command | 5037 (setq pr-txt-command |
5004 (cond (ps-windows-system "print") | 5038 (cond (ps-windows-system "print") |
5005 (ps-lp-system "lp") | 5039 (ps-lp-system "lp") |
5006 (t "lpr") | 5040 (t "lpr") |
5209 | 5243 |
5210 (defun pr-ps-utility-process (n-up infile outfile) | 5244 (defun pr-ps-utility-process (n-up infile outfile) |
5211 (let (item) | 5245 (let (item) |
5212 (and (stringp infile) (file-exists-p infile) | 5246 (and (stringp infile) (file-exists-p infile) |
5213 (setq item (cdr (assq pr-ps-utility pr-ps-utility-alist))) | 5247 (setq item (cdr (assq pr-ps-utility pr-ps-utility-alist))) |
5214 (pr-shell-command | 5248 (pr-call-process (nth 0 item) |
5215 (concat (pr-command (nth 0 item)) " " | 5249 (pr-switches-string (nth 1 item) |
5216 (pr-switches-string (nth 1 item) | 5250 "pr-ps-utility-alist entry") |
5217 "pr-ps-utility-alist entry") | 5251 (pr-switches-string (nth 8 item) |
5218 " " | 5252 "pr-ps-utility-alist entry") |
5219 (pr-switches-string (nth 8 item) | 5253 (and (nth 2 item) |
5220 "pr-ps-utility-alist entry") | 5254 (format (nth 2 item) ps-paper-type)) |
5221 " " | 5255 (format (nth 3 item) n-up) |
5222 (and (nth 2 item) | 5256 (and pr-file-landscape (nth 4 item)) |
5223 (format (nth 2 item) ps-paper-type)) | 5257 (and pr-file-duplex (nth 5 item)) |
5224 " " (format (nth 3 item) n-up) " " | 5258 (and pr-file-tumble (nth 6 item)) |
5225 (and pr-file-landscape (nth 4 item)) " " | 5259 (pr-expand-file-name infile) |
5226 (and pr-file-duplex (nth 5 item)) " " | 5260 (nth 7 item) |
5227 (and pr-file-tumble (nth 6 item)) | 5261 (pr-expand-file-name outfile))))) |
5228 " \"" (pr-expand-file-name infile) "\" " | 5262 |
5229 (nth 7 item) | 5263 |
5230 " \"" (pr-expand-file-name outfile) "\""))))) | 5264 (defun pr-remove-nil-from-list (lst) |
5231 | 5265 (while (and lst (null (car lst))) |
5232 | 5266 (setq lst (cdr lst))) |
5233 (defun pr-shell-command (command) | 5267 (let ((b lst) |
5234 (let ((shell-file-name pr-shell-file-name)) | 5268 (l (cdr lst))) |
5235 (shell-command command))) | 5269 (while l |
5270 (if (car l) | |
5271 (setq b l | |
5272 l (cdr l)) | |
5273 (setq l (cdr l)) | |
5274 (setcdr b l)))) | |
5275 lst) | |
5276 | |
5277 | |
5278 (defun pr-call-process (command &rest args) | |
5279 (let ((buffer (get-buffer-create "*Printing Command Output*")) | |
5280 (cmd (pr-command command)) | |
5281 status) | |
5282 (setq args (pr-remove-nil-from-list args)) | |
5283 (save-excursion | |
5284 (set-buffer buffer) | |
5285 (goto-char (point-max)) | |
5286 (insert (format "%s %S\n" cmd args))) | |
5287 (setq status (apply 'call-process cmd nil buffer nil args)) | |
5288 (save-excursion | |
5289 (set-buffer buffer) | |
5290 (goto-char (point-max)) | |
5291 (insert (format "Exit status: %s\n" status))))) | |
5236 | 5292 |
5237 | 5293 |
5238 (defun pr-txt-print (from to) | 5294 (defun pr-txt-print (from to) |
5239 (let ((lpr-command (pr-command pr-txt-command)) | 5295 (let ((lpr-command (pr-standard-path (pr-command pr-txt-command))) |
5240 (lpr-switches (pr-switches pr-txt-switches "pr-txt-switches")) | 5296 (lpr-switches (pr-switches pr-txt-switches "pr-txt-switches")) |
5241 (printer-name pr-txt-printer)) | 5297 (printer-name pr-txt-printer)) |
5242 (lpr-region from to))) | 5298 (lpr-region from to))) |
5243 | 5299 |
5244 | 5300 |