| 1 | ;;; printing.el --- printing utilities |
| 2 | |
| 3 | ;; Copyright (C) 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc. |
| 4 | |
| 5 | ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br> |
| 6 | ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br> |
| 7 | ;; Time-stamp: <2005-09-18 05:57:14 deego> |
| 8 | ;; Keywords: wp, print, PostScript |
| 9 | ;; Version: 6.8.4 |
| 10 | ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/ |
| 11 | |
| 12 | (defconst pr-version "6.8.4" |
| 13 | "printing.el, v 6.8.4 <2005/06/11 vinicius> |
| 14 | |
| 15 | Please send all bug fixes and enhancements to |
| 16 | Vinicius Jose Latorre <viniciusjl@ig.com.br> |
| 17 | ") |
| 18 | |
| 19 | ;; This file is part of GNU Emacs. |
| 20 | |
| 21 | ;; GNU Emacs is free software; you can redistribute it and/or modify it under |
| 22 | ;; the terms of the GNU General Public License as published by the Free |
| 23 | ;; Software Foundation; either version 2, or (at your option) any later |
| 24 | ;; version. |
| 25 | |
| 26 | ;; GNU Emacs is distributed in the hope that it will be useful, but WITHOUT ANY |
| 27 | ;; WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 28 | ;; FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
| 29 | ;; details. |
| 30 | |
| 31 | ;; You should have received a copy of the GNU General Public License along with |
| 32 | ;; GNU Emacs; see the file COPYING. If not, write to the Free Software |
| 33 | ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 34 | |
| 35 | ;;; Commentary: |
| 36 | |
| 37 | ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 38 | ;; |
| 39 | ;; Introduction |
| 40 | ;; ------------ |
| 41 | ;; |
| 42 | ;; With `printing' you can preview or print a PostScript file. You can also |
| 43 | ;; print a text file using PostScript, and preview or print buffers that use |
| 44 | ;; certain special modes like mh-folder-mode, rmail-summary-mode, |
| 45 | ;; gnus-summary-mode, etc. This package also includes a PostScript/text |
| 46 | ;; printer database. |
| 47 | ;; |
| 48 | ;; There are two user interfaces: |
| 49 | ;; |
| 50 | ;; * Menu interface: |
| 51 | ;; The `printing' menu replaces the usual print options in the menu bar. |
| 52 | ;; This is the default user interface. |
| 53 | ;; |
| 54 | ;; * Buffer interface: |
| 55 | ;; You can use a buffer interface instead of menus. It looks like a |
| 56 | ;; customization buffer. Basically, it has the same options found in the |
| 57 | ;; menu and some extra options, all this on a buffer. |
| 58 | ;; |
| 59 | ;; `printing' is prepared to run on GNU, Unix and NT systems. |
| 60 | ;; On GNU or Unix system, `printing' depends on gs and gv utilities. |
| 61 | ;; On NT system, `printing' depends on gstools (gswin32.exe and gsview32.exe). |
| 62 | ;; To obtain ghostscript, ghostview and GSview see the URL |
| 63 | ;; `http://www.gnu.org/software/ghostscript/ghostscript.html'. |
| 64 | ;; |
| 65 | ;; `printing' depends on ps-print package to generate PostScript files, to |
| 66 | ;; spool and to despool PostScript buffer. So, `printing' provides an |
| 67 | ;; interface to ps-print package and it also provides some extra stuff. |
| 68 | ;; |
| 69 | ;; To download the latest ps-print package see |
| 70 | ;; `http://www.cpqd.com.br/~vinicius/emacs/ps-print.tar.gz'. |
| 71 | ;; Please, see README file for ps-print installation instructions. |
| 72 | ;; |
| 73 | ;; `printing' was inspired on: |
| 74 | ;; |
| 75 | ;; print-nt.el Frederic Corne <frederic.corne@erli.fr> |
| 76 | ;; Special printing functions for Windows NT |
| 77 | ;; |
| 78 | ;; mh-e-init.el Tom Vogels <tov@ece.cmu.edu> |
| 79 | ;; PS-print for mail messages |
| 80 | ;; |
| 81 | ;; win32-ps-print.el Matthew O. Persico <mpersico@erols.com> |
| 82 | ;; PostScript printing with ghostscript |
| 83 | ;; |
| 84 | ;; ps-print-interface.el Volker Franz <volker.franz@tuebingen.mpg.de> |
| 85 | ;; Graphical front end for ps-print and previewing |
| 86 | ;; |
| 87 | ;; |
| 88 | ;; Log Messages |
| 89 | ;; ------------ |
| 90 | ;; |
| 91 | ;; The buffer *Printing Command Output* is where the `printing' log messages |
| 92 | ;; are inserted. All program called by `printing' has a log entry in the |
| 93 | ;; buffer *Printing Command Output*. A log entry has the following form: |
| 94 | ;; |
| 95 | ;; PROGRAM (ARG...) |
| 96 | ;; MESSAGE |
| 97 | ;; Exit status: CODE |
| 98 | ;; |
| 99 | ;; Where |
| 100 | ;; PROGRAM is the program activated by `printing', |
| 101 | ;; ARG is an argument passed to PROGRAM (it can have more than one argument), |
| 102 | ;; MESSAGE is an error message returned by PROGRAM (it can have no message, if |
| 103 | ;; PROGRAM is successful), |
| 104 | ;; and CODE is a numeric exit status or a signal description string. |
| 105 | ;; |
| 106 | ;; For example, after previewing a PostScript file, *Printing Command Output* |
| 107 | ;; will have the following entry: |
| 108 | ;; |
| 109 | ;; /usr/X11R6/bin/gv ("/home/user/example/file.ps") |
| 110 | ;; Exit status: 0 |
| 111 | ;; |
| 112 | ;; In the example above, the previewing was successful. If during previewing, |
| 113 | ;; you quit gv execution (by typing C-g during Emacs session), the log entry |
| 114 | ;; would be: |
| 115 | ;; |
| 116 | ;; /usr/X11R6/bin/gv ("/home/user/example/file.ps") |
| 117 | ;; Exit status: Quit |
| 118 | ;; |
| 119 | ;; So, if something goes wrong, a good place to take a look is the buffer |
| 120 | ;; *Printing Command Output*. Don't forget to see also the buffer *Messages*, |
| 121 | ;; it can help. |
| 122 | ;; |
| 123 | ;; |
| 124 | ;; Novices (First Users) |
| 125 | ;; --------------------- |
| 126 | ;; |
| 127 | ;; First of all, see printing documentation only to get an idea of what |
| 128 | ;; `printing' is capable. |
| 129 | ;; |
| 130 | ;; Then try to set the variables: `pr-ps-name', `pr-ps-printer-alist', |
| 131 | ;; `pr-txt-name', `pr-txt-printer-alist' and `pr-path-alist'. These variables |
| 132 | ;; are the main variables for printing processing. |
| 133 | ;; |
| 134 | ;; Now, please, see these variables documentation deeper. You can do this by |
| 135 | ;; typing C-h v pr-ps-name RET (for example) if you already loaded printing |
| 136 | ;; package, or by browsing printing.el source file. |
| 137 | ;; |
| 138 | ;; If the documentation isn't clear or if you find a way to improve the |
| 139 | ;; documentation, please, send an email to maintainer. All printing users |
| 140 | ;; will thank you. |
| 141 | ;; |
| 142 | ;; One way to set variables is by calling `pr-customize', customize all |
| 143 | ;; variables and save the customization by future sessions (see Options |
| 144 | ;; section). Other way is by coding your settings on Emacs init file (that is, |
| 145 | ;; ~/.emacs file), see below for a first setting template that it should be |
| 146 | ;; inserted on your ~/.emacs file (or c:/_emacs, if you're using Windows 9x/NT |
| 147 | ;; or MS-DOS): |
| 148 | ;; |
| 149 | ;; * Example of setting for Windows system: |
| 150 | ;; |
| 151 | ;; (require 'printing) ; load printing package |
| 152 | ;; (setq pr-path-alist |
| 153 | ;; '((windows "c:/applications/executables" PATH ghostview mpage) |
| 154 | ;; (ghostview "c:/gs/gsview-dir") |
| 155 | ;; (mpage "c:/mpage-dir") |
| 156 | ;; )) |
| 157 | ;; (setq pr-txt-name 'prt_06a) |
| 158 | ;; (setq pr-txt-printer-alist |
| 159 | ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a") |
| 160 | ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c") |
| 161 | ;; (PRN "" nil "PRN") |
| 162 | ;; (standard "redpr.exe" nil "") |
| 163 | ;; )) |
| 164 | ;; (setq pr-ps-name 'lps_06b) |
| 165 | ;; (setq pr-ps-printer-alist |
| 166 | ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a") |
| 167 | ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b") |
| 168 | ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c") |
| 169 | ;; (lps_08c nil nil nil "\\\\printers\\lps_08c") |
| 170 | ;; (LPT1 "" nil "" "LPT1:") |
| 171 | ;; (PRN "" nil "" "PRN") |
| 172 | ;; (standard "redpr.exe" nil "" "") |
| 173 | ;; )) |
| 174 | ;; (pr-update-menus t) ; update now printer and utility menus |
| 175 | ;; |
| 176 | ;; * Example of setting for GNU or Unix system: |
| 177 | ;; |
| 178 | ;; (require 'printing) ; load printing package |
| 179 | ;; (setq pr-path-alist |
| 180 | ;; '((unix "." "~/bin" ghostview mpage PATH) |
| 181 | ;; (ghostview "$HOME/bin/gsview-dir") |
| 182 | ;; (mpage "$HOME/bin/mpage-dir") |
| 183 | ;; )) |
| 184 | ;; (setq pr-txt-name 'prt_06a) |
| 185 | ;; (setq pr-txt-printer-alist |
| 186 | ;; '((prt_06a "lpr" nil "prt_06a") |
| 187 | ;; (prt_07c nil nil "prt_07c") |
| 188 | ;; )) |
| 189 | ;; (setq pr-ps-name 'lps_06b) |
| 190 | ;; (setq pr-ps-printer-alist |
| 191 | ;; '((lps_06b "lpr" nil "-P" "lps_06b") |
| 192 | ;; (lps_07c "lpr" nil nil "lps_07c") |
| 193 | ;; (lps_08c nil nil nil "lps_08c") |
| 194 | ;; )) |
| 195 | ;; (pr-update-menus t) ; update now printer and utility menus |
| 196 | ;; |
| 197 | ;; |
| 198 | ;; NOTE 1: Don't forget to download and install ghostscript utilities (see |
| 199 | ;; Utilities section). |
| 200 | ;; |
| 201 | ;; NOTE 2: The `printer-name' and `ps-printer-name' variables don't need to be |
| 202 | ;; set, as they are implicit set by `pr-ps-printer-alist' and |
| 203 | ;; `pr-txt-printer-alist'. |
| 204 | ;; |
| 205 | ;; NOTE 3: The duplex feature will only work on PostScript printers that |
| 206 | ;; support this feature. |
| 207 | ;; You can check if your PostScript printer supports duplex feature |
| 208 | ;; by checking the printer manual. Or you can try these steps: |
| 209 | ;; 1. Open a buffer (or use the *scratch* buffer). |
| 210 | ;; 2. Type: |
| 211 | ;; First line (on first page) |
| 212 | ;; ^L |
| 213 | ;; Second line (on second page) |
| 214 | ;; 3. Print this buffer with duplex turned on. |
| 215 | ;; If it's printed 2 (two) sheets of paper, then your PostScript |
| 216 | ;; printer doesn't have duplex feature; otherwise, it's ok, your |
| 217 | ;; printer does have duplex feature. |
| 218 | ;; |
| 219 | ;; NOTE 4: See Tips section. |
| 220 | ;; |
| 221 | ;; |
| 222 | ;; Tips |
| 223 | ;; ---- |
| 224 | ;; |
| 225 | ;; 1. If you have a local printer, that is, a printer which is connected |
| 226 | ;; directly to your computer, don't forget to connect the printer to your |
| 227 | ;; computer before printing. |
| 228 | ;; |
| 229 | ;; 2. If you try to print a file and it seems that the file was printed, but |
| 230 | ;; there is no paper in the printer, then try to set `pr-delete-temp-file' |
| 231 | ;; to nil. Probably `printing' is deleting the temporary file before your |
| 232 | ;; local system can get it to send to the printer. |
| 233 | ;; |
| 234 | ;; 3. Don't try to print a dynamic buffer, that is, a buffer which is |
| 235 | ;; modifying while `printing' tries to print. Eventually you got an error |
| 236 | ;; message. Instead, save the dynamic buffer to a file or copy it in |
| 237 | ;; another buffer and, then, print the file or the new static buffer. |
| 238 | ;; An example of dynamic buffer is the *Messages* buffer. |
| 239 | ;; |
| 240 | ;; 4. When running Emacs on Windows (with or without cygwin), check if your |
| 241 | ;; printer is a text printer or not by typing in a DOS window: |
| 242 | ;; |
| 243 | ;; print /D:\\host\printer somefile.txt |
| 244 | ;; |
| 245 | ;; Where, `host' is the machine where the printer is directly connected, |
| 246 | ;; `printer' is the printer name and `somefile.txt' is a text file. |
| 247 | ;; |
| 248 | ;; If the printer `\\host\printer' doesn't print the content of |
| 249 | ;; `somefile.txt' or, instead, it returns the following message: |
| 250 | ;; |
| 251 | ;; PostScript Error Handler |
| 252 | ;; Offending Command = CCC |
| 253 | ;; Stack = |
| 254 | ;; |
| 255 | ;; Where `CCC' is whatever is at the beginning of the text to be printed. |
| 256 | ;; |
| 257 | ;; Therefore, the printer `\\host\printer' is not a text printer, but a |
| 258 | ;; PostScript printer. So, please, don't include this printer in |
| 259 | ;; `pr-txt-printer-alist' (which see). |
| 260 | ;; |
| 261 | ;; 5. You can use gsprint instead of ghostscript to print monochrome PostScript |
| 262 | ;; files in Windows. The gsprint utility documentation says that it is more |
| 263 | ;; efficient than ghostscript to print monochrome PostScript. |
| 264 | ;; |
| 265 | ;; To print non-monochrome PostScript file, the efficiency of ghostscript |
| 266 | ;; is similar to gsprint. |
| 267 | ;; |
| 268 | ;; Also the gsprint utility comes together with gsview distribution. |
| 269 | ;; |
| 270 | ;; For more information about gsprint see |
| 271 | ;; `http://www.cs.wisc.edu/~ghost/gsview/gsprint.htm'. |
| 272 | ;; |
| 273 | ;; As an example of gsprint declaration: |
| 274 | ;; |
| 275 | ;; (setq pr-ps-printer-alist |
| 276 | ;; '((A "gsprint" ("-all" "-twoup") "-printer " "my-b/w-printer-name") |
| 277 | ;; (B "gsprint" ("-all" "-twoup") nil "-printer my-b/w-printer-name") |
| 278 | ;; ;; some other printer declaration |
| 279 | ;; )) |
| 280 | ;; |
| 281 | ;; The example above declares that printer A prints all pages (-all) and two |
| 282 | ;; pages per sheet (-twoup). The printer B declaration does the same as the |
| 283 | ;; printer A declaration, the only difference is the printer name selection. |
| 284 | ;; |
| 285 | ;; There are other command line options like: |
| 286 | ;; |
| 287 | ;; -mono Render in monochrome as 1bit/pixel (only black and white). |
| 288 | ;; -grey Render in greyscale as 8bits/pixel. |
| 289 | ;; -color Render in color as 24bits/pixel. |
| 290 | ;; |
| 291 | ;; The default is `-mono'. So, printer A and B in the example above are |
| 292 | ;; using implicitly the `-mono' option. Note that in `-mono' no gray tone |
| 293 | ;; or color is printed, this includes the zebra stripes, that is, in `-mono' |
| 294 | ;; the zebra stripes are not printed. |
| 295 | ;; |
| 296 | ;; See also documentation for `pr-ps-printer-alist'. |
| 297 | ;; |
| 298 | ;; |
| 299 | ;; Using `printing' |
| 300 | ;; ---------------- |
| 301 | ;; |
| 302 | ;; To use `printing' insert in your ~/.emacs file (or c:/_emacs, if you're |
| 303 | ;; using Windows 9x/NT or MS-DOS): |
| 304 | ;; |
| 305 | ;; (require 'printing) |
| 306 | ;; ;; ...some user settings... |
| 307 | ;; (pr-update-menus t) |
| 308 | ;; |
| 309 | ;; During `pr-update-menus' evaluation: |
| 310 | ;; * On Emacs 20: |
| 311 | ;; it replaces the Tools/Print menu by Tools/Printing menu. |
| 312 | ;; * On Emacs 21: |
| 313 | ;; it replaces the File/Print* menu entries by File/Print menu. |
| 314 | ;; Please, see section Menu Layout below for menu explanation. |
| 315 | ;; |
| 316 | ;; To use `printing' utilities you can use the Printing menu options, type M-x |
| 317 | ;; followed by one of the commands below, or type a key associated with the |
| 318 | ;; command you want (if there is a key binding). |
| 319 | ;; |
| 320 | ;; `printing' has the following commands: |
| 321 | ;; |
| 322 | ;; pr-interface |
| 323 | ;; pr-ps-directory-preview |
| 324 | ;; pr-ps-directory-using-ghostscript |
| 325 | ;; pr-ps-directory-print |
| 326 | ;; pr-ps-directory-ps-print |
| 327 | ;; pr-ps-buffer-preview |
| 328 | ;; pr-ps-buffer-using-ghostscript |
| 329 | ;; pr-ps-buffer-print |
| 330 | ;; pr-ps-buffer-ps-print |
| 331 | ;; pr-ps-region-preview |
| 332 | ;; pr-ps-region-using-ghostscript |
| 333 | ;; pr-ps-region-print |
| 334 | ;; pr-ps-region-ps-print |
| 335 | ;; pr-ps-mode-preview |
| 336 | ;; pr-ps-mode-using-ghostscript |
| 337 | ;; pr-ps-mode-print |
| 338 | ;; pr-ps-mode-ps-print |
| 339 | ;; pr-ps-file-preview |
| 340 | ;; pr-ps-file-up-preview |
| 341 | ;; pr-ps-file-using-ghostscript |
| 342 | ;; pr-ps-file-print |
| 343 | ;; pr-ps-file-ps-print |
| 344 | ;; pr-ps-file-up-ps-print |
| 345 | ;; pr-ps-fast-fire |
| 346 | ;; pr-despool-preview |
| 347 | ;; pr-despool-using-ghostscript |
| 348 | ;; pr-despool-print |
| 349 | ;; pr-despool-ps-print |
| 350 | ;; pr-printify-directory |
| 351 | ;; pr-printify-buffer |
| 352 | ;; pr-printify-region |
| 353 | ;; pr-txt-directory |
| 354 | ;; pr-txt-buffer |
| 355 | ;; pr-txt-region |
| 356 | ;; pr-txt-mode |
| 357 | ;; pr-txt-fast-fire |
| 358 | ;; pr-toggle-file-duplex |
| 359 | ;; pr-toggle-file-tumble |
| 360 | ;; pr-toggle-file-landscape |
| 361 | ;; pr-toggle-ghostscript |
| 362 | ;; pr-toggle-faces |
| 363 | ;; pr-toggle-spool |
| 364 | ;; pr-toggle-duplex |
| 365 | ;; pr-toggle-tumble |
| 366 | ;; pr-toggle-landscape |
| 367 | ;; pr-toggle-upside-down |
| 368 | ;; pr-toggle-line |
| 369 | ;; pr-toggle-zebra |
| 370 | ;; pr-toggle-header |
| 371 | ;; pr-toggle-lock |
| 372 | ;; pr-toggle-region |
| 373 | ;; pr-toggle-mode |
| 374 | ;; pr-customize |
| 375 | ;; lpr-customize |
| 376 | ;; pr-help |
| 377 | ;; pr-ps-name |
| 378 | ;; pr-txt-name |
| 379 | ;; pr-ps-utility |
| 380 | ;; pr-show-ps-setup |
| 381 | ;; pr-show-pr-setup |
| 382 | ;; pr-show-lpr-setup |
| 383 | ;; |
| 384 | ;; The general meanings of above commands are: |
| 385 | ;; |
| 386 | ;; PREFIX: |
| 387 | ;; `pr-interface' buffer interface for printing package. |
| 388 | ;; `pr-help' help for printing package. |
| 389 | ;; `pr-ps-name' interactively select a PostScript printer. |
| 390 | ;; `pr-txt-name' interactively select a text printer. |
| 391 | ;; `pr-ps-utility' interactively select a PostScript utility. |
| 392 | ;; `pr-show-*-setup' show current settings. |
| 393 | ;; `pr-ps-*' deal with PostScript code generation. |
| 394 | ;; `pr-txt-*' deal with text generation. |
| 395 | ;; `pr-toggle-*' toggle on/off some boolean variable. |
| 396 | ;; `pr-despool-*' despool the PostScript spooling buffer. |
| 397 | ;; `pr-printify-*' replace nonprintable ASCII by printable ASCII |
| 398 | ;; representation. |
| 399 | ;; |
| 400 | ;; SUFFIX: |
| 401 | ;; `*-customize' customization. |
| 402 | ;; `*-preview' preview a PostScript file. |
| 403 | ;; `*-using-ghostscript' use ghostscript to print. |
| 404 | ;; `*-fast-fire' fast fire command (see it for documentation). |
| 405 | ;; `*-print' send PostScript directly to printer. |
| 406 | ;; `*-ps-print' send PostScript directly to printer or use |
| 407 | ;; ghostscript to print. It depends on |
| 408 | ;; `pr-print-using-ghostscript' option. |
| 409 | ;; |
| 410 | ;; INFIX/SUFFIX: |
| 411 | ;; `*-directory*' process a directory. |
| 412 | ;; `*-buffer*' process a buffer. |
| 413 | ;; `*-region*' process a region. |
| 414 | ;; `*-mode*' process a major mode (see explanation below). |
| 415 | ;; `*-file-*' process a PostScript file. |
| 416 | ;; `*-file-up-*' process a PostScript file using a filter utility. |
| 417 | ;; |
| 418 | ;; Here are some examples: |
| 419 | ;; |
| 420 | ;; `pr-ps-buffer-using-ghostscript' |
| 421 | ;; Use ghostscript to print a buffer. |
| 422 | ;; |
| 423 | ;; `pr-ps-file-print' |
| 424 | ;; Print a PostScript file. |
| 425 | ;; |
| 426 | ;; `pr-toggle-spool' |
| 427 | ;; Toggle spooling buffer. |
| 428 | ;; |
| 429 | ;; So you can preview through ghostview, use ghostscript to print (if you don't |
| 430 | ;; have a PostScript printer) or send directly to printer a PostScript code |
| 431 | ;; generated by `ps-print' package. |
| 432 | ;; |
| 433 | ;; Besides operating one buffer or region each time, you also can postpone |
| 434 | ;; previewing or printing by saving the PostScript code generated in a |
| 435 | ;; temporary Emacs buffer. This way you can save banner pages between |
| 436 | ;; successive printing. You can toggle on/off spooling by invoking |
| 437 | ;; `pr-toggle-spool' interactively or through menu bar. |
| 438 | ;; |
| 439 | ;; If you type, for example: |
| 440 | ;; |
| 441 | ;; C-u M-x pr-ps-buffer-print RET |
| 442 | ;; |
| 443 | ;; The `pr-ps-buffer-print' command prompts you for a n-up printing number and |
| 444 | ;; a file name, and save the PostScript code generated to the file name instead |
| 445 | ;; of sending to printer. |
| 446 | ;; |
| 447 | ;; This behavior is similar with the commands that deal with PostScript code |
| 448 | ;; generation, that is, with `pr-ps-*' and `pr-despool-*' commands. If |
| 449 | ;; spooling is on, only `pr-despool-*' commands prompt for a file name and save |
| 450 | ;; the PostScript code spooled in this file. |
| 451 | ;; |
| 452 | ;; Besides the behavior described above, the `*-directory*' commands also |
| 453 | ;; prompt for a directory and a file name regexp. So, it's possible to process |
| 454 | ;; all or certain files on a directory at once (see also documentation for |
| 455 | ;; `pr-list-directory'). |
| 456 | ;; |
| 457 | ;; `printing' has also a special way to handle some major mode through |
| 458 | ;; `*-mode*' commands. So it's possible to customize a major mode printing, |
| 459 | ;; it's only needed to declare the customization in `pr-mode-alist' (see |
| 460 | ;; section Options) and invoke some of `*-mode*' commands. An example for |
| 461 | ;; major mode usage is when you're using gnus (or mh, or rmail, etc.) and |
| 462 | ;; you're in the *Summary* buffer, if you forget to switch to the *Article* |
| 463 | ;; buffer before printing, you'll get a nicely formatted list of article |
| 464 | ;; subjects shows up at the printer. With major mode printing you don't need |
| 465 | ;; to switch from gnus *Summary* buffer first. |
| 466 | ;; |
| 467 | ;; Current global keyboard mapping for GNU Emacs is: |
| 468 | ;; |
| 469 | ;; (global-set-key [print] 'pr-ps-fast-fire) |
| 470 | ;; (global-set-key [M-print] 'pr-ps-mode-using-ghostscript) |
| 471 | ;; (global-set-key [S-print] 'pr-ps-mode-using-ghostscript) |
| 472 | ;; (global-set-key [C-print] 'pr-txt-fast-fire) |
| 473 | ;; (global-set-key [C-M-print] 'pr-txt-fast-fire) |
| 474 | ;; |
| 475 | ;; And for XEmacs is: |
| 476 | ;; |
| 477 | ;; (global-set-key 'f22 'pr-ps-fast-fire) |
| 478 | ;; (global-set-key '(meta f22) 'pr-ps-mode-using-ghostscript) |
| 479 | ;; (global-set-key '(shift f22) 'pr-ps-mode-using-ghostscript) |
| 480 | ;; (global-set-key '(control f22) 'pr-txt-fast-fire) |
| 481 | ;; (global-set-key '(control meta f22) 'pr-txt-fast-fire) |
| 482 | ;; |
| 483 | ;; As a suggestion of global keyboard mapping for some `printing' commands: |
| 484 | ;; |
| 485 | ;; (global-set-key "\C-ci" 'pr-interface) |
| 486 | ;; (global-set-key "\C-cbp" 'pr-ps-buffer-print) |
| 487 | ;; (global-set-key "\C-cbx" 'pr-ps-buffer-preview) |
| 488 | ;; (global-set-key "\C-cbb" 'pr-ps-buffer-using-ghostscript) |
| 489 | ;; (global-set-key "\C-crp" 'pr-ps-region-print) |
| 490 | ;; (global-set-key "\C-crx" 'pr-ps-region-preview) |
| 491 | ;; (global-set-key "\C-crr" 'pr-ps-region-using-ghostscript) |
| 492 | ;; |
| 493 | ;; |
| 494 | ;; Options |
| 495 | ;; ------- |
| 496 | ;; |
| 497 | ;; Below it's shown a brief description of `printing' options, please, see the |
| 498 | ;; options declaration in the code for a long documentation. |
| 499 | ;; |
| 500 | ;; `pr-path-style' Specify which path style to use for external |
| 501 | ;; commands. |
| 502 | ;; |
| 503 | ;; `pr-path-alist' Specify an alist for command paths. |
| 504 | ;; |
| 505 | ;; `pr-txt-name' Specify a printer for printing a text file. |
| 506 | ;; |
| 507 | ;; `pr-txt-printer-alist' Specify an alist of all text printers. |
| 508 | ;; |
| 509 | ;; `pr-ps-name' Specify a printer for printing a PostScript |
| 510 | ;; file. |
| 511 | ;; |
| 512 | ;; `pr-ps-printer-alist' Specify an alist for all PostScript printers. |
| 513 | ;; |
| 514 | ;; `pr-temp-dir' Specify a directory for temporary files during |
| 515 | ;; printing. |
| 516 | ;; |
| 517 | ;; `pr-ps-temp-file' Specify PostScript temporary file name prefix. |
| 518 | ;; |
| 519 | ;; `pr-file-modes' Specify the file permission bits for newly |
| 520 | ;; created files. |
| 521 | ;; |
| 522 | ;; `pr-gv-command' Specify path and name of the gsview/gv |
| 523 | ;; utility. |
| 524 | ;; |
| 525 | ;; `pr-gs-command' Specify path and name of the ghostscript |
| 526 | ;; utility. |
| 527 | ;; |
| 528 | ;; `pr-gs-switches' Specify ghostscript switches. |
| 529 | ;; |
| 530 | ;; `pr-gs-device' Specify ghostscript device switch value. |
| 531 | ;; |
| 532 | ;; `pr-gs-resolution' Specify ghostscript resolution switch value. |
| 533 | ;; |
| 534 | ;; `pr-print-using-ghostscript' Non-nil means print using ghostscript. |
| 535 | ;; |
| 536 | ;; `pr-faces-p' Non-nil means print with face attributes. |
| 537 | ;; |
| 538 | ;; `pr-spool-p' Non-nil means spool printing in a buffer. |
| 539 | ;; |
| 540 | ;; `pr-file-landscape' Non-nil means print PostScript file in |
| 541 | ;; landscape orientation. |
| 542 | ;; |
| 543 | ;; `pr-file-duplex' Non-nil means print PostScript file in duplex |
| 544 | ;; mode. |
| 545 | ;; |
| 546 | ;; `pr-file-tumble' Non-nil means print PostScript file in tumble |
| 547 | ;; mode. |
| 548 | ;; |
| 549 | ;; `pr-auto-region' Non-nil means region is automagically detected. |
| 550 | ;; |
| 551 | ;; `pr-auto-mode' Non-nil means major-mode specific printing is |
| 552 | ;; prefered over normal printing. |
| 553 | ;; |
| 554 | ;; `pr-mode-alist' Specify an alist for a major-mode and printing |
| 555 | ;; function. |
| 556 | ;; |
| 557 | ;; `pr-ps-utility' Specify PostScript utility processing. |
| 558 | ;; |
| 559 | ;; `pr-ps-utility-alist' Specify an alist for PostScript utility |
| 560 | ;; processing. |
| 561 | ;; |
| 562 | ;; `pr-menu-lock' Non-nil means menu is locked while selecting |
| 563 | ;; toggle options. |
| 564 | ;; |
| 565 | ;; `pr-menu-char-height' Specify menu char height in pixels. |
| 566 | ;; |
| 567 | ;; `pr-menu-char-width' Specify menu char width in pixels. |
| 568 | ;; |
| 569 | ;; `pr-setting-database' Specify an alist for settings in general. |
| 570 | ;; |
| 571 | ;; `pr-visible-entry-list' Specify a list of Printing menu visible |
| 572 | ;; entries. |
| 573 | ;; |
| 574 | ;; `pr-delete-temp-file' Non-nil means delete temporary files. |
| 575 | ;; |
| 576 | ;; `pr-list-directory' Non-nil means list directory when processing a |
| 577 | ;; directory. |
| 578 | ;; |
| 579 | ;; `pr-buffer-name' Specify the name of the buffer interface for |
| 580 | ;; printing package. |
| 581 | ;; |
| 582 | ;; `pr-buffer-name-ignore' Specify a regexp list for buffer names to be |
| 583 | ;; ignored in interface buffer. |
| 584 | ;; |
| 585 | ;; `pr-buffer-verbose' Non-nil means to be verbose when editing a |
| 586 | ;; field in interface buffer. |
| 587 | ;; |
| 588 | ;; To set the above options you may: |
| 589 | ;; |
| 590 | ;; a) insert the code in your ~/.emacs, like: |
| 591 | ;; |
| 592 | ;; (setq pr-faces-p t) |
| 593 | ;; |
| 594 | ;; This way always keep your default settings when you enter a new Emacs |
| 595 | ;; session. |
| 596 | ;; |
| 597 | ;; b) or use `set-variable' in your Emacs session, like: |
| 598 | ;; |
| 599 | ;; M-x set-variable RET pr-faces-p RET t RET |
| 600 | ;; |
| 601 | ;; This way keep your settings only during the current Emacs session. |
| 602 | ;; |
| 603 | ;; c) or use customization, for example: |
| 604 | ;; click on menu-bar *Help* option, |
| 605 | ;; then click on *Customize*, |
| 606 | ;; then click on *Browse Customization Groups*, |
| 607 | ;; expand *PostScript* group, |
| 608 | ;; expand *Printing* group |
| 609 | ;; and then customize `printing' options. |
| 610 | ;; Through this way, you may choose if the settings are kept or not when |
| 611 | ;; you leave out the current Emacs session. |
| 612 | ;; |
| 613 | ;; d) or see the option value: |
| 614 | ;; |
| 615 | ;; C-h v pr-faces-p RET |
| 616 | ;; |
| 617 | ;; and click the *customize* hypertext button. |
| 618 | ;; Through this way, you may choose if the settings are kept or not when |
| 619 | ;; you leave out the current Emacs session. |
| 620 | ;; |
| 621 | ;; e) or invoke: |
| 622 | ;; |
| 623 | ;; M-x pr-customize RET |
| 624 | ;; |
| 625 | ;; and then customize `printing' options. |
| 626 | ;; Through this way, you may choose if the settings are kept or not when |
| 627 | ;; you leave out the current Emacs session. |
| 628 | ;; |
| 629 | ;; f) or use menu bar, for example: |
| 630 | ;; click on menu-bar *File* option, |
| 631 | ;; then click on *Printing*, |
| 632 | ;; then click on *Customize*, |
| 633 | ;; then click on *printing* |
| 634 | ;; and then customize `printing' options. |
| 635 | ;; Through this way, you may choose if the settings are kept or not when |
| 636 | ;; you leave out the current Emacs session. |
| 637 | ;; |
| 638 | ;; |
| 639 | ;; Menu Layout |
| 640 | ;; ----------- |
| 641 | ;; |
| 642 | ;; The `printing' menu (Tools/Printing or File/Print) has the following layout: |
| 643 | ;; |
| 644 | ;; +-----------------------------+ |
| 645 | ;; A 0 | Printing Interface | |
| 646 | ;; +-----------------------------+ +-A---------+ +-B------+ |
| 647 | ;; I 1 | PostScript Preview >|-------|Directory >|-----|1-up | |
| 648 | ;; 2 | PostScript Print >|---- A |Buffer >|-- B |2-up | |
| 649 | ;; 3 | PostScript Printer: name >|---- C |Region >|-- B |4-up | |
| 650 | ;; +-----------------------------+ |Mode >|-- B |Other...| |
| 651 | ;; II 4 | Printify >|-----\ |File >|--\ +--------+ |
| 652 | ;; 5 | Print >|---\ | |Despool... | | |
| 653 | ;; 6 | Text Printer: name >|-\ | | +-----------+ | |
| 654 | ;; +-----------------------------+ | | | +---------+ +------------+ |
| 655 | ;; III 7 |[ ]Landscape | | | \-|Directory| | No Prep... | Ia |
| 656 | ;; 8 |[ ]Print Header | | | |Buffer | +------------+ Ib |
| 657 | ;; 9 |[ ]Print Header Frame | | | |Region | | name >|- C |
| 658 | ;; 10 |[ ]Line Number | | | +---------+ +------------+ |
| 659 | ;; 11 |[ ]Zebra Stripes | | | +---------+ | 1-up... | Ic |
| 660 | ;; 12 |[ ]Duplex | | \---|Directory| | 2-up... | |
| 661 | ;; 13 |[ ]Tumble | \--\ |Buffer | | 4-up... | |
| 662 | ;; 14 |[ ]Upside-Down | | |Region | | Other... | |
| 663 | ;; 15 | Print All Pages >|--\ | |Mode | +------------+ |
| 664 | ;; +-----------------------------+ | | +---------+ |[ ]Landscape| Id |
| 665 | ;; IV 16 |[ ]Spool Buffer | | | +-C-------+ |[ ]Duplex | Ie |
| 666 | ;; 17 |[ ]Print with faces | | \--|( )name A| |[ ]Tumble | If |
| 667 | ;; 18 |[ ]Print via Ghostscript | | |( )name B| +------------+ |
| 668 | ;; +-----------------------------+ | |... | |
| 669 | ;; V 19 |[ ]Auto Region | | |(*)name | |
| 670 | ;; 20 |[ ]Auto Mode | | |... | |
| 671 | ;; 21 |[ ]Menu Lock | | +---------+ +--------------+ |
| 672 | ;; +-----------------------------+ \------------------|(*)All Pages | |
| 673 | ;; VI 22 | Customize >|--- D +-D------+ |( )Even Pages | |
| 674 | ;; 23 | Show Settings >|-------|printing| |( )Odd Pages | |
| 675 | ;; 24 | Help | |ps-print| |( )Even Sheets| |
| 676 | ;; +-----------------------------+ |lpr | |( )Odd Sheets | |
| 677 | ;; +--------+ +--------------+ |
| 678 | ;; |
| 679 | ;; See `pr-visible-entry-list' for hiding some parts of the menu. |
| 680 | ;; |
| 681 | ;; The menu has the following sections: |
| 682 | ;; |
| 683 | ;; A. Interface: |
| 684 | ;; |
| 685 | ;; 0. You can use a buffer interface instead of menus. It looks like the |
| 686 | ;; customization buffer. Basically, it has the same options found in the |
| 687 | ;; menu and some extra options, all this on a buffer. |
| 688 | ;; |
| 689 | ;; I. PostScript printing: |
| 690 | ;; |
| 691 | ;; 1. You can generate a PostScript file (if you type C-u before activating |
| 692 | ;; menu) or PostScript temporary file for a directory, a buffer, a region |
| 693 | ;; or a major mode, choosing 1-up, 2-up, 4-up or any other n-up printing; |
| 694 | ;; after file generation, ghostview is activated using the file generated |
| 695 | ;; as argument. This option is disabled if spooling is on (option 16). |
| 696 | ;; Also, if you already have a PostScript file you can preview it. |
| 697 | ;; Instead of previewing each buffer, region or major mode at once, you |
| 698 | ;; can save temporarily the PostScript code generated in a buffer and |
| 699 | ;; preview it later. The option `Despool...' despools the PostScript |
| 700 | ;; spooling buffer in a temporary file and uses ghostview to preview it. |
| 701 | ;; If you type C-u before choosing this option, the PostScript code |
| 702 | ;; generated is saved in a file instead of saving in a temporary file. |
| 703 | ;; To spool the PostScript code generated you need to turn on the option |
| 704 | ;; 16. The option `Despool...' is enabled if spooling is on (option |
| 705 | ;; 16). |
| 706 | ;; |
| 707 | ;; NOTE 1: It's possible to customize a major mode printing, just declare |
| 708 | ;; the customization in `pr-mode-alist' and invoke some of |
| 709 | ;; `*-mode*' commands or select Mode option in Printing menu. An |
| 710 | ;; example for major mode usage is when you're using gnus (or mh, |
| 711 | ;; or rmail, etc.) and you're in the *Summary* buffer, if you |
| 712 | ;; forget to switch to the *Article* buffer before printing, |
| 713 | ;; you'll get a nicely formatted list of article subjects shows |
| 714 | ;; up at the printer. With major mode printing you don't need to |
| 715 | ;; switch from gnus *Summary* buffer first. |
| 716 | ;; |
| 717 | ;; NOTE 2: There are the following options for PostScript file |
| 718 | ;; processing: |
| 719 | ;; Ia. Print the file *No Preprocessing*, that is, send it |
| 720 | ;; directly to PostScript printer. |
| 721 | ;; Ib. PostScript utility processing selection. |
| 722 | ;; See `pr-ps-utility-alist' and `pr-setting-database' for |
| 723 | ;; documentation. |
| 724 | ;; Ic. Do n-up processing before printing. |
| 725 | ;; Id. Toggle on/off landscape for PostScript file processing. |
| 726 | ;; Ie. Toggle on/off duplex for PostScript file processing. |
| 727 | ;; If. Toggle on/off tumble for PostScript file processing. |
| 728 | ;; |
| 729 | ;; NOTE 3: Don't forget to download and install the utilities declared on |
| 730 | ;; `pr-ps-utility-alist'. |
| 731 | ;; |
| 732 | ;; 2. Operate the same way as option 1, but it sends directly the PostScript |
| 733 | ;; code (or put in a file, if you've typed C-u) or it uses ghostscript to |
| 734 | ;; print the PostScript file generated. It depends on option 18, if it's |
| 735 | ;; turned on, it uses ghostscript; otherwise, it sends directly to |
| 736 | ;; printer. If spooling is on (option 16), the PostScript code is saved |
| 737 | ;; temporarily in a buffer instead of printing it or saving it in a file. |
| 738 | ;; Also, if you already have a PostScript file you can print it. Instead |
| 739 | ;; of printing each buffer, region or major mode at once, you can save |
| 740 | ;; temporarily the PostScript code generated in a buffer and print it |
| 741 | ;; later. The option `Despool...' despools the PostScript spooling |
| 742 | ;; buffer directly on a printer. If you type C-u before choosing this |
| 743 | ;; option, the PostScript code generated is saved in a file instead of |
| 744 | ;; sending to printer. To spool the PostScript code generated you need |
| 745 | ;; to turn on the option 16. This option is enabled if spooling is on |
| 746 | ;; (option 16). See also the NOTE 1, NOTE 2 and NOTE 3 on option 1. |
| 747 | ;; |
| 748 | ;; 3. You can select a new PostScript printer to send PostScript code |
| 749 | ;; generated. For selection it's used all PostScript printers defined |
| 750 | ;; in `pr-ps-printer-alist' variable (see it for documentation). |
| 751 | ;; See also `pr-setting-database'. |
| 752 | ;; |
| 753 | ;; II. Text printing: |
| 754 | ;; |
| 755 | ;; 4. If you have control characters (character code from \000 to \037) in a |
| 756 | ;; buffer and you want to print them in a text printer, select this |
| 757 | ;; option. All control characters in your buffer or region will be |
| 758 | ;; replaced by a printable representation. The printable representations |
| 759 | ;; use ^ (for ASCII control characters) or hex. The characters tab, |
| 760 | ;; linefeed, space, return and formfeed are not affected. You don't need |
| 761 | ;; to select this option if you use any option of section I, the |
| 762 | ;; PostScript engine treats control characters properly. |
| 763 | ;; |
| 764 | ;; 5. If you want to print a directory, buffer, region or major mode in a |
| 765 | ;; text printer, select this option. See also the NOTE 1 on option 1. |
| 766 | ;; |
| 767 | ;; 6. You can select a new text printer to send text generated. For |
| 768 | ;; selection it's used all text printers defined in |
| 769 | ;; `pr-txt-printer-alist' variable (see it for documentation). |
| 770 | ;; See also `pr-setting-database'. |
| 771 | ;; |
| 772 | ;; III. PostScript page toggle options: |
| 773 | ;; |
| 774 | ;; 7. If you want a PostScript landscape printing, turn on this option. |
| 775 | ;; |
| 776 | ;; 8. If you want to have a header in each page in your PostScript code, |
| 777 | ;; turn on this option. |
| 778 | ;; |
| 779 | ;; 9. If you want to draw a gaudy frame around the header, turn on this |
| 780 | ;; option. This option is enabled if print header is on (option 8). |
| 781 | ;; |
| 782 | ;; 10. If you want that the line number is printed in your PostScript code, |
| 783 | ;; turn on this option. |
| 784 | ;; |
| 785 | ;; 11. If you want background zebra stripes in your PostScript code, turn on |
| 786 | ;; this option. |
| 787 | ;; |
| 788 | ;; 12. If you want a duplex printing and your PostScript printer has this |
| 789 | ;; feature, turn on this option. |
| 790 | ;; |
| 791 | ;; 13. If you turned on duplex printing, you can choose if you want to have |
| 792 | ;; a printing suitable for binding on the left or right (tumble off), or |
| 793 | ;; to have a printing suitable for binding at top or bottom (tumble on). |
| 794 | ;; This option is enabled if duplex is on (option 12). |
| 795 | ;; |
| 796 | ;; 14. If you want a PostScript upside-down printing, turn on this option. |
| 797 | ;; |
| 798 | ;; 15. With this option, you can choose if you want to print all pages, odd |
| 799 | ;; pages, even pages, odd sheets or even sheets. |
| 800 | ;; See also `ps-even-or-odd-pages'. |
| 801 | ;; |
| 802 | ;; IV. PostScript processing toggle options: |
| 803 | ;; |
| 804 | ;; 16. If you want to spool the PostScript code generated, turn on this |
| 805 | ;; option. To spool the PostScript code generated use option 2. You |
| 806 | ;; can despool later by choosing option 1 or 2, sub-option `Despool...'. |
| 807 | ;; |
| 808 | ;; 17. If you use colors in your buffers and want to see these colors on |
| 809 | ;; your PostScript code generated, turn on this option. If you have a |
| 810 | ;; black/white PostScript printer, these colors are displayed in gray |
| 811 | ;; scale by PostScript printer interpreter. |
| 812 | ;; |
| 813 | ;; 18. If you don't have a PostScript printer to send PostScript files, turn |
| 814 | ;; on this option. When this option is on, the ghostscript is used to |
| 815 | ;; print PostScript files. In GNU or Unix system, if ghostscript is set |
| 816 | ;; as a PostScript filter, you don't need to turn on this option. |
| 817 | ;; |
| 818 | ;; V. Printing customization: |
| 819 | ;; |
| 820 | ;; 19. If you want that region is automagically detected, turn on this |
| 821 | ;; option. Note that this will only work if you're using transient mark |
| 822 | ;; mode. When this option is on, the `*-buffer*' commands will behave |
| 823 | ;; like `*-region*' commands, that is, `*-buffer*' commands will print |
| 824 | ;; only the region marked instead of all buffer. |
| 825 | ;; |
| 826 | ;; 20. Turn this option on if you want that when current major-mode is |
| 827 | ;; declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands |
| 828 | ;; behave like `*-mode*' commands. |
| 829 | ;; |
| 830 | ;; 21. If you want that Printing menu stays open while you are setting |
| 831 | ;; toggle options, turn on this option. The variables |
| 832 | ;; `pr-menu-char-height' and `pr-menu-char-width' are used to guess the |
| 833 | ;; menu position, so don't forget to adjust these variables if menu |
| 834 | ;; position is not ok. |
| 835 | ;; |
| 836 | ;; VI. Customization: |
| 837 | ;; |
| 838 | ;; 22. Besides all options in section III, IV and V, you can customize much |
| 839 | ;; more PostScript options in `ps-print' option. Or you can customize |
| 840 | ;; some `lpr' options for text printing. Or customize `printing' |
| 841 | ;; options. |
| 842 | ;; |
| 843 | ;; 23. Show current settings for `printing', `ps-print' or `lpr'. |
| 844 | ;; |
| 845 | ;; 24. Quick help for printing menu layout. |
| 846 | ;; |
| 847 | ;; |
| 848 | ;; Option Settings |
| 849 | ;; --------------- |
| 850 | ;; |
| 851 | ;; Below it's shown only the main options that affect all `printing' package. |
| 852 | ;; Check all the settings below *BEFORE* running `printing' commands. |
| 853 | ;; |
| 854 | ;; * Example of setting for GNU or Unix system: |
| 855 | ;; |
| 856 | ;; (require 'printing) |
| 857 | ;; (setq pr-path-alist |
| 858 | ;; '((unix "." "~/bin" ghostview mpage PATH) |
| 859 | ;; (ghostview "$HOME/bin/gsview-dir") |
| 860 | ;; (mpage "$HOME/bin/mpage-dir") |
| 861 | ;; )) |
| 862 | ;; (setq pr-txt-name 'prt_06a) |
| 863 | ;; (setq pr-txt-printer-alist |
| 864 | ;; '((prt_06a "lpr" nil "prt_06a") |
| 865 | ;; (prt_07c nil nil "prt_07c") |
| 866 | ;; )) |
| 867 | ;; (setq pr-ps-name 'lps_06b) |
| 868 | ;; (setq pr-ps-printer-alist |
| 869 | ;; '((lps_06b "lpr" nil "-P" "lps_06b") |
| 870 | ;; (lps_07c "lpr" nil nil "lps_07c") |
| 871 | ;; (lps_08c nil nil nil "lps_08c") |
| 872 | ;; )) |
| 873 | ;; (setq pr-temp-dir "/tmp/") |
| 874 | ;; (setq pr-gv-command "gv") |
| 875 | ;; (setq pr-gs-command "gs") |
| 876 | ;; (setq pr-gs-switches '("-q -dNOPAUSE -I/usr/share/ghostscript/5.10")) |
| 877 | ;; (setq pr-gs-device "uniprint") |
| 878 | ;; (setq pr-gs-resolution 300) |
| 879 | ;; (setq pr-ps-utility 'mpage) |
| 880 | ;; (setq pr-ps-utility-alist |
| 881 | ;; '((mpage "mpage" nil "-b%s" "-%d" "-l" "-t" "-T" ">" nil) |
| 882 | ;; (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil |
| 883 | ;; (inherits-from: . no-duplex)) |
| 884 | ;; )) |
| 885 | ;; (setq pr-setting-database |
| 886 | ;; '((no-duplex |
| 887 | ;; nil nil nil |
| 888 | ;; (pr-file-duplex . nil) |
| 889 | ;; (pr-file-tumble . nil)) |
| 890 | ;; )) |
| 891 | ;; (pr-update-menus t) ; update now printer and utility menus |
| 892 | ;; |
| 893 | ;; * Example of setting for Windows system: |
| 894 | ;; |
| 895 | ;; (require 'printing) |
| 896 | ;; (setq pr-path-alist |
| 897 | ;; '((windows "c:/applications/executables" PATH ghostview mpage) |
| 898 | ;; (ghostview "c:/gs/gsview-dir") |
| 899 | ;; (mpage "c:/mpage-dir") |
| 900 | ;; )) |
| 901 | ;; (setq pr-txt-name 'prt_06a) |
| 902 | ;; (setq pr-txt-printer-alist |
| 903 | ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a") |
| 904 | ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c") |
| 905 | ;; (PRN "" nil "PRN") |
| 906 | ;; (standard "redpr.exe" nil "") |
| 907 | ;; )) |
| 908 | ;; (setq pr-ps-name 'lps_06b) |
| 909 | ;; (setq pr-ps-printer-alist |
| 910 | ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a") |
| 911 | ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b") |
| 912 | ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c") |
| 913 | ;; (lps_08c nil nil nil "\\\\printers\\lps_08c") |
| 914 | ;; (b/w "gsprint" ("-all" "-twoup") "-printer " "b/w-pr-name") |
| 915 | ;; (LPT1 "" nil "" "LPT1:") |
| 916 | ;; (PRN "" nil "" "PRN") |
| 917 | ;; (standard "redpr.exe" nil "" "") |
| 918 | ;; )) |
| 919 | ;; (setq pr-temp-dir "C:/WINDOWS/TEMP/") |
| 920 | ;; (setq pr-gv-command "c:/gs/gsview/gsview32.exe") |
| 921 | ;; (setq pr-gs-command "c:/gs/gswin32.exe") |
| 922 | ;; (setq pr-gs-switches '("-q -dNOPAUSE -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts")) |
| 923 | ;; (setq pr-gs-device "mswinpr2") |
| 924 | ;; (setq pr-gs-resolution 300) |
| 925 | ;; (setq pr-ps-utility 'psnup) |
| 926 | ;; (setq pr-ps-utility-alist |
| 927 | ;; '((psnup "c:/psutils/psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " |
| 928 | ;; nil (inherits-from: . no-duplex)) |
| 929 | ;; )) |
| 930 | ;; (setq pr-setting-database |
| 931 | ;; '((no-duplex |
| 932 | ;; nil nil nil |
| 933 | ;; (pr-file-duplex . nil) |
| 934 | ;; (pr-file-tumble . nil)) |
| 935 | ;; )) |
| 936 | ;; (pr-update-menus t) ; update now printer and utility menus |
| 937 | ;; |
| 938 | ;; NOTE: Don't forget to download and install the utilities declared on |
| 939 | ;; `pr-ps-utility-alist'. |
| 940 | ;; |
| 941 | ;; |
| 942 | ;; Utilities |
| 943 | ;; --------- |
| 944 | ;; |
| 945 | ;; `printing' package has the following utilities: |
| 946 | ;; |
| 947 | ;; `pr-setup' Return the current `printing' setup. |
| 948 | ;; |
| 949 | ;; `lpr-setup' Return the current `lpr' setup. |
| 950 | ;; |
| 951 | ;; `pr-update-menus' Update utility, PostScript and text printer menus. |
| 952 | ;; |
| 953 | ;; `pr-menu-bind' Install `printing' menu in the menubar. |
| 954 | ;; |
| 955 | ;; |
| 956 | ;; Below are some URL where you can find good utilities. |
| 957 | ;; |
| 958 | ;; * For `printing' package: |
| 959 | ;; |
| 960 | ;; printing `http://www.cpqd.com.br/~vinicius/emacs/printing.el.gz' |
| 961 | ;; ps-print `http://www.cpqd.com.br/~vinicius/emacs/ps-print.tar.gz' |
| 962 | ;; |
| 963 | ;; * For GNU or Unix system: |
| 964 | ;; |
| 965 | ;; gs, gv `http://www.gnu.org/software/ghostscript/ghostscript.html' |
| 966 | ;; enscript `http://people.ssh.fi/mtr/genscript/' |
| 967 | ;; psnup `http://www.knackered.org/angus/psutils/' |
| 968 | ;; mpage `http://www.mesa.nl/pub/mpage/' |
| 969 | ;; |
| 970 | ;; * For Windows system: |
| 971 | ;; |
| 972 | ;; gswin32, gsview32 |
| 973 | ;; `http://www.gnu.org/software/ghostscript/ghostscript.html' |
| 974 | ;; gsprint `http://www.cs.wisc.edu/~ghost/gsview/gsprint.htm'. |
| 975 | ;; enscript `http://people.ssh.fi/mtr/genscript/' |
| 976 | ;; psnup `http://gnuwin32.sourceforge.net/packages/psutils.htm' |
| 977 | ;; redmon `http://www.cs.wisc.edu/~ghost/redmon/' |
| 978 | ;; |
| 979 | ;; |
| 980 | ;; Acknowledgments |
| 981 | ;; --------------- |
| 982 | ;; |
| 983 | ;; Thanks to Stefan Monnier <monnier@iro.umontreal.ca> for GNU Emacs and XEmacs |
| 984 | ;; printing menu (in `pr-menu-spec') merging suggestion. |
| 985 | ;; |
| 986 | ;; Thanks to Lennart Borgman <lennart.borgman.073@student.lu.se> for gsprint |
| 987 | ;; suggestion (see tip 5 in section Tips). |
| 988 | ;; |
| 989 | ;; Thanks to Drew Adams <drew.adams@oracle.com> for suggestions: |
| 990 | ;; - directory processing. |
| 991 | ;; - `pr-path-alist' variable. |
| 992 | ;; - doc fix. |
| 993 | ;; - a lot of tests on Windows. |
| 994 | ;; |
| 995 | ;; Thanks to Fred Labrosse <f.labrosse@maths.bath.ac.uk> for XEmacs tests. |
| 996 | ;; |
| 997 | ;; Thanks to Klaus Berndl <klaus.berndl@sdm.de> for invaluable help/debugging |
| 998 | ;; and for suggestions: |
| 999 | ;; - even/odd pages printing. |
| 1000 | ;; - ghostscript parameters for `pr-ps-printer-alist'. |
| 1001 | ;; - default printer name. |
| 1002 | ;; - completion functions. |
| 1003 | ;; - automagic region detection. |
| 1004 | ;; - menu entry hiding. |
| 1005 | ;; - fast fire PostScript printing command. |
| 1006 | ;; - `pr-path-style' variable. |
| 1007 | ;; |
| 1008 | ;; Thanks to Kim F. Storm <storm@filanet.dk> for beta-test and for suggestions: |
| 1009 | ;; - PostScript Print and PostScript Print Preview merge. |
| 1010 | ;; - Tools/Printing menu. |
| 1011 | ;; - replace *-using-preview by *-using-ghostscript. |
| 1012 | ;; - printer selection. |
| 1013 | ;; - extra parameters for `pr-ps-printer-alist'. |
| 1014 | ;; |
| 1015 | ;; Thanks to: |
| 1016 | ;; Frederic Corne <frederic.corne@erli.fr> print-nt.el |
| 1017 | ;; Tom Vogels <tov@ece.cmu.edu> mh-e-init.el |
| 1018 | ;; Matthew O. Persico <mpersico@erols.com> win32-ps-print.el |
| 1019 | ;; Volker Franz <volker.franz@tuebingen.mpg.de> ps-print-interface.el |
| 1020 | ;; And to all people who contributed with them. |
| 1021 | ;; |
| 1022 | ;; |
| 1023 | ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1024 | |
| 1025 | ;;; Code: |
| 1026 | |
| 1027 | |
| 1028 | (require 'lpr) |
| 1029 | (require 'ps-print) |
| 1030 | |
| 1031 | |
| 1032 | (and (string< ps-print-version "6.6.4") |
| 1033 | (error "`printing' requires `ps-print' package version 6.6.4 or later")) |
| 1034 | |
| 1035 | |
| 1036 | (defconst pr-cygwin-system |
| 1037 | (and ps-windows-system (getenv "OSTYPE") |
| 1038 | (string-match "cygwin" (getenv "OSTYPE")))) |
| 1039 | |
| 1040 | |
| 1041 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1042 | ;; To avoid compilation gripes |
| 1043 | |
| 1044 | |
| 1045 | (or (fboundp 'easy-menu-intern) ; hacked from easymenu.el |
| 1046 | (defsubst easy-menu-intern (s) |
| 1047 | (if (stringp s) (intern s) s))) |
| 1048 | |
| 1049 | |
| 1050 | |
| 1051 | (or (fboundp 'subst-char-in-string) ; hacked from subr.el |
| 1052 | (defun subst-char-in-string (fromchar tochar string &optional inplace) |
| 1053 | "Replace FROMCHAR with TOCHAR in STRING each time it occurs. |
| 1054 | Unless optional argument INPLACE is non-nil, return a new string." |
| 1055 | (let ((i (length string)) |
| 1056 | (newstr (if inplace string (copy-sequence string)))) |
| 1057 | (while (> (setq i (1- i)) 0) |
| 1058 | (if (eq (aref newstr i) fromchar) |
| 1059 | (aset newstr i tochar))) |
| 1060 | newstr))) |
| 1061 | |
| 1062 | |
| 1063 | (or (fboundp 'make-temp-file) ; hacked from subr.el |
| 1064 | (defun make-temp-file (prefix &optional dir-flag suffix) |
| 1065 | "Create a temporary file. |
| 1066 | The returned file name (created by appending some random characters at the end |
| 1067 | of PREFIX, and expanding against `temporary-file-directory' if necessary), |
| 1068 | is guaranteed to point to a newly created empty file. |
| 1069 | You can then use `write-region' to write new data into the file. |
| 1070 | |
| 1071 | If DIR-FLAG is non-nil, create a new empty directory instead of a file. |
| 1072 | |
| 1073 | If SUFFIX is non-nil, add that at the end of the file name." |
| 1074 | (let ((umask (default-file-modes)) |
| 1075 | file) |
| 1076 | (unwind-protect |
| 1077 | (progn |
| 1078 | ;; Create temp files with strict access rights. It's easy to |
| 1079 | ;; loosen them later, whereas it's impossible to close the |
| 1080 | ;; time-window of loose permissions otherwise. |
| 1081 | (set-default-file-modes ?\700) |
| 1082 | (while (condition-case () |
| 1083 | (progn |
| 1084 | (setq file |
| 1085 | (make-temp-name |
| 1086 | (expand-file-name prefix temporary-file-directory))) |
| 1087 | (if suffix |
| 1088 | (setq file (concat file suffix))) |
| 1089 | (if dir-flag |
| 1090 | (make-directory file) |
| 1091 | (write-region "" nil file nil 'silent nil 'excl)) |
| 1092 | nil) |
| 1093 | (file-already-exists t)) |
| 1094 | ;; the file was somehow created by someone else between |
| 1095 | ;; `make-temp-name' and `write-region', let's try again. |
| 1096 | nil) |
| 1097 | file) |
| 1098 | ;; Reset the umask. |
| 1099 | (set-default-file-modes umask))))) |
| 1100 | |
| 1101 | |
| 1102 | ;; GNU Emacs |
| 1103 | (defalias 'pr-e-frame-char-height 'frame-char-height) |
| 1104 | (defalias 'pr-e-frame-char-width 'frame-char-width) |
| 1105 | (defalias 'pr-e-mouse-pixel-position 'mouse-pixel-position) |
| 1106 | ;; XEmacs |
| 1107 | (defalias 'pr-x-add-submenu 'add-submenu) |
| 1108 | (defalias 'pr-x-event-function 'event-function) |
| 1109 | (defalias 'pr-x-event-object 'event-object) |
| 1110 | (defalias 'pr-x-find-menu-item 'find-menu-item) |
| 1111 | (defalias 'pr-x-font-height 'font-height) |
| 1112 | (defalias 'pr-x-font-width 'font-width) |
| 1113 | (defalias 'pr-x-get-popup-menu-response 'get-popup-menu-response) |
| 1114 | (defalias 'pr-x-make-event 'make-event) |
| 1115 | (defalias 'pr-x-misc-user-event-p 'misc-user-event-p) |
| 1116 | (defalias 'pr-x-relabel-menu-item 'relabel-menu-item) |
| 1117 | (defalias 'pr-x-event-x-pixel 'event-x-pixel) |
| 1118 | (defalias 'pr-x-event-y-pixel 'event-y-pixel) |
| 1119 | |
| 1120 | (cond |
| 1121 | ((featurep 'xemacs) ; XEmacs |
| 1122 | (defvar current-menubar nil) |
| 1123 | (defvar current-mouse-event nil) |
| 1124 | (defvar zmacs-region-stays nil) |
| 1125 | (defalias 'pr-f-set-keymap-parents 'set-keymap-parents) |
| 1126 | (defalias 'pr-f-set-keymap-name 'set-keymap-name) |
| 1127 | (defun pr-f-read-string (prompt initial history default) |
| 1128 | (let ((str (read-string prompt initial))) |
| 1129 | (if (and str (not (string= str ""))) |
| 1130 | str |
| 1131 | default))) |
| 1132 | (defun pr-keep-region-active () |
| 1133 | (setq zmacs-region-stays t))) |
| 1134 | |
| 1135 | (t ; GNU Emacs |
| 1136 | (defvar deactivate-mark nil) |
| 1137 | (defalias 'pr-f-set-keymap-parents 'set-keymap-parent) |
| 1138 | (defalias 'pr-f-set-keymap-name 'ignore) |
| 1139 | (defalias 'pr-f-read-string 'read-string) |
| 1140 | (defun pr-keep-region-active () |
| 1141 | (setq deactivate-mark nil)))) |
| 1142 | |
| 1143 | |
| 1144 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1145 | ;; Customization Functions |
| 1146 | |
| 1147 | |
| 1148 | (defun pr-alist-custom-set (symbol value) |
| 1149 | "Set the value of custom variables for printer & utility selection." |
| 1150 | (set symbol value) |
| 1151 | (and (featurep 'printing) ; update only after printing is loaded |
| 1152 | (pr-update-menus t))) |
| 1153 | |
| 1154 | |
| 1155 | (defun pr-ps-utility-custom-set (symbol value) |
| 1156 | "Update utility menu entry." |
| 1157 | (set symbol value) |
| 1158 | (and (featurep 'printing) ; update only after printing is loaded |
| 1159 | (pr-menu-set-utility-title value))) |
| 1160 | |
| 1161 | |
| 1162 | (defun pr-ps-name-custom-set (symbol value) |
| 1163 | "Update `PostScript Printer:' menu entry." |
| 1164 | (set symbol value) |
| 1165 | (and (featurep 'printing) ; update only after printing is loaded |
| 1166 | (pr-menu-set-ps-title value))) |
| 1167 | |
| 1168 | |
| 1169 | (defun pr-txt-name-custom-set (symbol value) |
| 1170 | "Update `Text Printer:' menu entry." |
| 1171 | (set symbol value) |
| 1172 | (and (featurep 'printing) ; update only after printing is loaded |
| 1173 | (pr-menu-set-txt-title value))) |
| 1174 | |
| 1175 | |
| 1176 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1177 | ;; User Interface (I) |
| 1178 | |
| 1179 | |
| 1180 | (defgroup printing nil |
| 1181 | "Printing Utilities group." |
| 1182 | :tag "Printing Utilities" |
| 1183 | :link '(emacs-library-link :tag "Source Lisp File" "printing.el") |
| 1184 | :prefix "pr-" |
| 1185 | :version "20" |
| 1186 | :group 'wp |
| 1187 | :group 'postscript) |
| 1188 | |
| 1189 | |
| 1190 | (defcustom pr-path-style |
| 1191 | (if (and (not pr-cygwin-system) |
| 1192 | ps-windows-system) |
| 1193 | 'windows |
| 1194 | 'unix) |
| 1195 | "*Specify which path style to use for external commands. |
| 1196 | |
| 1197 | Valid values are: |
| 1198 | |
| 1199 | windows Windows 9x/NT style (\\) |
| 1200 | |
| 1201 | unix Unix style (/)" |
| 1202 | :type '(choice :tag "Path style" |
| 1203 | (const :tag "Windows 9x/NT Style (\\)" :value windows) |
| 1204 | (const :tag "Unix Style (/)" :value unix)) |
| 1205 | :version "20" |
| 1206 | :group 'printing) |
| 1207 | |
| 1208 | |
| 1209 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1210 | ;; Internal Functions (I) |
| 1211 | |
| 1212 | |
| 1213 | (defun pr-dosify-file-name (path) |
| 1214 | "Replace unix-style directory separator character with dos/windows one." |
| 1215 | (interactive "sPath: ") |
| 1216 | (if (eq pr-path-style 'windows) |
| 1217 | (subst-char-in-string ?/ ?\\ path) |
| 1218 | path)) |
| 1219 | |
| 1220 | |
| 1221 | (defun pr-unixify-file-name (path) |
| 1222 | "Replace dos/windows-style directory separator character with unix one." |
| 1223 | (interactive "sPath: ") |
| 1224 | (if (eq pr-path-style 'windows) |
| 1225 | (subst-char-in-string ?\\ ?/ path) |
| 1226 | path)) |
| 1227 | |
| 1228 | |
| 1229 | (defun pr-standard-file-name (path) |
| 1230 | "Ensure the proper directory separator depending on the OS. |
| 1231 | That is, if Emacs is running on DOS/Windows, ensure dos/windows-style directory |
| 1232 | separator; otherwise, ensure unix-style directory separator." |
| 1233 | (if (or pr-cygwin-system ps-windows-system) |
| 1234 | (subst-char-in-string ?/ ?\\ path) |
| 1235 | (subst-char-in-string ?\\ ?/ path))) |
| 1236 | |
| 1237 | |
| 1238 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 1239 | ;; User Interface (II) |
| 1240 | |
| 1241 | |
| 1242 | (defcustom pr-path-alist |
| 1243 | '((unix PATH) |
| 1244 | (cygwin PATH) |
| 1245 | (windows PATH)) |
| 1246 | "*Specify an alist for command paths. |
| 1247 | |
| 1248 | It's used to find commands used for printing package, like gv, gs, gsview.exe, |
| 1249 | mpage, print.exe, etc. See also `pr-command' function. |
| 1250 | |
| 1251 | Each element has the form: |
| 1252 | |
| 1253 | (ENTRY DIRECTORY...) |
| 1254 | |
| 1255 | Where: |
| 1256 | |
| 1257 | ENTRY It's a symbol, used to identify this entry. |
| 1258 | There must exist at least one of the following entries: |
| 1259 | |
| 1260 | unix this entry is used when Emacs is running on GNU or |
| 1261 | Unix system. |
| 1262 | |
| 1263 | cygwin this entry is used when Emacs is running on Windows |
| 1264 | 95/98/NT/2000 with Cygwin. |
| 1265 | |
| 1266 | windows this entry is used when Emacs is running on Windows |
| 1267 | 95/98/NT/2000. |
| 1268 | |
| 1269 | DIRECTORY It should be a string or a symbol. If it's a symbol, it should |
| 1270 | exist an equal entry in `pr-path-alist'. If it's a string, |
| 1271 | it's considered a directory specification. |
| 1272 | |
| 1273 | The directory specification may contain: |
| 1274 | $var environment variable expansion |
| 1275 | ~/ tilde expansion |
| 1276 | ./ current directory |
| 1277 | ../ previous directory |
| 1278 | |
| 1279 | For example, let's say the home directory is /home/my and the |
| 1280 | current directory is /home/my/dir, so: |
| 1281 | |
| 1282 | THE ENTRY IS EXPANDED TO |
| 1283 | ~/entry /home/my/entry |
| 1284 | ./entry /home/my/dir/entry |
| 1285 | ../entry /home/my/entry |
| 1286 | $HOME/entry /home/my/entry |
| 1287 | $HOME/~/other/../my/entry /home/my/entry |
| 1288 | |
| 1289 | SPECIAL SYMBOL: If the symbol `PATH' is used in the directory |
| 1290 | list and there isn't a `PATH' entry in `pr-path-alist' or the |
| 1291 | `PATH' entry has a null directory list, the PATH environment |
| 1292 | variable is used. |
| 1293 | |
| 1294 | Examples: |
| 1295 | |
| 1296 | * On GNU or Unix system: |
| 1297 | |
| 1298 | '((unix \".\" \"~/bin\" ghostview mpage PATH) |
| 1299 | (ghostview \"$HOME/bin/gsview-dir\") |
| 1300 | (mpage \"$HOME/bin/mpage-dir\") |
| 1301 | ) |
| 1302 | |
| 1303 | * On Windows system: |
| 1304 | |
| 1305 | '((windows \"c:/applications/executables\" PATH ghostview mpage) |
| 1306 | (ghostview \"c:/gs/gsview-dir\") |
| 1307 | (mpage \"c:/mpage-dir\") |
| 1308 | )" |
| 1309 | :type '(repeat |
| 1310 | (cons :tag "" |
| 1311 | (symbol :tag "Identifier ") |
| 1312 | (repeat :tag "Directory List" |
| 1313 | (choice :menu-tag "Directory" |
| 1314 | :tag "Directory" |
| 1315 | (string :value "") |
| 1316 | (symbol :value symbol))))) |
| 1317 | :version "20" |
| 1318 | :group 'printing) |
| 1319 | |
| 1320 | |
| 1321 | (defcustom pr-txt-name 'default |
| 1322 | "*Specify a printer for printing a text file. |
| 1323 | |
| 1324 | The printer name symbol should be defined on `pr-txt-printer-alist' (see it for |
| 1325 | documentation). |
| 1326 | |
| 1327 | This variable should be modified by customization engine. If this variable is |
| 1328 | modified by other means (for example, a lisp function), use `pr-update-menus' |
| 1329 | function (see it for documentation) to update text printer menu." |
| 1330 | :type 'symbol |
| 1331 | :set 'pr-txt-name-custom-set |
| 1332 | :version "20" |
| 1333 | :group 'printing) |
| 1334 | |
| 1335 | |
| 1336 | (defcustom pr-txt-printer-alist |
| 1337 | (list (list 'default lpr-command nil |
| 1338 | (cond ((boundp 'printer-name) printer-name) |
| 1339 | (ps-windows-system "PRN") |
| 1340 | (t nil) |
| 1341 | ))) |
| 1342 | ;; Examples: |
| 1343 | ;; * On GNU or Unix system: |
| 1344 | ;; '((prt_06a "lpr" nil "prt_06a") |
| 1345 | ;; (prt_07c nil nil "prt_07c") |
| 1346 | ;; ) |
| 1347 | ;; * On Windows system: |
| 1348 | ;; '((prt_06a "print" nil "/D:\\\\printers\\prt_06a") |
| 1349 | ;; (prt_07c nil nil "/D:\\\\printers\\prt_07c") |
| 1350 | ;; (PRN "" nil "PRN") |
| 1351 | ;; (standard "redpr.exe" nil "") |
| 1352 | ;; ) |
| 1353 | "*Specify an alist of all text printers (text printer database). |
| 1354 | |
| 1355 | The alist element has the form: |
| 1356 | |
| 1357 | (SYMBOL COMMAND SWITCHES NAME) |
| 1358 | |
| 1359 | Where: |
| 1360 | |
| 1361 | SYMBOL It's a symbol to identify a text printer. It's for |
| 1362 | `pr-txt-name' variable setting and for menu selection. |
| 1363 | Examples: |
| 1364 | 'prt_06a |
| 1365 | 'my_printer |
| 1366 | |
| 1367 | COMMAND Name of the program for printing a text file. On MS-DOS and |
| 1368 | MS-Windows systems, if the value is an empty string, then Emacs |
| 1369 | will write directly to the printer port given by NAME (see text |
| 1370 | below), that is, the NAME should be something like \"PRN\" or |
| 1371 | \"LPT1:\". |
| 1372 | If NAME is something like \"\\\\\\\\host\\\\share-name\" then |
| 1373 | COMMAND shouldn't be an empty string. |
| 1374 | The programs `print' and `nprint' (the standard print programs |
| 1375 | on Windows NT and Novell Netware respectively) are handled |
| 1376 | specially, using NAME as the destination for output; any other |
| 1377 | program is treated like `lpr' except that an explicit filename |
| 1378 | is given as the last argument. |
| 1379 | If COMMAND is nil, it's used the default printing program: |
| 1380 | `print' for Windows system, `lp' for lp system and `lpr' for |
| 1381 | all other systems. See also `pr-path-alist'. |
| 1382 | Examples: |
| 1383 | \"print\" |
| 1384 | \"lpr\" |
| 1385 | \"lp\" |
| 1386 | |
| 1387 | SWITCHES List of sexp's to pass as extra options for text printer |
| 1388 | program. It is recommended to set NAME (see text below) |
| 1389 | instead of including an explicit switch on this list. |
| 1390 | Example: |
| 1391 | . for lpr |
| 1392 | '(\"-#3\" \"-l\") |
| 1393 | nil |
| 1394 | |
| 1395 | NAME A string that specifies a text printer name. |
| 1396 | On Unix-like systems, a string value should be a name |
| 1397 | understood by lpr's -P option (or lp's -d option). |
| 1398 | On MS-DOS and MS-Windows systems, it is the name of a printer |
| 1399 | device or port. Typical non-default settings would be \"LPT1:\" |
| 1400 | to \"LPT3:\" for parallel printers, or \"COM1\" to \"COM4\" or |
| 1401 | \"AUX\" for serial printers, or \"\\\\\\\\hostname\\\\printer\" |
| 1402 | (or \"/D:\\\\\\\\hostname\\\\printer\") for a shared network |
| 1403 | printer. You can also set it to a name of a file, in which |
| 1404 | case the output gets appended to that file. If you want to |
| 1405 | discard the printed output, set this to \"NUL\". |
| 1406 | Examples: |
| 1407 | . for print.exe |
| 1408 | \"/D:\\\\\\\\host\\\\share-name\" |
| 1409 | \"LPT1:\" |
| 1410 | \"PRN\" |
| 1411 | |
| 1412 | . for lpr or lp |
| 1413 | \"share-name\" |
| 1414 | |
| 1415 | This variable should be modified by customization engine. If this variable is |
| 1416 | modified by other means (for example, a lisp function), use `pr-update-menus' |
| 1417 | function (see it for documentation) to update text printer menu. |
| 1418 | |
| 1419 | Examples: |
| 1420 | |
| 1421 | * On GNU or Unix system: |
| 1422 | |
| 1423 | '((prt_06a \"lpr\" nil \"prt_06a\") |
| 1424 | (prt_07c nil nil \"prt_07c\") |
| 1425 | ) |
| 1426 | |
| 1427 | * On Windows system: |
| 1428 | |
| 1429 | '((prt_06a \"print\" nil \"/D:\\\\\\\\printers\\\\prt_06a\") |
| 1430 | (prt_07c nil nil \"/D:\\\\\\\\printers\\\\prt_07c\") |
| 1431 | (PRN \"\" nil \"PRN\") |
| 1432 | (standard \"redpr.exe\" nil \"\") |
| 1433 | ) |
| 1434 | |
| 1435 | Useful links: |
| 1436 | |
| 1437 | * Information about the print command (print.exe) |
| 1438 | `http://www.computerhope.com/printhlp.htm' |
| 1439 | |
| 1440 | * RedMon - Redirection Port Monitor (redpr.exe) |
| 1441 | `http://www.cs.wisc.edu/~ghost/redmon/index.htm' |
| 1442 | |
| 1443 | * Redirection Port Monitor (redpr.exe on-line help) |
| 1444 | `http://www.cs.wisc.edu/~ghost/redmon/en/redmon.htm' |
| 1445 | |
| 1446 | * UNIX man pages: lpr (or type `man lpr') |
| 1447 | `http://bama.ua.edu/cgi-bin/man-cgi?lpr' |
| 1448 | `http://www.mediacollege.com/cgi-bin/man/page.cgi?section=all&topic=lpr' |
| 1449 | |
| 1450 | * UNIX man pages: lp (or type `man lp') |
| 1451 | `http://bama.ua.edu/cgi-bin/man-cgi?lp' |
| 1452 | `http://www.mediacollege.com/cgi-bin/man/page.cgi?section=all&topic=lp' |
| 1453 | " |
| 1454 | :type '(repeat |
| 1455 | (list :tag "Text Printer" |
| 1456 | (symbol :tag "Printer Symbol Name") |
| 1457 | (string :tag "Printer Command") |
| 1458 | (repeat :tag "Printer Switches" |
| 1459 | (sexp :tag "Switch" :value "")) |
| 1460 | (choice :menu-tag "Printer Name" |
| 1461 | :tag "Printer Name" |
| 1462 | (const :tag "None" nil) |
| 1463 | string))) |
| 1464 | :set 'pr-alist-custom-set |
| 1465 | :version "20" |
| 1466 | :group 'printing) |
| 1467 | |
| 1468 | |
| 1469 | (defcustom pr-ps-name 'default |
| 1470 | "*Specify a printer for printing a PostScript file. |
| 1471 | |
| 1472 | This printer name symbol should be defined on `pr-ps-printer-alist' (see it for |
| 1473 | documentation). |
| 1474 | |
| 1475 | This variable should be modified by customization engine. If this variable is |
| 1476 | modified by other means (for example, a lisp function), use `pr-update-menus' |
| 1477 | function (see it for documentation) to update PostScript printer menu." |
| 1478 | :type 'symbol |
| 1479 | :set 'pr-ps-name-custom-set |
| 1480 | :version "20" |
| 1481 | :group 'printing) |
| 1482 | |
| 1483 | |
| 1484 | (defcustom pr-ps-printer-alist |
| 1485 | (list (list 'default lpr-command nil |
| 1486 | (cond (ps-windows-system nil) |
| 1487 | (ps-lp-system "-d") |
| 1488 | (t "-P")) |
| 1489 | (or (getenv "PRINTER") (getenv "LPDEST") ps-printer-name))) |
| 1490 | ;; Examples: |
| 1491 | ;; * On GNU or Unix system: |
| 1492 | ;; '((lps_06b "lpr" nil "-P" "lps_06b") |
| 1493 | ;; (lps_07c "lpr" nil nil "lps_07c") |
| 1494 | ;; (lps_08c nil nil nil "lps_08c") |
| 1495 | ;; ) |
| 1496 | ;; * On Windows system: |
| 1497 | ;; '((lps_06a "print" nil "/D:" "\\\\printers\\lps_06a") |
| 1498 | ;; (lps_06b "print" nil nil "\\\\printers\\lps_06b") |
| 1499 | ;; (lps_07c "print" nil "" "/D:\\\\printers\\lps_07c") |
| 1500 | ;; (lps_08c nil nil nil "\\\\printers\\lps_08c") |
| 1501 | ;; (b/w "gsprint" ("-all" "-twoup") "-printer " "b/w-pr-name") |
| 1502 | ;; (LPT1 "" nil "" "LPT1:") |
| 1503 | ;; (PRN "" nil "" "PRN") |
| 1504 | ;; (standard "redpr.exe" nil "" "") |
| 1505 | ;; ) |
| 1506 | "*Specify an alist for all PostScript printers (PostScript printer database). |
| 1507 | |
| 1508 | The alist element has the form: |
| 1509 | |
| 1510 | (SYMBOL COMMAND SWITCHES PRINTER-SWITCH NAME DEFAULT...) |
| 1511 | |
| 1512 | Where: |
| 1513 | |
| 1514 | SYMBOL It's a symbol to identify a PostScript printer. It's for |
| 1515 | `pr-ps-name' variable setting and for menu selection. |
| 1516 | Examples: |
| 1517 | 'prt_06a |
| 1518 | 'my_printer |
| 1519 | |
| 1520 | COMMAND Name of the program for printing a PostScript file. On MS-DOS |
| 1521 | and MS-Windows systems, if the value is an empty string then |
| 1522 | Emacs will write directly to the printer port given by NAME |
| 1523 | (see text below), that is, the NAME should be something like |
| 1524 | \"PRN\" or \"LPT1:\". |
| 1525 | If NAME is something like \"\\\\\\\\host\\\\share-name\" then |
| 1526 | COMMAND shouldn't be an empty string. |
| 1527 | The programs `print' and `nprint' (the standard print programs |
| 1528 | on Windows NT and Novell Netware respectively) are handled |
| 1529 | specially, using NAME as the destination for output; any other |
| 1530 | program is treated like `lpr' except that an explicit filename |
| 1531 | is given as the last argument. |
| 1532 | If COMMAND is nil, it's used the default printing program: |
| 1533 | `print' for Windows system, `lp' for lp system and `lpr' for |
| 1534 | all other systems. See also `pr-path-alist'. |
| 1535 | Examples: |
| 1536 | \"print\" |
| 1537 | \"lpr\" |
| 1538 | \"lp\" |
| 1539 | \"cp\" |
| 1540 | \"gsprint\" |
| 1541 | |
| 1542 | SWITCHES List of sexp's to pass as extra options for PostScript printer |
| 1543 | program. It is recommended to set NAME (see text below) |
| 1544 | instead of including an explicit switch on this list. |
| 1545 | Example: |
| 1546 | . for lpr |
| 1547 | '(\"-#3\" \"-l\") |
| 1548 | nil |
| 1549 | |
| 1550 | . for gsprint.exe |
| 1551 | '(\"-all\" \"-twoup\") |
| 1552 | |
| 1553 | PRINTER-SWITCH A string that specifies PostScript printer name switch. If |
| 1554 | it's necessary to have a space between PRINTER-SWITCH and NAME, |
| 1555 | it should be inserted at the end of PRINTER-SWITCH string. |
| 1556 | If PRINTER-SWITCH is nil, it's used the default printer name |
| 1557 | switch: `/D:' for Windows system, `-d' for lp system and `-P' |
| 1558 | for all other systems. |
| 1559 | Examples: |
| 1560 | . for lpr |
| 1561 | \"-P \" |
| 1562 | |
| 1563 | . for lp |
| 1564 | \"-d \" |
| 1565 | |
| 1566 | . for print.exe |
| 1567 | \"/D:\" |
| 1568 | |
| 1569 | . for gsprint.exe |
| 1570 | \"-printer \" |
| 1571 | |
| 1572 | NAME A string that specifies a PostScript printer name. |
| 1573 | On Unix-like systems, a string value should be a name |
| 1574 | understood by lpr's -P option (or lp's -d option). |
| 1575 | On MS-DOS and MS-Windows systems, it is the name of a printer |
| 1576 | device or port. Typical non-default settings would be \"LPT1:\" |
| 1577 | to \"LPT3:\" for parallel printers, or \"COM1\" to \"COM4\" or |
| 1578 | \"AUX\" for serial printers, or \"\\\\\\\\hostname\\\\printer\" |
| 1579 | (or \"/D:\\\\\\\\hostname\\\\printer\") for a shared network |
| 1580 | printer. You can also set it to a name of a file, in which |
| 1581 | case the output gets appended to that file. If you want to |
| 1582 | discard the printed output, set this to \"NUL\". |
| 1583 | Examples: |
| 1584 | . for cp.exe |
| 1585 | \"\\\\\\\\host\\\\share-name\" |
| 1586 | |
| 1587 | . for print.exe or gsprint.exe |
| 1588 | \"/D:\\\\\\\\host\\\\share-name\" |
| 1589 | \"\\\\\\\\host\\\\share-name\" |
| 1590 | \"LPT1:\" |
| 1591 | \"PRN\" |
| 1592 | |
| 1593 | . for lpr or lp |
| 1594 | \"share-name\" |
| 1595 | |
| 1596 | DEFAULT It's a way to set default values when this entry is selected. |
| 1597 | It's a cons like: |
| 1598 | |
| 1599 | (VARIABLE . VALUE) |
| 1600 | |
| 1601 | That associates VARIABLE with VALUE. when this entry is |
| 1602 | selected, it's executed the following command: |
| 1603 | |
| 1604 | (set VARIABLE (eval VALUE)) |
| 1605 | |
| 1606 | Note that VALUE can be any valid lisp expression. So, don't |
| 1607 | forget to quote symbols and constant lists. |
| 1608 | If VARIABLE is the special keyword `inherits-from:', VALUE must |
| 1609 | be a symbol name setting defined in `pr-setting-database' from |
| 1610 | which the current setting inherits the context. Take care with |
| 1611 | circular inheritance. |
| 1612 | Examples: |
| 1613 | '(ps-landscape-mode . nil) |
| 1614 | '(ps-spool-duplex . t) |
| 1615 | '(pr-gs-device . (my-gs-device t)) |
| 1616 | |
| 1617 | This variable should be modified by customization engine. If this variable is |
| 1618 | modified by other means (for example, a lisp function), use `pr-update-menus' |
| 1619 | function (see it for documentation) to update PostScript printer menu. |
| 1620 | |
| 1621 | Examples: |
| 1622 | |
| 1623 | * On GNU or Unix system: |
| 1624 | |
| 1625 | '((lps_06b \"lpr\" nil \"-P\" \"lps_06b\") |
| 1626 | (lps_07c \"lpr\" nil nil \"lps_07c\") |
| 1627 | (lps_08c nil nil nil \"lps_08c\") |
| 1628 | ) |
| 1629 | |
| 1630 | * On Windows system: |
| 1631 | |
| 1632 | '((lps_06a \"print\" nil \"/D:\" \"\\\\\\\\printers\\\\lps_06a\") |
| 1633 | (lps_06b \"print\" nil nil \"\\\\\\\\printers\\\\lps_06b\") |
| 1634 | (lps_07c \"print\" nil \"\" \"/D:\\\\\\\\printers\\\\lps_07c\") |
| 1635 | (lps_08c nil nil nil \"\\\\\\\\printers\\\\lps_08c\") |
| 1636 | (b/w1 \"gsprint\" (\"-all\" \"-twoup\") \"-printer \" \"b/w-pr-name\") |
| 1637 | (b/w2 \"gsprint\" (\"-all\" \"-twoup\") nil \"-printer \\\\\\\\printers\\\\lps_06a\") |
| 1638 | (LPT1 \"\" nil \"\" \"LPT1:\") |
| 1639 | (PRN \"\" nil \"\" \"PRN\") |
| 1640 | (standard \"redpr.exe\" nil \"\" \"\") |
| 1641 | ) |
| 1642 | |
| 1643 | |
| 1644 | gsprint: |
| 1645 | |
| 1646 | You can use gsprint instead of ghostscript to print monochrome PostScript files |
| 1647 | in Windows. The gsprint utility documentation says that it is more efficient |
| 1648 | than ghostscript to print monochrome PostScript. |
| 1649 | |
| 1650 | To print non-monochrome PostScript file, the efficiency of ghostscript is |
| 1651 | similar to gsprint. |
| 1652 | |
| 1653 | Also the gsprint utility comes together with gsview distribution. |
| 1654 | |
| 1655 | As an example of gsprint declaration: |
| 1656 | |
| 1657 | (setq pr-ps-printer-alist |
| 1658 | '((A \"gsprint\" (\"-all\" \"-twoup\") \"-printer \" \"lps_015\") |
| 1659 | (B \"gsprint\" (\"-all\" \"-twoup\") nil \"-printer lps_015\") |
| 1660 | ;; some other printer declaration |
| 1661 | )) |
| 1662 | |
| 1663 | The example above declares that printer A prints all pages (-all) and two pages |
| 1664 | per sheet (-twoup). The printer B declaration does the same as the printer A |
| 1665 | declaration, the only difference is the printer name selection. |
| 1666 | |
| 1667 | There are other command line options like: |
| 1668 | |
| 1669 | -mono Render in monochrome as 1bit/pixel (only black and white). |
| 1670 | -grey Render in greyscale as 8bits/pixel. |
| 1671 | -color Render in color as 24bits/pixel. |
| 1672 | |
| 1673 | The default is `-mono'. So, printer A and B in the example above are using |
| 1674 | implicitly the `-mono' option. Note that in `-mono' no gray tone or color is |
| 1675 | printed, this includes the zebra stripes, that is, in `-mono' the zebra stripes |
| 1676 | are not printed. |
| 1677 | |
| 1678 | |
| 1679 | Useful links: |
| 1680 | |
| 1681 | * GSPRINT - Ghostscript print to Windows printer |
| 1682 | `http://www.cs.wisc.edu/~ghost/gsview/gsprint.htm' |
| 1683 | |
| 1684 | * Introduction to Ghostscript |
| 1685 | `http://www.cs.wisc.edu/~ghost/doc/intro.htm' |
| 1686 | |
| 1687 | * How to use Ghostscript |
| 1688 | `http://www.cs.wisc.edu/~ghost/doc/cvs/Use.htm' |
| 1689 | |
| 1690 | * Information about the print command (print.exe) |
| 1691 | `http://www.computerhope.com/printhlp.htm' |
| 1692 | |
| 1693 | * RedMon - Redirection Port Monitor (redpr.exe) |
| 1694 | `http://www.cs.wisc.edu/~ghost/redmon/index.htm' |
| 1695 | |
| 1696 | * Redirection Port Monitor (redpr.exe on-line help) |
| 1697 | `http://www.cs.wisc.edu/~ghost/redmon/en/redmon.htm' |
| 1698 | |
| 1699 | * UNIX man pages: lpr (or type `man lpr') |
| 1700 | `http://bama.ua.edu/cgi-bin/man-cgi?lpr' |
| 1701 | `http://www.mediacollege.com/cgi-bin/man/page.cgi?section=all&topic=lpr' |
| 1702 | |
| 1703 | * UNIX man pages: lp (or type `man lp') |
| 1704 | `http://bama.ua.edu/cgi-bin/man-cgi?lp' |
| 1705 | `http://www.mediacollege.com/cgi-bin/man/page.cgi?section=all&topic=lp' |
| 1706 | |
| 1707 | * GNU utilities for Win32 (cp.exe) |
| 1708 | `http://unxutils.sourceforge.net/' |
| 1709 | " |
| 1710 | :type '(repeat |
| 1711 | (list |
| 1712 | :tag "PostScript Printer" |
| 1713 | (symbol :tag "Printer Symbol Name") |
| 1714 | (string :tag "Printer Command") |
| 1715 | (repeat :tag "Printer Switches" |
| 1716 | (sexp :tag "Switch" :value "")) |
| 1717 | (choice :menu-tag "Printer Name Switch" |
| 1718 | :tag "Printer Name Switch" |
| 1719 | (const :tag "None" nil) |
| 1720 | string) |
| 1721 | (choice :menu-tag "Printer Name" |
| 1722 | :tag "Printer Name" |
| 1723 | (const :tag "None" nil) |
| 1724 | string) |
| 1725 | (repeat |
| 1726 | :tag "Default Value List" |
| 1727 | :inline t |
| 1728 | (cons |
| 1729 | :tag "" |
| 1730 | (choice |
| 1731 | :menu-tag "Variable" |
| 1732 | :tag "Variable" |
| 1733 | (const :tag "Landscape" ps-landscape-mode) |
| 1734 | (const :tag "Print Header" ps-print-header) |
| 1735 | (const :tag "Print Header Frame" ps-print-header-frame) |
| 1736 | (const :tag "Line Number" ps-line-number) |
| 1737 | (const :tag "Zebra Stripes" ps-zebra-stripes) |
| 1738 | (const :tag "Duplex" ps-spool-duplex) |
| 1739 | (const :tag "Tumble" ps-spool-tumble) |
| 1740 | (const :tag "Upside-Down" ps-print-upside-down) |
| 1741 | (const :tag "PS File Landscape" pr-file-landscape) |
| 1742 | (const :tag "PS File Duplex" pr-file-duplex) |
| 1743 | (const :tag "PS File Tumble" pr-file-tumble) |
| 1744 | (const :tag "Auto Region" pr-auto-region) |
| 1745 | (const :tag "Auto Mode" pr-auto-mode) |
| 1746 | (const :tag "Ghostscript Device" pr-gs-device) |
| 1747 | (const :tag "Ghostscript Resolution" pr-gs-resolution) |
| 1748 | (const :tag "inherits-from:" inherits-from:) |
| 1749 | (variable :tag "Other")) |
| 1750 | (sexp :tag "Value"))) |
| 1751 | )) |
| 1752 | :set 'pr-alist-custom-set |
| 1753 | :version "20" |
| 1754 | :group 'printing) |
| 1755 | |
| 1756 | |
| 1757 | (defcustom pr-temp-dir |
| 1758 | (pr-dosify-file-name |
| 1759 | (if (boundp 'temporary-file-directory) |
| 1760 | (symbol-value 'temporary-file-directory) |
| 1761 | ;; hacked from `temporary-file-directory' variable in files.el |
| 1762 | (file-name-as-directory |
| 1763 | (or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP") |
| 1764 | (cond (ps-windows-system "c:/temp") |
| 1765 | ((memq system-type '(vax-vms axp-vms)) "SYS$SCRATCH:") |
| 1766 | (t "/tmp") |
| 1767 | ))))) |
| 1768 | "*Specify a directory for temporary files during printing. |
| 1769 | |
| 1770 | See also `pr-ps-temp-file' and `pr-file-modes'." |
| 1771 | :type '(directory :tag "Temporary Directory") |
| 1772 | :version "20" |
| 1773 | :group 'printing) |
| 1774 | |
| 1775 | |
| 1776 | (defcustom pr-ps-temp-file "prspool-" |
| 1777 | "*Specify PostScript temporary file name prefix. |
| 1778 | |
| 1779 | See also `pr-temp-dir' and `pr-file-modes'." |
| 1780 | :type '(file :tag "PostScript Temporary File Name") |
| 1781 | :version "21" |
| 1782 | :group 'printing) |
| 1783 | |
| 1784 | |
| 1785 | ;; It uses 0600 as default instead of (default-file-modes). |
| 1786 | ;; So, by default, only the session owner have permission to deal with files |
| 1787 | ;; generated by `printing'. |
| 1788 | (defcustom pr-file-modes ?\600 |
| 1789 | "*Specify the file permission bits for newly created files. |
| 1790 | |
| 1791 | It should be an integer; only the low 9 bits are used. |
| 1792 | |
| 1793 | See also `pr-temp-dir' and `pr-ps-temp-file'." |
| 1794 | :type '(integer :tag "File Permission Bits") |
| 1795 | :version "21.3" |
| 1796 | :group 'printing) |
| 1797 | |
| 1798 | |
| 1799 | (defcustom pr-gv-command |
| 1800 | (if ps-windows-system |
| 1801 | "gsview32.exe" |
| 1802 | "gv") |
| 1803 | "*Specify path and name of the gsview/gv utility. |
| 1804 | |
| 1805 | See also `pr-path-alist'. |
| 1806 | |
| 1807 | Useful links: |
| 1808 | |
| 1809 | * GNU gv manual |
| 1810 | `http://www.gnu.org/software/gv/manual/gv.html' |
| 1811 | |
| 1812 | * GSview Help |
| 1813 | `http://www.cs.wisc.edu/~ghost/gsview/gsviewen.htm' |
| 1814 | |
| 1815 | * GSview Help - Common Problems |
| 1816 | `http://www.cs.wisc.edu/~ghost/gsview/gsviewen.htm#Common_Problems' |
| 1817 | |
| 1818 | * GSview Readme (compilation & installation) |
| 1819 | `http://www.cs.wisc.edu/~ghost/gsview/Readme.htm' |
| 1820 | |
| 1821 | * GSview (main site) |
| 1822 | `http://www.cs.wisc.edu/~ghost/gsview/index.htm' |
| 1823 | |
| 1824 | * Ghostscript, Ghostview and GSview |
| 1825 | `http://www.cs.wisc.edu/~ghost/' |
| 1826 | |
| 1827 | * Ghostview |
| 1828 | `http://www.cs.wisc.edu/~ghost/gv/index.htm' |
| 1829 | |
| 1830 | * gv 3.5, June 1997 |
| 1831 | `http://www.cs.wisc.edu/~ghost/gv/gv_doc/gv.html' |
| 1832 | |
| 1833 | * MacGSView (MacOS) |
| 1834 | `http://www.cs.wisc.edu/~ghost/macos/index.htm' |
| 1835 | " |
| 1836 | :type '(string :tag "Ghostview Utility") |
| 1837 | :version "20" |
| 1838 | :group 'printing) |
| 1839 | |
| 1840 | |
| 1841 | (defcustom pr-gs-command |
| 1842 | (if ps-windows-system |
| 1843 | "gswin32.exe" |
| 1844 | "gs") |
| 1845 | "*Specify path and name of the ghostscript utility. |
| 1846 | |
| 1847 | See also `pr-path-alist'. |
| 1848 | |
| 1849 | Useful links: |
| 1850 | |
| 1851 | * Ghostscript, Ghostview and GSview |
| 1852 | `http://www.cs.wisc.edu/~ghost/' |
| 1853 | |
| 1854 | * Introduction to Ghostscript |
| 1855 | `http://www.cs.wisc.edu/~ghost/doc/intro.htm' |
| 1856 | |
| 1857 | * How to use Ghostscript |
| 1858 | `http://www.cs.wisc.edu/~ghost/doc/cvs/Use.htm' |
| 1859 | |
| 1860 | * Printer compatibility |
| 1861 | `http://www.cs.wisc.edu/~ghost/doc/printer.htm' |
| 1862 | " |
| 1863 | :type '(string :tag "Ghostscript Utility") |
| 1864 | :version "20" |
| 1865 | :group 'printing) |
| 1866 | |
| 1867 | |
| 1868 | (defcustom pr-gs-switches |
| 1869 | (if ps-windows-system |
| 1870 | '("-q -dNOPAUSE -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts") |
| 1871 | '("-q -dNOPAUSE -I/usr/share/ghostscript/5.10")) |
| 1872 | "*Specify ghostscript switches. See the documentation on GS for more info. |
| 1873 | |
| 1874 | It's a list of strings, where each string is one or more ghostscript switches. |
| 1875 | |
| 1876 | A note on the gs switches: |
| 1877 | |
| 1878 | -q quiet |
| 1879 | -dNOPAUSE don't wait for user intervention |
| 1880 | -Ic:/gs/gs5.50;c:/gs/gs5.50/fonts the directories needed for gs |
| 1881 | -c quit it's added at the end to terminate gs |
| 1882 | |
| 1883 | To see ghostscript documentation for more information: |
| 1884 | |
| 1885 | * On GNU or Unix system: |
| 1886 | - for full documentation, type: man gs |
| 1887 | - for brief documentation, type: gs -h |
| 1888 | |
| 1889 | * On Windows system: |
| 1890 | - for full documentation, see in a browser the file |
| 1891 | c:/gstools/gs5.50/index.html, that is, the file index.html which is |
| 1892 | located in the same directory as gswin32.exe. |
| 1893 | - for brief documentation, type: gswin32.exe -h |
| 1894 | |
| 1895 | Useful links: |
| 1896 | |
| 1897 | * Introduction to Ghostscript |
| 1898 | `http://www.cs.wisc.edu/~ghost/doc/intro.htm' |
| 1899 | |
| 1900 | * How to use Ghostscript |
| 1901 | `http://www.cs.wisc.edu/~ghost/doc/cvs/Use.htm' |
| 1902 | |
| 1903 | * Printer compatibility |
| 1904 | `http://www.cs.wisc.edu/~ghost/doc/printer.htm' |
| 1905 | " |
| 1906 | :type '(repeat (string :tag "Ghostscript Switch")) |
| 1907 | :version "20" |
| 1908 | :group 'printing) |
| 1909 | |
| 1910 | |
| 1911 | (defcustom pr-gs-device |
| 1912 | (if ps-windows-system |
| 1913 | "mswinpr2" |
| 1914 | "uniprint") |
| 1915 | "*Specify the ghostscript device switch value (-sDEVICE=). |
| 1916 | |
| 1917 | A note on the gs switches: |
| 1918 | |
| 1919 | -sDEVICE=djet500 the printer - works with HP DeskJet 540 |
| 1920 | |
| 1921 | See `pr-gs-switches' for documentation. |
| 1922 | See also `pr-ps-printer-alist'." |
| 1923 | :type '(string :tag "Ghostscript Device") |
| 1924 | :version "20" |
| 1925 | :group 'printing) |
| 1926 | |
| 1927 | |
| 1928 | (defcustom pr-gs-resolution 300 |
| 1929 | "*Specify ghostscript resolution switch value (-r). |
| 1930 | |
| 1931 | A note on the gs switches: |
| 1932 | |
| 1933 | -r300 resolution 300x300 |
| 1934 | |
| 1935 | See `pr-gs-switches' for documentation. |
| 1936 | See also `pr-ps-printer-alist'." |
| 1937 | :type '(integer :tag "Ghostscript Resolution") |
| 1938 | :version "20" |
| 1939 | :group 'printing) |
| 1940 | |
| 1941 | |
| 1942 | (defcustom pr-print-using-ghostscript nil |
| 1943 | "*Non-nil means print using ghostscript. |
| 1944 | |
| 1945 | This is useful if you don't have a PostScript printer, so you could use the |
| 1946 | ghostscript to print a PostScript file. |
| 1947 | |
| 1948 | In GNU or Unix system, if ghostscript is set as a PostScript filter, this |
| 1949 | variable should be nil." |
| 1950 | :type 'boolean |
| 1951 | :version "20" |
| 1952 | :group 'printing) |
| 1953 | |
| 1954 | |
| 1955 | (defcustom pr-faces-p nil |
| 1956 | "*Non-nil means print with face attributes." |
| 1957 | :type 'boolean |
| 1958 | :version "20" |
| 1959 | :group 'printing) |
| 1960 | |
| 1961 | |
| 1962 | (defcustom pr-spool-p nil |
| 1963 | "*Non-nil means spool printing in a buffer." |
| 1964 | :type 'boolean |
| 1965 | :version "20" |
| 1966 | :group 'printing) |
| 1967 | |
| 1968 | |
| 1969 | (defcustom pr-file-landscape nil |
| 1970 | "*Non-nil means print PostScript file in landscape orientation." |
| 1971 | :type 'boolean |
| 1972 | :version "20" |
| 1973 | :group 'printing) |
| 1974 | |
| 1975 | |
| 1976 | (defcustom pr-file-duplex nil |
| 1977 | "*Non-nil means print PostScript file in duplex mode." |
| 1978 | :type 'boolean |
| 1979 | :version "20" |
| 1980 | :group 'printing) |
| 1981 | |
| 1982 | |
| 1983 | (defcustom pr-file-tumble nil |
| 1984 | "*Non-nil means print PostScript file in tumble mode. |
| 1985 | |
| 1986 | If tumble is off, produces a printing suitable for binding on the left or |
| 1987 | right. |
| 1988 | If tumble is on, produces a printing suitable for binding at the top or |
| 1989 | bottom." |
| 1990 | :type 'boolean |
| 1991 | :version "20" |
| 1992 | :group 'printing) |
| 1993 | |
| 1994 | |
| 1995 | (defcustom pr-auto-region t |
| 1996 | "*Non-nil means region is automagically detected. |
| 1997 | |
| 1998 | Note that this will only work if you're using transient mark mode. |
| 1999 | |
| 2000 | When this variable is non-nil, the `*-buffer*' commands will behave like |
| 2001 | `*-region*' commands, that is, `*-buffer*' commands will print only the region |
| 2002 | marked instead of all buffer." |
| 2003 | :type 'boolean |
| 2004 | :version "20" |
| 2005 | :group 'printing) |
| 2006 | |
| 2007 | |
| 2008 | (defcustom pr-auto-mode t |
| 2009 | "*Non-nil means major-mode specific printing is prefered over normal printing. |
| 2010 | |
| 2011 | That is, if current major-mode is declared in `pr-mode-alist', the `*-buffer*' |
| 2012 | and `*-region*' commands will behave like `*-mode*' commands; otherwise, |
| 2013 | `*-buffer*' commands will print the current buffer and `*-region*' commands |
| 2014 | will print the current region." |
| 2015 | :type 'boolean |
| 2016 | :version "20" |
| 2017 | :group 'printing) |
| 2018 | |
| 2019 | |
| 2020 | (defcustom pr-mode-alist |
| 2021 | '((mh-folder-mode ; mh summary buffer |
| 2022 | pr-mh-lpr-1 pr-mh-print-1 |
| 2023 | 2 |
| 2024 | (ps-article-author ps-article-subject) |
| 2025 | ("/pagenumberstring load" pr-article-date) |
| 2026 | nil |
| 2027 | ) |
| 2028 | (mh-letter-mode ; mh letter buffer |
| 2029 | pr-mh-lpr-2 pr-mh-print-2 |
| 2030 | 2 |
| 2031 | (ps-article-author ps-article-subject) |
| 2032 | ("/pagenumberstring load" pr-article-date) |
| 2033 | nil |
| 2034 | ) |
| 2035 | (rmail-summary-mode ; rmail summary buffer |
| 2036 | pr-rmail-lpr pr-rmail-print |
| 2037 | 3 |
| 2038 | (ps-article-subject ps-article-author buffer-name) |
| 2039 | nil |
| 2040 | nil |
| 2041 | ) |
| 2042 | (rmail-mode ; rmail buffer |
| 2043 | pr-rmail-lpr pr-rmail-print |
| 2044 | 3 |
| 2045 | (ps-article-subject ps-article-author buffer-name) |
| 2046 | nil |
| 2047 | nil |
| 2048 | ) |
| 2049 | (gnus-summary-mode ; gnus summary buffer |
| 2050 | pr-gnus-lpr pr-gnus-print |
| 2051 | 3 |
| 2052 | (ps-article-subject ps-article-author gnus-newsgroup-name) |
| 2053 | nil |
| 2054 | nil |
| 2055 | ) |
| 2056 | (gnus-article-mode ; gnus article buffer |
| 2057 | pr-gnus-lpr pr-gnus-print |
| 2058 | 3 |
| 2059 | (ps-article-subject ps-article-author gnus-newsgroup-name) |
| 2060 | nil |
| 2061 | nil |
| 2062 | ) |
| 2063 | (Info-mode ; Info buffer |
| 2064 | pr-mode-lpr pr-mode-print |
| 2065 | 2 |
| 2066 | (ps-info-node ps-info-file) |
| 2067 | nil |
| 2068 | nil |
| 2069 | ) |
| 2070 | (vm-mode ; vm mode |
| 2071 | pr-vm-lpr pr-vm-print |
| 2072 | 3 |
| 2073 | (ps-article-subject ps-article-author buffer-name) |
| 2074 | nil |
| 2075 | nil |
| 2076 | ) |
| 2077 | ) |
| 2078 | "*Specify an alist for a major-mode and printing functions. |
| 2079 | |
| 2080 | To customize a major mode printing, just declare the customization in |
| 2081 | `pr-mode-alist' and invoke some of `*-mode*' commands. An example for major |
| 2082 | mode usage is when you're using gnus (or mh, or rmail, etc.) and you're in the |
| 2083 | *Summary* buffer, if you forget to switch to the *Article* buffer before |
| 2084 | printing, you'll get a nicely formatted list of article subjects shows up at |
| 2085 | the printer. With major mode printing you don't need to switch from gnus |
| 2086 | *Summary* buffer first. |
| 2087 | |
| 2088 | The elements have the following form: |
| 2089 | |
| 2090 | (MAJOR-MODE |
| 2091 | LPR-PRINT PS-PRINT |
| 2092 | HEADER-LINES |
| 2093 | LEFT-HEADER |
| 2094 | RIGHT-HEADER |
| 2095 | KILL-LOCAL-VARIABLE |
| 2096 | DEFAULT...) |
| 2097 | |
| 2098 | Where: |
| 2099 | |
| 2100 | MAJOR-MODE It's the major mode symbol. |
| 2101 | |
| 2102 | LPR-PRINT It's a symbol function for text printing. It's invoked with |
| 2103 | one argument: |
| 2104 | (HEADER-LINES LEFT-HEADER RIGHT-HEADER DEFAULT...). |
| 2105 | |
| 2106 | Usually LPR-PRINT function prepares the environment or buffer |
| 2107 | and then call the function `pr-mode-lpr' which it's used to |
| 2108 | process the buffer and send it to text printer. |
| 2109 | |
| 2110 | The `pr-mode-lpr' definition is: |
| 2111 | |
| 2112 | (pr-mode-lpr HEADER-LIST &optional FROM TO) |
| 2113 | |
| 2114 | Where HEADER-LIST is like the argument passed to LPR-PRINT. |
| 2115 | FROM and TO are the beginning and end markers, respectively, |
| 2116 | for a region. If FROM is nil, it's used (point-min); if TO is |
| 2117 | nil, it's used (point-max). |
| 2118 | |
| 2119 | PS-PRINT It's a symbol function for PostScript printing. It's invoked |
| 2120 | with 3 arguments: n-up printing, file name and the list: |
| 2121 | (HEADER-LINES LEFT-HEADER RIGHT-HEADER DEFAULT...). |
| 2122 | |
| 2123 | Usually PS-PRINT function prepares the environment or buffer |
| 2124 | and then call the function `pr-mode-print' which it's used to |
| 2125 | process the buffer and send it to PostScript printer. |
| 2126 | |
| 2127 | The `pr-mode-print' definition is: |
| 2128 | |
| 2129 | (pr-mode-print N-UP FILENAME HEADER-LIST &optional FROM TO) |
| 2130 | |
| 2131 | Where N-UP, FILENAME and HEADER-LIST are like the arguments |
| 2132 | passed to PS-PRINT. FROM and TO are the beginning and end |
| 2133 | markers, respectively, for a region. If TO is nil, it's used |
| 2134 | (point-max). |
| 2135 | |
| 2136 | HEADER-LINES It's the number of header lines; if is nil, it uses |
| 2137 | `ps-header-lines' value. |
| 2138 | |
| 2139 | LEFT-HEADER It's the left header part, it's a list of string, variable |
| 2140 | symbol or function symbol (with no argument); if is nil, it |
| 2141 | uses `ps-left-header' value. |
| 2142 | |
| 2143 | RIGHT-HEADER It's the right header part, it's a list of string, variable |
| 2144 | symbol or function symbol (with no argument); if is nil, it |
| 2145 | uses `ps-right-header' value. |
| 2146 | |
| 2147 | KILL-LOCAL-VARIABLE |
| 2148 | Non-nil means to kill all buffer local variable declared in |
| 2149 | DEFAULT (see below). |
| 2150 | |
| 2151 | DEFAULT It's a way to set default values when this entry is selected. |
| 2152 | It's a cons like: |
| 2153 | |
| 2154 | (VARIABLE-SYM . VALUE) |
| 2155 | |
| 2156 | That associates VARIABLE-SYM with VALUE. when this entry is |
| 2157 | selected, it's executed the following command: |
| 2158 | |
| 2159 | (set (make-local-variable VARIABLE-SYM) (eval VALUE)) |
| 2160 | |
| 2161 | Note that VALUE can be any valid lisp expression. So, don't |
| 2162 | forget to quote symbols and constant lists. |
| 2163 | If VARIABLE is the special keyword `inherits-from:', VALUE must |
| 2164 | be a symbol name setting defined in `pr-setting-database' from |
| 2165 | which the current setting inherits the context. Take care with |
| 2166 | circular inheritance. |
| 2167 | Examples: |
| 2168 | '(ps-landscape-mode . nil) |
| 2169 | '(ps-spool-duplex . t) |
| 2170 | '(pr-gs-device . (my-gs-device t))" |
| 2171 | :type '(repeat |
| 2172 | (list |
| 2173 | :tag "" |
| 2174 | (symbol :tag "Major Mode") |
| 2175 | (function :tag "Text Printing Function") |
| 2176 | (function :tag "PS Printing Function") |
| 2177 | (choice :menu-tag "Number of Header Lines" |
| 2178 | :tag "Number of Header Lines" |
| 2179 | (integer :tag "Number") |
| 2180 | (const :tag "Default Number" nil)) |
| 2181 | (repeat :tag "Left Header List" |
| 2182 | (choice :menu-tag "Left Header" |
| 2183 | :tag "Left Header" |
| 2184 | string symbol)) |
| 2185 | (repeat :tag "Right Header List" |
| 2186 | (choice :menu-tag "Right Header" |
| 2187 | :tag "Right Header" |
| 2188 | string symbol)) |
| 2189 | (boolean :tag "Kill Local Variable At End") |
| 2190 | (repeat |
| 2191 | :tag "Default Value List" |
| 2192 | :inline t |
| 2193 | (cons |
| 2194 | :tag "" |
| 2195 | (choice |
| 2196 | :menu-tag "Variable" |
| 2197 | :tag "Variable" |
| 2198 | (const :tag "Landscape" ps-landscape-mode) |
| 2199 | (const :tag "Print Header" ps-print-header) |
| 2200 | (const :tag "Print Header Frame" ps-print-header-frame) |
| 2201 | (const :tag "Line Number" ps-line-number) |
| 2202 | (const :tag "Zebra Stripes" ps-zebra-stripes) |
| 2203 | (const :tag "Duplex" ps-spool-duplex) |
| 2204 | (const :tag "Tumble" ps-spool-tumble) |
| 2205 | (const :tag "Upside-Down" ps-print-upside-down) |
| 2206 | (const :tag "PS File Landscape" pr-file-landscape) |
| 2207 | (const :tag "PS File Duplex" pr-file-duplex) |
| 2208 | (const :tag "PS File Tumble" pr-file-tumble) |
| 2209 | (const :tag "Auto Region" pr-auto-region) |
| 2210 | (const :tag "Auto Mode" pr-auto-mode) |
| 2211 | (const :tag "Ghostscript Device" pr-gs-device) |
| 2212 | (const :tag "Ghostscript Resolution" pr-gs-resolution) |
| 2213 | (const :tag "inherits-from:" inherits-from:) |
| 2214 | (variable :tag "Other")) |
| 2215 | (sexp :tag "Value"))) |
| 2216 | )) |
| 2217 | :version "20" |
| 2218 | :group 'printing) |
| 2219 | |
| 2220 | |
| 2221 | (defcustom pr-ps-utility 'mpage |
| 2222 | "*Specify PostScript utility symbol. |
| 2223 | |
| 2224 | This utility symbol should be defined on `pr-ps-utility-alist' (see it for |
| 2225 | documentation). |
| 2226 | |
| 2227 | This variable should be modified by customization engine. If this variable is |
| 2228 | modified by other means (for example, a lisp function), use `pr-update-menus' |
| 2229 | function (see it for documentation) to update PostScript utility menu. |
| 2230 | |
| 2231 | NOTE: Don't forget to download and install the utilities declared on |
| 2232 | `pr-ps-utility-alist'." |
| 2233 | :type '(symbol :tag "PS File Utility") |
| 2234 | :set 'pr-ps-utility-custom-set |
| 2235 | :version "20" |
| 2236 | :group 'printing) |
| 2237 | |
| 2238 | |
| 2239 | (defcustom pr-ps-utility-alist |
| 2240 | '((mpage "mpage" nil "-b%s" "-%d" "-l" "-t" "-T" ">" nil) |
| 2241 | (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil |
| 2242 | (inherits-from: . no-duplex)) |
| 2243 | ) |
| 2244 | ;; Examples: |
| 2245 | ;; * On GNU or Unix system: |
| 2246 | ;; '((mpage "mpage" nil "-b%s" "-%d" "-l" "-t" "-T" ">" nil) |
| 2247 | ;; (psnup "psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil |
| 2248 | ;; (pr-file-duplex . nil) (pr-file-tumble . nil)) |
| 2249 | ;; ) |
| 2250 | ;; * On Windows system: |
| 2251 | ;; '((psnup "c:/psutils/psnup" ("-q") "-P%s" "-%d" "-l" nil nil " " nil |
| 2252 | ;; (pr-file-duplex . nil) (pr-file-tumble . nil)) |
| 2253 | ;; ) |
| 2254 | "*Specify an alist for PostScript utility processing (PS utility database). |
| 2255 | |
| 2256 | The alist element has the form: |
| 2257 | |
| 2258 | (SYMBOL UTILITY MUST-SWITCHES PAPERSIZE N-UP LANDSCAPE DUPLEX TUMBLE OUTPUT |
| 2259 | SWITCHES DEFAULT...) |
| 2260 | |
| 2261 | Where: |
| 2262 | |
| 2263 | SYMBOL It's a symbol to identify a PostScript utility. It's for |
| 2264 | `pr-ps-utility' variable setting and for menu selection. |
| 2265 | Examples: |
| 2266 | 'mpage |
| 2267 | 'psnup |
| 2268 | |
| 2269 | UTILITY Name of utility for processing a PostScript file. |
| 2270 | See also `pr-path-alist'. |
| 2271 | Examples: |
| 2272 | . for GNU or Unix system: |
| 2273 | \"mpage\" |
| 2274 | \"psnup -q\" |
| 2275 | |
| 2276 | . for Windows system: |
| 2277 | \"c:/psutils/psnup -q\" |
| 2278 | |
| 2279 | MUST-SWITCHES List of sexp's to pass as options to the PostScript utility |
| 2280 | program. These options are necessary to process the utility |
| 2281 | program and must be placed before any other switches. |
| 2282 | Example: |
| 2283 | . for psnup: |
| 2284 | '(\"-q\") |
| 2285 | |
| 2286 | PAPERSIZE It's a format string to specify paper size switch. |
| 2287 | Example: |
| 2288 | . for mpage |
| 2289 | \"-b%s\" |
| 2290 | |
| 2291 | N-UP It's a format string to specify n-up switch. |
| 2292 | Example: |
| 2293 | . for psnup |
| 2294 | \"-%d\" |
| 2295 | |
| 2296 | LANDSCAPE It's a string to specify landscape switch. If the utility |
| 2297 | doesn't have landscape switch, set to nil. |
| 2298 | Example: |
| 2299 | . for psnup |
| 2300 | \"-l\" |
| 2301 | |
| 2302 | DUPLEX It's a string to specify duplex switch. If the utility doesn't |
| 2303 | have duplex switch, set to nil. |
| 2304 | Example: |
| 2305 | . for psnup |
| 2306 | nil |
| 2307 | |
| 2308 | TUMBLE It's a string to specify tumble switch. If the utility doesn't |
| 2309 | have tumble switch, set to nil. |
| 2310 | Example: |
| 2311 | . for psnup |
| 2312 | nil |
| 2313 | |
| 2314 | OUTPUT It's a string to specify how to generate an output file. Some |
| 2315 | utilities accept an output file option, but some others need |
| 2316 | output redirection or some other way to specify an output file. |
| 2317 | Example: |
| 2318 | . for psnup |
| 2319 | \" \" ; psnup ... input output |
| 2320 | |
| 2321 | . for mpage |
| 2322 | \">\" ; mpage ... input > output |
| 2323 | |
| 2324 | SWITCHES List of sexp's to pass as extra options to the PostScript utility |
| 2325 | program. |
| 2326 | Example: |
| 2327 | . for psnup |
| 2328 | '(\"-q\") |
| 2329 | nil |
| 2330 | |
| 2331 | DEFAULT It's a way to set default values when this entry is selected. |
| 2332 | It's a cons like: |
| 2333 | |
| 2334 | (VARIABLE . VALUE) |
| 2335 | |
| 2336 | That associates VARIABLE with VALUE. when this entry is |
| 2337 | selected, it's executed the following command: |
| 2338 | |
| 2339 | (set VARIABLE (eval VALUE)) |
| 2340 | |
| 2341 | Note that VALUE can be any valid lisp expression. So, don't |
| 2342 | forget to quote symbols and constant lists. |
| 2343 | If VARIABLE is the special keyword `inherits-from:', VALUE must |
| 2344 | be a symbol name setting defined in `pr-setting-database' from |
| 2345 | which the current setting inherits the context. Take care with |
| 2346 | circular inheritance. |
| 2347 | Examples: |
| 2348 | '(pr-file-landscape . nil) |
| 2349 | '(pr-file-duplex . t) |
| 2350 | '(pr-gs-device . (my-gs-device t)) |
| 2351 | |
| 2352 | This variable should be modified by customization engine. If this variable is |
| 2353 | modified by other means (for example, a lisp function), use `pr-update-menus' |
| 2354 | function (see it for documentation) to update PostScript utility menu. |
| 2355 | |
| 2356 | NOTE: Don't forget to download and install the utilities declared on |
| 2357 | `pr-ps-utility-alist'. |
| 2358 | |
| 2359 | Examples: |
| 2360 | |
| 2361 | * On GNU or Unix system: |
| 2362 | |
| 2363 | '((mpage \"mpage\" nil \"-b%s\" \"-%d\" \"-l\" \"-t\" \"-T\" \">\" nil) |
| 2364 | (psnup \"psnup\" (\"-q\") \"-P%s\" \"-%d\" \"-l\" nil nil \" \" nil |
| 2365 | (pr-file-duplex . nil) (pr-file-tumble . nil)) |
| 2366 | ) |
| 2367 | |
| 2368 | * On Windows system: |
| 2369 | |
| 2370 | '((psnup \"c:/psutils/psnup\" (\"-q\") \"-P%s\" \"-%d\" \"-l\" nil nil \" \" |
| 2371 | nil (pr-file-duplex . nil) (pr-file-tumble . nil)) |
| 2372 | ) |
| 2373 | |
| 2374 | Useful links: |
| 2375 | |
| 2376 | * mpage download (GNU or Unix) |
| 2377 | `http://www.mesa.nl/pub/mpage/' |
| 2378 | |
| 2379 | * mpage documentation (GNU or Unix - or type `man mpage') |
| 2380 | `http://www.cs.umd.edu/faq/guides/manual_unix/node48.html' |
| 2381 | `http://www.rt.com/man/mpage.1.html' |
| 2382 | |
| 2383 | * psnup (Windows, GNU or Unix) |
| 2384 | `http://www.knackered.org/angus/psutils/' |
| 2385 | `http://gershwin.ens.fr/vdaniel/Doc-Locale/Outils-Gnu-Linux/PsUtils/' |
| 2386 | |
| 2387 | * psnup (PsUtils for Windows) |
| 2388 | `http://gnuwin32.sourceforge.net/packages/psutils.htm' |
| 2389 | |
| 2390 | * psnup documentation (GNU or Unix - or type `man psnup') |
| 2391 | `http://linux.about.com/library/cmd/blcmdl1_psnup.htm' |
| 2392 | `http://amath.colorado.edu/computing/software/man/psnup.html' |
| 2393 | |
| 2394 | * GNU Enscript (Windows, GNU or Unix) |
| 2395 | `http://people.ssh.com/mtr/genscript/' |
| 2396 | |
| 2397 | * GNU Enscript documentation (Windows, GNU or Unix) |
| 2398 | `http://people.ssh.com/mtr/genscript/enscript.man.html' |
| 2399 | (on GNU or Unix, type `man enscript') |
| 2400 | " |
| 2401 | :type '(repeat |
| 2402 | (list :tag "PS File Utility" |
| 2403 | (symbol :tag "Utility Symbol") |
| 2404 | (string :tag "Utility Name") |
| 2405 | (repeat :tag "Must Utility Switches" |
| 2406 | (sexp :tag "Switch" :value "")) |
| 2407 | (choice :menu-tag "Paper Size" |
| 2408 | :tag "Paper Size" |
| 2409 | (const :tag "No Paper Size" nil) |
| 2410 | (string :tag "Paper Size Format")) |
| 2411 | (choice :menu-tag "N-Up" |
| 2412 | :tag "N-Up" |
| 2413 | (const :tag "No N-Up" nil) |
| 2414 | (string :tag "N-Up Format")) |
| 2415 | (choice :menu-tag "Landscape" |
| 2416 | :tag "Landscape" |
| 2417 | (const :tag "No Landscape" nil) |
| 2418 | (string :tag "Landscape Switch")) |
| 2419 | (choice :menu-tag "Duplex" |
| 2420 | :tag "Duplex" |
| 2421 | (const :tag "No Duplex" nil) |
| 2422 | (string :tag "Duplex Switch")) |
| 2423 | (choice :menu-tag "Tumble" |
| 2424 | :tag "Tumble" |
| 2425 | (const :tag "No Tumble" nil) |
| 2426 | (string :tag "Tumble Switch")) |
| 2427 | (string :tag "Output Separator") |
| 2428 | (repeat :tag "Utility Switches" |
| 2429 | (sexp :tag "Switch" :value "")) |
| 2430 | (repeat |
| 2431 | :tag "Default Value List" |
| 2432 | :inline t |
| 2433 | (cons |
| 2434 | :tag "" |
| 2435 | (choice |
| 2436 | :menu-tag "Variable" |
| 2437 | :tag "Variable" |
| 2438 | (const :tag "PS File Landscape" pr-file-landscape) |
| 2439 | (const :tag "PS File Duplex" pr-file-duplex) |
| 2440 | (const :tag "PS File Tumble" pr-file-tumble) |
| 2441 | (const :tag "Ghostscript Device" pr-gs-device) |
| 2442 | (const :tag "Ghostscript Resolution" pr-gs-resolution) |
| 2443 | (const :tag "inherits-from:" inherits-from:) |
| 2444 | (variable :tag "Other")) |
| 2445 | (sexp :tag "Value"))) |
| 2446 | )) |
| 2447 | :set 'pr-alist-custom-set |
| 2448 | :version "20" |
| 2449 | :group 'printing) |
| 2450 | |
| 2451 | |
| 2452 | (defcustom pr-menu-lock t |
| 2453 | "*Non-nil means menu is locked while selecting toggle options. |
| 2454 | |
| 2455 | See also `pr-menu-char-height' and `pr-menu-char-width'." |
| 2456 | :type 'boolean |
| 2457 | :version "20" |
| 2458 | :group 'printing) |
| 2459 | |
| 2460 | |
| 2461 | (defcustom pr-menu-char-height |
| 2462 | (cond ((featurep 'xemacs) ; XEmacs |
| 2463 | (pr-x-font-height (face-font 'default))) |
| 2464 | (t ; GNU Emacs |
| 2465 | (pr-e-frame-char-height))) |
| 2466 | "*Specify menu char height in pixels. |
| 2467 | |
| 2468 | This variable is used to guess which vertical position should be locked the |
| 2469 | menu, so don't forget to adjust it if menu position is not ok. |
| 2470 | |
| 2471 | See also `pr-menu-lock' and `pr-menu-char-width'." |
| 2472 | :type 'integer |
| 2473 | :version "20" |
| 2474 | :group 'printing) |
| 2475 | |
| 2476 | |
| 2477 | (defcustom pr-menu-char-width |
| 2478 | (cond ((featurep 'xemacs) ; XEmacs |
| 2479 | (pr-x-font-width (face-font 'default))) |
| 2480 | (t ; GNU Emacs |
| 2481 | (pr-e-frame-char-width))) |
| 2482 | "*Specify menu char width in pixels. |
| 2483 | |
| 2484 | This variable is used to guess which horizontal position should be locked the |
| 2485 | menu, so don't forget to adjust it if menu position is not ok. |
| 2486 | |
| 2487 | See also `pr-menu-lock' and `pr-menu-char-height'." |
| 2488 | :type 'integer |
| 2489 | :version "20" |
| 2490 | :group 'printing) |
| 2491 | |
| 2492 | |
| 2493 | (defcustom pr-setting-database |
| 2494 | '((no-duplex ; setting symbol name |
| 2495 | nil nil nil ; inherits local kill-local |
| 2496 | (pr-file-duplex . nil) ; settings |
| 2497 | (pr-file-tumble . nil)) |
| 2498 | ) |
| 2499 | "*Specify an alist for settings in general. |
| 2500 | |
| 2501 | The elements have the following form: |
| 2502 | |
| 2503 | (SYMBOL INHERITS LOCAL KILL-LOCAL SETTING...) |
| 2504 | |
| 2505 | Where: |
| 2506 | |
| 2507 | SYMBOL It's a symbol to identify the setting group. |
| 2508 | |
| 2509 | INHERITS Specify the inheritance for SYMBOL group. It's a symbol name |
| 2510 | setting from which the current setting inherits the context. |
| 2511 | If INHERITS is nil, means that there is no inheritance. |
| 2512 | This is a simple inheritance mechanism. |
| 2513 | |
| 2514 | Let's see an example to illustrate the inheritance mechanism: |
| 2515 | |
| 2516 | (setq pr-setting-database |
| 2517 | '((no-duplex ; setting symbol name |
| 2518 | nil ; inherits |
| 2519 | nil nil ; local kill-local |
| 2520 | (pr-file-duplex . nil) ; settings |
| 2521 | (pr-file-tumble . nil) |
| 2522 | ) |
| 2523 | (no-duplex-and-landscape ; setting symbol name |
| 2524 | no-duplex ; inherits |
| 2525 | nil nil ; local kill-local |
| 2526 | (pr-file-landscape . nil) ; settings |
| 2527 | ))) |
| 2528 | |
| 2529 | The example above has two setting groups: no-duplex and |
| 2530 | no-duplex-and-landscape. When setting no-duplex is activated |
| 2531 | through `inherits-from:' (see `pr-ps-utility', `pr-mode-alist' |
| 2532 | and `pr-ps-printer-alist'), the variables pr-file-duplex and |
| 2533 | pr-file-tumble are both set to nil. |
| 2534 | |
| 2535 | Now when setting no-duplex-and-landscape is activated through |
| 2536 | `inherits-from:', the variable pr-file-landscape is set to nil |
| 2537 | and also the settings for no-duplex are done, because |
| 2538 | no-duplex-and-landscape inherits settings from no-duplex. |
| 2539 | |
| 2540 | Take care with circular inheritance. It's an error if circular |
| 2541 | inheritance happens. |
| 2542 | |
| 2543 | LOCAL Non-nil means that all settings for SYMBOL group will be |
| 2544 | declared local buffer. |
| 2545 | |
| 2546 | KILL-LOCAL Non-nil means that all settings for SYMBOL group will be |
| 2547 | killed at end. It has effect only when LOCAL is non-nil. |
| 2548 | |
| 2549 | SETTING It's a cons like: |
| 2550 | |
| 2551 | (VARIABLE . VALUE) |
| 2552 | |
| 2553 | That associates VARIABLE with VALUE. when this entry is |
| 2554 | selected, it's executed the following command: |
| 2555 | |
| 2556 | * If LOCAL is non-nil: |
| 2557 | (set (make-local-variable VARIABLE) (eval VALUE)) |
| 2558 | |
| 2559 | * If LOCAL is nil: |
| 2560 | (set VARIABLE (eval VALUE)) |
| 2561 | |
| 2562 | Note that VALUE can be any valid lisp expression. So, don't |
| 2563 | forget to quote symbols and constant lists. |
| 2564 | This setting is ignored if VARIABLE is equal to keyword |
| 2565 | `inherits-from:'. |
| 2566 | Examples: |
| 2567 | '(ps-landscape-mode . nil) |
| 2568 | '(ps-spool-duplex . t) |
| 2569 | '(pr-gs-device . (my-gs-device t))" |
| 2570 | :type '(repeat |
| 2571 | (list |
| 2572 | :tag "" |
| 2573 | (symbol :tag "Setting Name") |
| 2574 | (choice :menu-tag "Inheritance" |
| 2575 | :tag "Inheritance" |
| 2576 | (const :tag "No Inheritance" nil) |
| 2577 | (symbol :tag "Inherits From")) |
| 2578 | (boolean :tag "Local Buffer Setting") |
| 2579 | (boolean :tag "Kill Local Variable At End") |
| 2580 | (repeat |
| 2581 | :tag "Setting List" |
| 2582 | :inline t |
| 2583 | (cons |
| 2584 | :tag "" |
| 2585 | (choice |
| 2586 | :menu-tag "Variable" |
| 2587 | :tag "Variable" |
| 2588 | (const :tag "Landscape" ps-landscape-mode) |
| 2589 | (const :tag "Print Header" ps-print-header) |
| 2590 | (const :tag "Print Header Frame" ps-print-header-frame) |
| 2591 | (const :tag "Line Number" ps-line-number) |
| 2592 | (const :tag "Zebra Stripes" ps-zebra-stripes) |
| 2593 | (const :tag "Duplex" ps-spool-duplex) |
| 2594 | (const :tag "Tumble" ps-spool-tumble) |
| 2595 | (const :tag "Upside-Down" ps-print-upside-down) |
| 2596 | (const :tag "PS File Landscape" pr-file-landscape) |
| 2597 | (const :tag "PS File Duplex" pr-file-duplex) |
| 2598 | (const :tag "PS File Tumble" pr-file-tumble) |
| 2599 | (const :tag "Auto Region" pr-auto-region) |
| 2600 | (const :tag "Auto Mode" pr-auto-mode) |
| 2601 | (const :tag "Ghostscript Device" pr-gs-device) |
| 2602 | (const :tag "Ghostscript Resolution" pr-gs-resolution) |
| 2603 | (variable :tag "Other")) |
| 2604 | (sexp :tag "Value"))) |
| 2605 | )) |
| 2606 | :version "20" |
| 2607 | :group 'printing) |
| 2608 | |
| 2609 | |
| 2610 | (defcustom pr-visible-entry-list |
| 2611 | '(postscript text postscript-options postscript-process printing help) |
| 2612 | "*Specify a list of Printing menu visible entries. |
| 2613 | |
| 2614 | Valid values with the corresponding menu parts are: |
| 2615 | |
| 2616 | +------------------------------+ |
| 2617 | | Printing Interface | |
| 2618 | +------------------------------+ |
| 2619 | `postscript' | PostScript Preview >| |
| 2620 | | PostScript Print >| |
| 2621 | | PostScript Printer: name >| |
| 2622 | +------------------------------+ |
| 2623 | `text' | Printify >| |
| 2624 | | Print >| |
| 2625 | | Text Printer: name >| |
| 2626 | +------------------------------+ |
| 2627 | `postscript-options' |[ ] Landscape | |
| 2628 | |[ ] Print Header | |
| 2629 | |[ ] Print Header Frame | |
| 2630 | |[ ] Line Number | |
| 2631 | |[ ] Zebra Stripes | |
| 2632 | |[ ] Duplex | |
| 2633 | |[ ] Tumble | |
| 2634 | |[ ] Upside-Down | |
| 2635 | | Print All Pages >| |
| 2636 | +------------------------------+ |
| 2637 | `postscript-process' |[ ] Spool Buffer | |
| 2638 | |[ ] Print with faces | |
| 2639 | |[ ] Print via Ghostscript | |
| 2640 | +------------------------------+ |
| 2641 | `printing' |[ ] Auto Region | |
| 2642 | |[ ] Auto Mode | |
| 2643 | |[ ] Menu Lock | |
| 2644 | +------------------------------+ |
| 2645 | `help' | Customize >| |
| 2646 | | Show Settings >| |
| 2647 | | Help | |
| 2648 | +------------------------------+ |
| 2649 | |
| 2650 | Any other value is ignored." |
| 2651 | :type '(repeat :tag "Menu Visible Part" |
| 2652 | (choice :menu-tag "Menu Part" |
| 2653 | :tag "Menu Part" |
| 2654 | (const postscript) |
| 2655 | (const text) |
| 2656 | (const postscript-options) |
| 2657 | (const postscript-process) |
| 2658 | (const printing) |
| 2659 | (const help))) |
| 2660 | :version "20" |
| 2661 | :group 'printing) |
| 2662 | |
| 2663 | |
| 2664 | (defcustom pr-delete-temp-file t |
| 2665 | "*Non-nil means delete temporary files. |
| 2666 | |
| 2667 | Set `pr-delete-temp-file' to nil, if the following message (or a similar) |
| 2668 | happens when printing: |
| 2669 | |
| 2670 | Error: could not open \"c:\\temp\\prspool.ps\" for reading." |
| 2671 | :type 'boolean |
| 2672 | :version "20" |
| 2673 | :group 'printing) |
| 2674 | |
| 2675 | |
| 2676 | (defcustom pr-list-directory nil |
| 2677 | "*Non-nil means list directory when processing a directory. |
| 2678 | |
| 2679 | That is, any subdirectories (and the superdirectory) of the directory (given as |
| 2680 | argument of functions below) are also printed (as dired-mode listings). |
| 2681 | |
| 2682 | It's used by `pr-ps-directory-preview', `pr-ps-directory-using-ghostscript', |
| 2683 | `pr-ps-directory-print', `pr-ps-directory-ps-print', `pr-printify-directory' |
| 2684 | and `pr-txt-directory'." |
| 2685 | :type 'boolean |
| 2686 | :version "20" |
| 2687 | :group 'printing) |
| 2688 | |
| 2689 | |
| 2690 | (defcustom pr-buffer-name "*Printing Interface*" |
| 2691 | "*Specify the name of the buffer interface for printing package. |
| 2692 | |
| 2693 | It's used by `pr-interface'." |
| 2694 | :type 'string |
| 2695 | :version "20" |
| 2696 | :group 'printing) |
| 2697 | |
| 2698 | |
| 2699 | (defcustom pr-buffer-name-ignore |
| 2700 | (list (regexp-quote pr-buffer-name) ; ignore printing interface buffer |
| 2701 | "^ .*$") ; ignore invisible buffers |
| 2702 | "*Specify a regexp list for buffer names to be ignored in interface buffer. |
| 2703 | |
| 2704 | NOTE: Case is important for matching, that is, `case-fold-search' is always |
| 2705 | nil. |
| 2706 | |
| 2707 | It's used by `pr-interface'." |
| 2708 | :type '(repeat (regexp :tag "Buffer Name Regexp")) |
| 2709 | :version "20" |
| 2710 | :group 'printing) |
| 2711 | |
| 2712 | |
| 2713 | (defcustom pr-buffer-verbose t |
| 2714 | "*Non-nil means to be verbose when editing a field in interface buffer. |
| 2715 | |
| 2716 | It's used by `pr-interface'." |
| 2717 | :type 'boolean |
| 2718 | :version "20" |
| 2719 | :group 'printing) |
| 2720 | |
| 2721 | |
| 2722 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 2723 | ;; Internal Variables |
| 2724 | |
| 2725 | |
| 2726 | (defvar pr-txt-command nil |
| 2727 | "Name of program for printing a text file. |
| 2728 | See `pr-txt-printer-alist'.") |
| 2729 | |
| 2730 | |
| 2731 | (defvar pr-txt-switches nil |
| 2732 | "List of sexp's to pass as extra options to the text printer program. |
| 2733 | See `pr-txt-printer-alist'.") |
| 2734 | |
| 2735 | |
| 2736 | (defvar pr-txt-printer nil |
| 2737 | "Specify text printer name. |
| 2738 | See `pr-txt-printer-alist'.") |
| 2739 | |
| 2740 | |
| 2741 | (defvar pr-ps-command nil |
| 2742 | "Name of program for printing a PostScript file. |
| 2743 | See `pr-ps-printer-alist'.") |
| 2744 | |
| 2745 | |
| 2746 | (defvar pr-ps-switches nil |
| 2747 | "List of sexp's to pass as extra options to the PostScript printer program. |
| 2748 | See `pr-ps-printer-alist'.") |
| 2749 | |
| 2750 | |
| 2751 | (defvar pr-ps-printer-switch nil |
| 2752 | "Specify PostScript printer name switch. |
| 2753 | See `pr-ps-printer-alist'.") |
| 2754 | |
| 2755 | |
| 2756 | (defvar pr-ps-printer nil |
| 2757 | "Specify PostScript printer name. |
| 2758 | See `pr-ps-printer-alist'.") |
| 2759 | |
| 2760 | |
| 2761 | (defvar pr-menu-bar nil |
| 2762 | "Specify Printing menu-bar entry.") |
| 2763 | |
| 2764 | |
| 2765 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 2766 | ;; Macros |
| 2767 | |
| 2768 | |
| 2769 | (defmacro pr-save-file-modes (&rest body) |
| 2770 | "Set temporally file modes to `pr-file-modes'." |
| 2771 | `(let ((pr--default-file-modes (default-file-modes))) ; save default |
| 2772 | (set-default-file-modes pr-file-modes) |
| 2773 | ,@body |
| 2774 | (set-default-file-modes pr--default-file-modes))) ; restore default |
| 2775 | |
| 2776 | |
| 2777 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 2778 | ;; Keys & Menus |
| 2779 | |
| 2780 | |
| 2781 | (defmacro pr-xemacs-global-menubar (&rest body) |
| 2782 | `(save-excursion |
| 2783 | (let ((temp (get-buffer-create (make-temp-name " *Temp")))) |
| 2784 | ;; be sure to access global menubar |
| 2785 | (set-buffer temp) |
| 2786 | ,@body |
| 2787 | (kill-buffer temp)))) |
| 2788 | |
| 2789 | |
| 2790 | (defsubst pr-visible-p (key) |
| 2791 | (memq key pr-visible-entry-list)) |
| 2792 | |
| 2793 | |
| 2794 | (defsubst pr-mode-alist-p () |
| 2795 | (cdr (assq major-mode pr-mode-alist))) |
| 2796 | |
| 2797 | |
| 2798 | (defsubst pr-auto-mode-p () |
| 2799 | (and pr-auto-mode (pr-mode-alist-p))) |
| 2800 | |
| 2801 | |
| 2802 | (defsubst pr-using-ghostscript-p () |
| 2803 | (and pr-print-using-ghostscript (not pr-spool-p))) |
| 2804 | |
| 2805 | |
| 2806 | (defun pr-get-symbol (name) |
| 2807 | (easy-menu-intern name)) |
| 2808 | |
| 2809 | (cond |
| 2810 | ((featurep 'xemacs) ; XEmacs |
| 2811 | (defvar zmacs-region-stays nil) ; to avoid compilation gripes |
| 2812 | (defun pr-region-active-p () |
| 2813 | (and pr-auto-region (not zmacs-region-stays) (ps-mark-active-p)))) |
| 2814 | |
| 2815 | (t ; GNU Emacs |
| 2816 | (defun pr-region-active-p () |
| 2817 | (and pr-auto-region transient-mark-mode mark-active)))) |
| 2818 | |
| 2819 | |
| 2820 | (defconst pr-menu-spec |
| 2821 | ;; Menu mapping: |
| 2822 | ;; unfortunately XEmacs doesn't support :active for submenus, |
| 2823 | ;; only for items. |
| 2824 | ;; So, it uses :included instead of :active. |
| 2825 | ;; Also, XEmacs doesn't support :help tag. |
| 2826 | (let ((pr-:active (if (featurep 'xemacs) |
| 2827 | :included ; XEmacs |
| 2828 | :active)) ; GNU Emacs |
| 2829 | (pr-:help (if (featurep 'xemacs) |
| 2830 | 'ignore ; XEmacs |
| 2831 | #'(lambda (text) (list :help text))))) ; GNU Emacs |
| 2832 | `( |
| 2833 | ["Printing Interface" pr-interface |
| 2834 | ,@(funcall |
| 2835 | pr-:help "Use buffer interface instead of menu interface")] |
| 2836 | "--" |
| 2837 | ("PostScript Preview" :included (pr-visible-p 'postscript) |
| 2838 | ,@(funcall |
| 2839 | pr-:help "Preview PostScript instead of sending to printer") |
| 2840 | ("Directory" ,pr-:active (not pr-spool-p) |
| 2841 | ["1-up" (pr-ps-directory-preview 1 nil nil t) t] |
| 2842 | ["2-up" (pr-ps-directory-preview 2 nil nil t) t] |
| 2843 | ["4-up" (pr-ps-directory-preview 4 nil nil t) t] |
| 2844 | ["Other..." (pr-ps-directory-preview nil nil nil t) |
| 2845 | :keys "\\[pr-ps-buffer-preview]"]) |
| 2846 | ("Buffer" ,pr-:active (not pr-spool-p) |
| 2847 | ["1-up" (pr-ps-buffer-preview 1 t) t] |
| 2848 | ["2-up" (pr-ps-buffer-preview 2 t) t] |
| 2849 | ["4-up" (pr-ps-buffer-preview 4 t) t] |
| 2850 | ["Other..." (pr-ps-buffer-preview nil t) |
| 2851 | :keys "\\[pr-ps-buffer-preview]"]) |
| 2852 | ("Region" ,pr-:active (and (not pr-spool-p) (ps-mark-active-p)) |
| 2853 | ["1-up" (pr-ps-region-preview 1 t) t] |
| 2854 | ["2-up" (pr-ps-region-preview 2 t) t] |
| 2855 | ["4-up" (pr-ps-region-preview 4 t) t] |
| 2856 | ["Other..." (pr-ps-region-preview nil t) |
| 2857 | :keys "\\[pr-ps-region-preview]"]) |
| 2858 | ("Mode" ,pr-:active (and (not pr-spool-p) (pr-mode-alist-p)) |
| 2859 | ["1-up" (pr-ps-mode-preview 1 t) t] |
| 2860 | ["2-up" (pr-ps-mode-preview 2 t) t] |
| 2861 | ["4-up" (pr-ps-mode-preview 4 t) t] |
| 2862 | ["Other..." (pr-ps-mode-preview nil t) |
| 2863 | :keys "\\[pr-ps-mode-preview]"]) |
| 2864 | ("File" |
| 2865 | ["No Preprocessing..." (call-interactively 'pr-ps-file-preview) |
| 2866 | :keys "\\[pr-ps-file-preview]" |
| 2867 | ,@(funcall |
| 2868 | pr-:help "Preview PostScript file")] |
| 2869 | "--" |
| 2870 | ["PostScript Utility" pr-update-menus :active pr-ps-utility-alist |
| 2871 | ,@(funcall |
| 2872 | pr-:help "Select PostScript utility")] |
| 2873 | "--" |
| 2874 | ["1-up..." (pr-ps-file-up-preview 1 t t) pr-ps-utility-alist] |
| 2875 | ["2-up..." (pr-ps-file-up-preview 2 t t) pr-ps-utility-alist] |
| 2876 | ["4-up..." (pr-ps-file-up-preview 4 t t) pr-ps-utility-alist] |
| 2877 | ["Other..." (pr-ps-file-up-preview nil t t) |
| 2878 | :keys "\\[pr-ps-file-up-preview]" :active pr-ps-utility-alist] |
| 2879 | "--" |
| 2880 | ["Landscape" pr-toggle-file-landscape-menu |
| 2881 | :style toggle :selected pr-file-landscape |
| 2882 | ,@(funcall |
| 2883 | pr-:help "Toggle landscape for PostScript file") |
| 2884 | :active pr-ps-utility-alist] |
| 2885 | ["Duplex" pr-toggle-file-duplex-menu |
| 2886 | :style toggle :selected pr-file-duplex |
| 2887 | ,@(funcall |
| 2888 | pr-:help "Toggle duplex for PostScript file") |
| 2889 | :active pr-ps-utility-alist] |
| 2890 | ["Tumble" pr-toggle-file-tumble-menu |
| 2891 | :style toggle :selected pr-file-tumble |
| 2892 | ,@(funcall |
| 2893 | pr-:help "Toggle tumble for PostScript file") |
| 2894 | :active (and pr-file-duplex pr-ps-utility-alist)]) |
| 2895 | ["Despool..." (call-interactively 'pr-despool-preview) |
| 2896 | :active pr-spool-p :keys "\\[pr-despool-preview]" |
| 2897 | ,@(funcall |
| 2898 | pr-:help "Despool PostScript buffer to printer or file (C-u)")]) |
| 2899 | ("PostScript Print" :included (pr-visible-p 'postscript) |
| 2900 | ,@(funcall |
| 2901 | pr-:help "Send PostScript to printer or file (C-u)") |
| 2902 | ("Directory" |
| 2903 | ["1-up" (pr-ps-directory-ps-print 1 nil nil t) t] |
| 2904 | ["2-up" (pr-ps-directory-ps-print 2 nil nil t) t] |
| 2905 | ["4-up" (pr-ps-directory-ps-print 4 nil nil t) t] |
| 2906 | ["Other..." (pr-ps-directory-ps-print nil nil nil t) |
| 2907 | :keys "\\[pr-ps-buffer-ps-print]"]) |
| 2908 | ("Buffer" |
| 2909 | ["1-up" (pr-ps-buffer-ps-print 1 t) t] |
| 2910 | ["2-up" (pr-ps-buffer-ps-print 2 t) t] |
| 2911 | ["4-up" (pr-ps-buffer-ps-print 4 t) t] |
| 2912 | ["Other..." (pr-ps-buffer-ps-print nil t) |
| 2913 | :keys "\\[pr-ps-buffer-ps-print]"]) |
| 2914 | ("Region" ,pr-:active (ps-mark-active-p) |
| 2915 | ["1-up" (pr-ps-region-ps-print 1 t) t] |
| 2916 | ["2-up" (pr-ps-region-ps-print 2 t) t] |
| 2917 | ["4-up" (pr-ps-region-ps-print 4 t) t] |
| 2918 | ["Other..." (pr-ps-region-ps-print nil t) |
| 2919 | :keys "\\[pr-ps-region-ps-print]"]) |
| 2920 | ("Mode" ,pr-:active (pr-mode-alist-p) |
| 2921 | ["1-up" (pr-ps-mode-ps-print 1 t) t] |
| 2922 | ["2-up" (pr-ps-mode-ps-print 2 t) t] |
| 2923 | ["4-up" (pr-ps-mode-ps-print 4 t) t] |
| 2924 | ["Other..." (pr-ps-mode-ps-print nil t) |
| 2925 | :keys "\\[pr-ps-mode-ps-print]"]) |
| 2926 | ("File" |
| 2927 | ["No Preprocessing..." (call-interactively 'pr-ps-file-ps-print) |
| 2928 | :keys "\\[pr-ps-file-ps-print]" |
| 2929 | ,@(funcall |
| 2930 | pr-:help "Send PostScript file to printer")] |
| 2931 | "--" |
| 2932 | ["PostScript Utility" pr-update-menus :active pr-ps-utility-alist |
| 2933 | ,@(funcall |
| 2934 | pr-:help "Select PostScript utility")] |
| 2935 | "--" |
| 2936 | ["1-up..." (pr-ps-file-up-ps-print 1 t t) pr-ps-utility-alist] |
| 2937 | ["2-up..." (pr-ps-file-up-ps-print 2 t t) pr-ps-utility-alist] |
| 2938 | ["4-up..." (pr-ps-file-up-ps-print 4 t t) pr-ps-utility-alist] |
| 2939 | ["Other..." (pr-ps-file-up-ps-print nil t t) |
| 2940 | :keys "\\[pr-ps-file-up-ps-print]" :active pr-ps-utility-alist] |
| 2941 | "--" |
| 2942 | ["Landscape" pr-toggle-file-landscape-menu |
| 2943 | :style toggle :selected pr-file-landscape |
| 2944 | ,@(funcall |
| 2945 | pr-:help "Toggle landscape for PostScript file") |
| 2946 | :active pr-ps-utility-alist] |
| 2947 | ["Duplex" pr-toggle-file-duplex-menu |
| 2948 | :style toggle :selected pr-file-duplex |
| 2949 | ,@(funcall |
| 2950 | pr-:help "Toggle duplex for PostScript file") |
| 2951 | :active pr-ps-utility-alist] |
| 2952 | ["Tumble" pr-toggle-file-tumble-menu |
| 2953 | :style toggle :selected pr-file-tumble |
| 2954 | ,@(funcall |
| 2955 | pr-:help "Toggle tumble for PostScript file") |
| 2956 | :active (and pr-file-duplex pr-ps-utility-alist)]) |
| 2957 | ["Despool..." (call-interactively 'pr-despool-ps-print) |
| 2958 | :active pr-spool-p :keys "\\[pr-despool-ps-print]" |
| 2959 | ,@(funcall |
| 2960 | pr-:help "Despool PostScript buffer to printer or file (C-u)")]) |
| 2961 | ["PostScript Printers" pr-update-menus |
| 2962 | :active pr-ps-printer-alist :included (pr-visible-p 'postscript) |
| 2963 | ,@(funcall |
| 2964 | pr-:help "Select PostScript printer")] |
| 2965 | "--" |
| 2966 | ("Printify" :included (pr-visible-p 'text) |
| 2967 | ,@(funcall |
| 2968 | pr-:help |
| 2969 | "Replace non-printing chars with printable representations.") |
| 2970 | ["Directory" pr-printify-directory t] |
| 2971 | ["Buffer" pr-printify-buffer t] |
| 2972 | ["Region" pr-printify-region (ps-mark-active-p)]) |
| 2973 | ("Print" :included (pr-visible-p 'text) |
| 2974 | ,@(funcall |
| 2975 | pr-:help "Send text to printer") |
| 2976 | ["Directory" pr-txt-directory t] |
| 2977 | ["Buffer" pr-txt-buffer t] |
| 2978 | ["Region" pr-txt-region (ps-mark-active-p)] |
| 2979 | ["Mode" pr-txt-mode (pr-mode-alist-p)]) |
| 2980 | ["Text Printers" pr-update-menus |
| 2981 | :active pr-txt-printer-alist :included (pr-visible-p 'text) |
| 2982 | ,@(funcall |
| 2983 | pr-:help "Select text printer")] |
| 2984 | "--" |
| 2985 | ["Landscape" pr-toggle-landscape-menu |
| 2986 | :style toggle :selected ps-landscape-mode |
| 2987 | :included (pr-visible-p 'postscript-options)] |
| 2988 | ["Print Header" pr-toggle-header-menu |
| 2989 | :style toggle :selected ps-print-header |
| 2990 | :included (pr-visible-p 'postscript-options)] |
| 2991 | ["Print Header Frame" pr-toggle-header-frame-menu |
| 2992 | :style toggle :selected ps-print-header-frame :active ps-print-header |
| 2993 | :included (pr-visible-p 'postscript-options)] |
| 2994 | ["Line Number" pr-toggle-line-menu |
| 2995 | :style toggle :selected ps-line-number |
| 2996 | :included (pr-visible-p 'postscript-options)] |
| 2997 | ["Zebra Stripes" pr-toggle-zebra-menu |
| 2998 | :style toggle :selected ps-zebra-stripes |
| 2999 | :included (pr-visible-p 'postscript-options)] |
| 3000 | ["Duplex" pr-toggle-duplex-menu |
| 3001 | :style toggle :selected ps-spool-duplex |
| 3002 | :included (pr-visible-p 'postscript-options)] |
| 3003 | ["Tumble" pr-toggle-tumble-menu |
| 3004 | :style toggle :selected ps-spool-tumble :active ps-spool-duplex |
| 3005 | :included (pr-visible-p 'postscript-options)] |
| 3006 | ["Upside-Down" pr-toggle-upside-down-menu |
| 3007 | :style toggle :selected ps-print-upside-down |
| 3008 | :included (pr-visible-p 'postscript-options)] |
| 3009 | ("Print All Pages" :included (pr-visible-p 'postscript-options) |
| 3010 | ,@(funcall |
| 3011 | pr-:help "Select odd/even pages/sheets to print") |
| 3012 | ["All Pages" (pr-even-or-odd-pages nil) |
| 3013 | :style radio :selected (eq ps-even-or-odd-pages nil)] |
| 3014 | ["Even Pages" (pr-even-or-odd-pages 'even-page) |
| 3015 | :style radio :selected (eq ps-even-or-odd-pages 'even-page)] |
| 3016 | ["Odd Pages" (pr-even-or-odd-pages 'odd-page) |
| 3017 | :style radio :selected (eq ps-even-or-odd-pages 'odd-page)] |
| 3018 | ["Even Sheets" (pr-even-or-odd-pages 'even-sheet) |
| 3019 | :style radio :selected (eq ps-even-or-odd-pages 'even-sheet)] |
| 3020 | ["Odd Sheets" (pr-even-or-odd-pages 'odd-sheet) |
| 3021 | :style radio :selected (eq ps-even-or-odd-pages 'odd-sheet)]) |
| 3022 | "--" |
| 3023 | ["Spool Buffer" pr-toggle-spool-menu |
| 3024 | :style toggle :selected pr-spool-p |
| 3025 | :included (pr-visible-p 'postscript-process) |
| 3026 | ,@(funcall |
| 3027 | pr-:help "Toggle PostScript spooling")] |
| 3028 | ["Print with faces" pr-toggle-faces-menu |
| 3029 | :style toggle :selected pr-faces-p |
| 3030 | :included (pr-visible-p 'postscript-process) |
| 3031 | ,@(funcall |
| 3032 | pr-:help "Toggle PostScript printing with faces")] |
| 3033 | ["Print via Ghostscript" pr-toggle-ghostscript-menu |
| 3034 | :style toggle :selected pr-print-using-ghostscript |
| 3035 | :included (pr-visible-p 'postscript-process) |
| 3036 | ,@(funcall |
| 3037 | pr-:help "Toggle PostScript generation using ghostscript")] |
| 3038 | "--" |
| 3039 | ["Auto Region" pr-toggle-region-menu |
| 3040 | :style toggle :selected pr-auto-region |
| 3041 | :included (pr-visible-p 'printing)] |
| 3042 | ["Auto Mode" pr-toggle-mode-menu |
| 3043 | :style toggle :selected pr-auto-mode |
| 3044 | :included (pr-visible-p 'printing)] |
| 3045 | ["Menu Lock" pr-toggle-lock-menu |
| 3046 | :style toggle :selected pr-menu-lock |
| 3047 | :included (pr-visible-p 'printing)] |
| 3048 | "--" |
| 3049 | ("Customize" :included (pr-visible-p 'help) |
| 3050 | ["printing" pr-customize t] |
| 3051 | ["ps-print" ps-print-customize t] |
| 3052 | ["lpr" lpr-customize t]) |
| 3053 | ("Show Settings" :included (pr-visible-p 'help) |
| 3054 | ["printing" pr-show-pr-setup t] |
| 3055 | ["ps-print" pr-show-ps-setup t] |
| 3056 | ["lpr" pr-show-lpr-setup t]) |
| 3057 | ["Help" pr-help :active t :included (pr-visible-p 'help)] |
| 3058 | ))) |
| 3059 | |
| 3060 | |
| 3061 | (defvar pr-menu-print-item "print" |
| 3062 | "Non-nil means that menu binding was not done. |
| 3063 | |
| 3064 | Used by `pr-menu-bind' and `pr-update-menus'.") |
| 3065 | |
| 3066 | |
| 3067 | (defun pr-menu-bind () |
| 3068 | "Install `printing' menu in the menubar. |
| 3069 | |
| 3070 | On Emacs 20, it replaces the Tools/Print menu by Tools/Printing menu. |
| 3071 | |
| 3072 | On Emacs 21 and 22, it replaces the File/Print* menu entries by File/Print |
| 3073 | menu. |
| 3074 | |
| 3075 | Calls `pr-update-menus' to adjust menus." |
| 3076 | (interactive) |
| 3077 | (cond |
| 3078 | ((featurep 'xemacs) ; XEmacs |
| 3079 | ;; Menu binding |
| 3080 | (pr-xemacs-global-menubar |
| 3081 | (pr-x-add-submenu nil (cons "Printing" pr-menu-spec) "Apps")) |
| 3082 | (setq pr-menu-print-item nil)) |
| 3083 | |
| 3084 | |
| 3085 | (t ; GNU Emacs |
| 3086 | ;; Menu binding |
| 3087 | (require 'easymenu) |
| 3088 | ;; Replace existing "print" item by "Printing" item. |
| 3089 | ;; If you're changing this file, you'll load it a second, |
| 3090 | ;; third... time, but "print" item exists only in the first load. |
| 3091 | (cond |
| 3092 | ;; Emacs 20 |
| 3093 | ((string< emacs-version "21.") |
| 3094 | (easy-menu-change '("tools") "Printing" pr-menu-spec pr-menu-print-item) |
| 3095 | (when pr-menu-print-item |
| 3096 | (easy-menu-remove-item nil '("tools") pr-menu-print-item) |
| 3097 | (setq pr-menu-print-item nil |
| 3098 | pr-menu-bar (vector 'menu-bar 'tools |
| 3099 | (pr-get-symbol "Printing"))))) |
| 3100 | ;; Emacs 21 & 22 |
| 3101 | (t |
| 3102 | (let* ((has-file (lookup-key global-map (vector 'menu-bar 'file))) |
| 3103 | (item-file (if has-file '("file") '("files")))) |
| 3104 | (cond |
| 3105 | (pr-menu-print-item |
| 3106 | (easy-menu-change item-file "Print" pr-menu-spec "print-buffer") |
| 3107 | (let ((items '("print-buffer" "print-region" |
| 3108 | "ps-print-buffer-faces" "ps-print-region-faces" |
| 3109 | "ps-print-buffer" "ps-print-region"))) |
| 3110 | (while items |
| 3111 | (easy-menu-remove-item nil item-file (car items)) |
| 3112 | (setq items (cdr items))) |
| 3113 | (setq pr-menu-print-item nil |
| 3114 | pr-menu-bar (vector 'menu-bar |
| 3115 | (if has-file 'file 'files) |
| 3116 | (pr-get-symbol "Print"))))) |
| 3117 | (t |
| 3118 | (easy-menu-change item-file "Print" pr-menu-spec)))))))) |
| 3119 | (pr-update-menus t)) |
| 3120 | |
| 3121 | |
| 3122 | ;; Key binding |
| 3123 | (let ((pr-print-key (if (featurep 'xemacs) |
| 3124 | 'f22 ; XEmacs |
| 3125 | 'print))) ; GNU Emacs |
| 3126 | (global-set-key `[,pr-print-key] 'pr-ps-fast-fire) |
| 3127 | ;; Well, M-print and S-print are used because in my keyboard S-print works |
| 3128 | ;; and M-print doesn't. But M-print can work in other keyboard. |
| 3129 | (global-set-key `[(meta ,pr-print-key)] 'pr-ps-mode-using-ghostscript) |
| 3130 | (global-set-key `[(shift ,pr-print-key)] 'pr-ps-mode-using-ghostscript) |
| 3131 | ;; Well, C-print and C-M-print are used because in my keyboard C-M-print works |
| 3132 | ;; and C-print doesn't. But C-print can work in other keyboard. |
| 3133 | (global-set-key `[(control ,pr-print-key)] 'pr-txt-fast-fire) |
| 3134 | (global-set-key `[(control meta ,pr-print-key)] 'pr-txt-fast-fire)) |
| 3135 | |
| 3136 | |
| 3137 | ;;; You can also use something like: |
| 3138 | ;;;(global-set-key "\C-ci" 'pr-interface) |
| 3139 | ;;;(global-set-key "\C-cbp" 'pr-ps-buffer-print) |
| 3140 | ;;;(global-set-key "\C-cbx" 'pr-ps-buffer-preview) |
| 3141 | ;;;(global-set-key "\C-cbb" 'pr-ps-buffer-using-ghostscript) |
| 3142 | ;;;(global-set-key "\C-crp" 'pr-ps-region-print) |
| 3143 | ;;;(global-set-key "\C-crx" 'pr-ps-region-preview) |
| 3144 | ;;;(global-set-key "\C-crr" 'pr-ps-region-using-ghostscript) |
| 3145 | |
| 3146 | |
| 3147 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 3148 | ;; Help Message |
| 3149 | |
| 3150 | |
| 3151 | (defconst pr-help-message |
| 3152 | (concat "printing.el version " pr-version |
| 3153 | " ps-print.el version " ps-print-version |
| 3154 | "\n\n |
| 3155 | Menu Layout |
| 3156 | ----------- |
| 3157 | |
| 3158 | The `printing' menu (Tools/Printing or File/Print) has the following layout: |
| 3159 | |
| 3160 | +-----------------------------+ |
| 3161 | A 0 | Printing Interface | |
| 3162 | +-----------------------------+ +-A---------+ +-B------+ |
| 3163 | I 1 | PostScript Preview >|-------|Directory >|-----|1-up | |
| 3164 | 2 | PostScript Print >|---- A |Buffer >|-- B |2-up | |
| 3165 | 3 | PostScript Printer: name >|---- C |Region >|-- B |4-up | |
| 3166 | +-----------------------------+ |Mode >|-- B |Other...| |
| 3167 | II 4 | Printify >|-----\\ |File >|--\\ +--------+ |
| 3168 | 5 | Print >|---\\ | |Despool... | | |
| 3169 | 6 | Text Printer: name >|-\\ | | +-----------+ | |
| 3170 | +-----------------------------+ | | | +---------+ +------------+ |
| 3171 | III 7 |[ ]Landscape | | | \\-|Directory| | No Prep... | Ia |
| 3172 | 8 |[ ]Print Header | | | |Buffer | +------------+ Ib |
| 3173 | 9 |[ ]Print Header Frame | | | |Region | | name >|- C |
| 3174 | 10 |[ ]Line Number | | | +---------+ +------------+ |
| 3175 | 11 |[ ]Zebra Stripes | | | +---------+ | 1-up... | Ic |
| 3176 | 12 |[ ]Duplex | | \\---|Directory| | 2-up... | |
| 3177 | 13 |[ ]Tumble | \\--\\ |Buffer | | 4-up... | |
| 3178 | 14 |[ ]Upside-Down | | |Region | | Other... | |
| 3179 | 15 | Print All Pages >|--\\ | |Mode | +------------+ |
| 3180 | +-----------------------------+ | | +---------+ |[ ]Landscape| Id |
| 3181 | IV 16 |[ ]Spool Buffer | | | +-C-------+ |[ ]Duplex | Ie |
| 3182 | 17 |[ ]Print with faces | | \\--|( )name A| |[ ]Tumble | If |
| 3183 | 18 |[ ]Print via Ghostscript | | |( )name B| +------------+ |
| 3184 | +-----------------------------+ | |... | |
| 3185 | V 19 |[ ]Auto Region | | |(*)name | |
| 3186 | 20 |[ ]Auto Mode | | |... | |
| 3187 | 21 |[ ]Menu Lock | | +---------+ +--------------+ |
| 3188 | +-----------------------------+ \\------------------|(*)All Pages | |
| 3189 | VI 22 | Customize >|--- D +-D------+ |( )Even Pages | |
| 3190 | 23 | Show Settings >|-------|printing| |( )Odd Pages | |
| 3191 | 24 | Help | |ps-print| |( )Even Sheets| |
| 3192 | +-----------------------------+ |lpr | |( )Odd Sheets | |
| 3193 | +--------+ +--------------+ |
| 3194 | |
| 3195 | See `pr-visible-entry-list' for hiding some parts of the menu. |
| 3196 | |
| 3197 | The menu has the following sections: |
| 3198 | |
| 3199 | A. Interface: |
| 3200 | |
| 3201 | 0. You can use a buffer interface instead of menus. It looks like the |
| 3202 | customization buffer. Basically, it has the same options found in the |
| 3203 | menu and some extra options, all this on a buffer. |
| 3204 | |
| 3205 | I. PostScript printing: |
| 3206 | |
| 3207 | 1. You can generate a PostScript file (if you type C-u before activating |
| 3208 | menu) or PostScript temporary file for a directory, a buffer, a region |
| 3209 | or a major mode, choosing 1-up, 2-up, 4-up or any other n-up printing; |
| 3210 | after file generation, ghostview is activated using the file generated |
| 3211 | as argument. This option is disabled if spooling is on (option 16). |
| 3212 | Also, if you already have a PostScript file you can preview it. |
| 3213 | Instead of previewing each buffer, region or major mode at once, you |
| 3214 | can save temporarily the PostScript code generated in a buffer and |
| 3215 | preview it later. The option `Despool...' despools the PostScript |
| 3216 | spooling buffer in a temporary file and uses ghostview to preview it. |
| 3217 | If you type C-u before choosing this option, the PostScript code |
| 3218 | generated is saved in a file instead of saving in a temporary file. To |
| 3219 | spool the PostScript code generated you need to turn on the option 16. |
| 3220 | The option `Despool...' is enabled if spooling is on (option 16). |
| 3221 | |
| 3222 | NOTE 1: It's possible to customize a major mode printing, just declare |
| 3223 | the customization in `pr-mode-alist' and invoke some of |
| 3224 | `*-mode*' commands or select Mode option in Printing menu. An |
| 3225 | example for major mode usage is when you're using gnus (or mh, |
| 3226 | or rmail, etc.) and you're in the *Summary* buffer, if you |
| 3227 | forget to switch to the *Article* buffer before printing, |
| 3228 | you'll get a nicely formatted list of article subjects shows |
| 3229 | up at the printer. With major mode printing you don't need to |
| 3230 | switch from gnus *Summary* buffer first. |
| 3231 | |
| 3232 | NOTE 2: There are the following options for PostScript file processing: |
| 3233 | Ia. Print the file *No Preprocessing*, that is, send it |
| 3234 | directly to PostScript printer. |
| 3235 | Ib. PostScript utility processing selection. |
| 3236 | See `pr-ps-utility-alist' and `pr-setting-database' for |
| 3237 | documentation. |
| 3238 | Ic. Do n-up processing before printing. |
| 3239 | Id. Toggle on/off landscape for PostScript file processing. |
| 3240 | Ie. Toggle on/off duplex for PostScript file processing. |
| 3241 | If. Toggle on/off tumble for PostScript file processing. |
| 3242 | |
| 3243 | NOTE 3: Don't forget to download and install the utilities declared on |
| 3244 | `pr-ps-utility-alist'. |
| 3245 | |
| 3246 | 2. Operate the same way as option 1, but it sends directly the PostScript |
| 3247 | code (or put in a file, if you've typed C-u) or it uses ghostscript to |
| 3248 | print the PostScript file generated. It depends on option 18, if it's |
| 3249 | turned on, it uses ghostscript; otherwise, it sends directly to |
| 3250 | printer. If spooling is on (option 16), the PostScript code is saved |
| 3251 | temporarily in a buffer instead of printing it or saving it in a file. |
| 3252 | Also, if you already have a PostScript file you can print it. |
| 3253 | Instead of printing each buffer, region or major mode at once, you can |
| 3254 | save temporarily the PostScript code generated in a buffer and print it |
| 3255 | later. The option `Despool...' despools the PostScript spooling buffer |
| 3256 | directly on a printer. If you type C-u before choosing this option, |
| 3257 | the PostScript code generated is saved in a file instead of sending it to |
| 3258 | the printer. To spool the PostScript code generated you need to turn on |
| 3259 | option 16. This option is enabled if spooling is on (option 16). |
| 3260 | See also the NOTE 1, NOTE 2 and NOTE 3 on option 1. |
| 3261 | |
| 3262 | 3. You can select a new PostScript printer to send PostScript code |
| 3263 | generated. For selection it's used all PostScript printers defined |
| 3264 | in `pr-ps-printer-alist' variable (see it for documentation). |
| 3265 | See also `pr-setting-database'. |
| 3266 | |
| 3267 | II. Text printing: |
| 3268 | |
| 3269 | 4. If you have control characters (character code from \\000 to \\037) in a |
| 3270 | buffer and you want to print them in a text printer, select this |
| 3271 | option. All control characters in your buffer or region will be |
| 3272 | replaced by a printable representation. The printable representations |
| 3273 | use ^ (for ASCII control characters) or hex. The characters tab, |
| 3274 | linefeed, space, return and formfeed are not affected. |
| 3275 | You don't need to select this option if you use any option of section |
| 3276 | I, the PostScript engine treats control characters properly. |
| 3277 | |
| 3278 | 5. If you want to print a directory, buffer, region or major mode in a |
| 3279 | text printer, select this option. See also the NOTE 1 on option 1. |
| 3280 | |
| 3281 | 6. You can select a new text printer to send text generated. For |
| 3282 | selection it's used all text printers defined in `pr-txt-printer-alist' |
| 3283 | variable (see it for documentation). |
| 3284 | See also `pr-setting-database'. |
| 3285 | |
| 3286 | III. PostScript page toggle options: |
| 3287 | |
| 3288 | 7. If you want a PostScript landscape printing, turn on this option. |
| 3289 | |
| 3290 | 8. If you want to have a header in each page in your PostScript code, |
| 3291 | turn on this option. |
| 3292 | |
| 3293 | 9. If you want to draw a gaudy frame around the header, turn on this |
| 3294 | option. This option is enabled if print header is on (option 8). |
| 3295 | |
| 3296 | 10. If you want that the line number is printed in your PostScript code, |
| 3297 | turn on this option. |
| 3298 | |
| 3299 | 11. If you want background zebra stripes in your PostScript code, turn on |
| 3300 | this option. |
| 3301 | |
| 3302 | 12. If you want a duplex printing and your PostScript printer has this |
| 3303 | feature, turn on this option. |
| 3304 | |
| 3305 | 13. If you turned on duplex printing, you can choose if you want to have a |
| 3306 | printing suitable for binding on the left or right (tumble off), or to |
| 3307 | have a printing suitable for binding at top or bottom (tumble on). |
| 3308 | This option is enabled if duplex is on (option 12). |
| 3309 | |
| 3310 | 14. If you want a PostScript upside-down printing, turn on this option. |
| 3311 | |
| 3312 | 15. With this option, you can choose if you want to print all pages, odd |
| 3313 | pages, even pages, odd sheets or even sheets. |
| 3314 | See also `ps-even-or-odd-pages'. |
| 3315 | |
| 3316 | IV. PostScript processing toggle options: |
| 3317 | |
| 3318 | 16. If you want to spool the PostScript code generated, turn on this |
| 3319 | option. To spool the PostScript code generated use option 2. You can |
| 3320 | despool later by choosing option 1 or 2, sub-option `Despool...'. |
| 3321 | |
| 3322 | 17. If you use colors in your buffers and want to see these colors on your |
| 3323 | PostScript code generated, turn on this option. If you have a |
| 3324 | black/white PostScript printer, these colors are displayed in gray |
| 3325 | scale by PostScript printer interpreter. |
| 3326 | |
| 3327 | 18. If you don't have a PostScript printer to send PostScript files, turn |
| 3328 | on this option. When this option is on, the ghostscript is used to |
| 3329 | print PostScript files. In GNU or Unix system, if ghostscript is set |
| 3330 | as a PostScript filter, you don't need to turn on this option. |
| 3331 | |
| 3332 | V. Printing customization: |
| 3333 | |
| 3334 | 19. If you want that region is automagically detected, turn on this |
| 3335 | option. Note that this will only work if you're using transient mark |
| 3336 | mode. When this option is on, the `*-buffer*' commands will behave |
| 3337 | like `*-region*' commands, that is, `*-buffer*' commands will print |
| 3338 | only the region marked instead of all buffer. |
| 3339 | |
| 3340 | 20. Turn this option on if you want that when current major-mode is |
| 3341 | declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands |
| 3342 | behave like `*-mode*' commands. |
| 3343 | |
| 3344 | 21. If you want that Printing menu stays open while you are setting |
| 3345 | toggle options, turn on this option. The variables |
| 3346 | `pr-menu-char-height' and `pr-menu-char-width' are used to guess the |
| 3347 | menu position, so don't forget to adjust these variables if menu |
| 3348 | position is not ok. |
| 3349 | |
| 3350 | VI. Customization: |
| 3351 | |
| 3352 | 22. Besides all options in section III, IV and V, you can customize much |
| 3353 | more PostScript options in `ps-print' option. Or you can customize |
| 3354 | some `lpr' options for text printing. Or customize `printing' |
| 3355 | options. |
| 3356 | |
| 3357 | 23. Show current settings for `printing', `ps-print' or `lpr'. |
| 3358 | |
| 3359 | 24. Quick help for printing menu layout. |
| 3360 | ") |
| 3361 | "Printing help message.") |
| 3362 | |
| 3363 | |
| 3364 | (defconst pr-interface-help-message |
| 3365 | (concat "printing.el version " pr-version |
| 3366 | " ps-print.el version " ps-print-version |
| 3367 | "\n\n |
| 3368 | The printing interface buffer has the same functionality as the printing menu. |
| 3369 | The major difference is that the states (like sending PostScript generated to a |
| 3370 | file, n-up printing, etc.) are set and saved between priting buffer |
| 3371 | activation. Also, the landscape, duplex and tumble values are the same for |
| 3372 | PostScript file and directory/buffer/region/mode processing; using menu, there |
| 3373 | are different value sets for PostScript file and directory/buffer/region/mode |
| 3374 | processing. |
| 3375 | |
| 3376 | The printing interface buffer has the following sections: |
| 3377 | |
| 3378 | 1. Print: |
| 3379 | |
| 3380 | Here you can choose to print/preview a buffer, a directory or a PostScript |
| 3381 | file: |
| 3382 | |
| 3383 | 1a. Buffer: |
| 3384 | |
| 3385 | * Buffer List: |
| 3386 | Select a buffer from the current buffer list. |
| 3387 | |
| 3388 | * Region: |
| 3389 | If it's on, this means that the selected buffer has an active region, |
| 3390 | so you can turn on/off, as you wish. |
| 3391 | If it's off when a buffer is selected, this means that the selected |
| 3392 | buffer has no active region, so it'll not be possible to turn it on. |
| 3393 | If you want to process the region, let this option on. |
| 3394 | If you want to process the whole buffer, let this option off. |
| 3395 | |
| 3396 | * Mode: |
| 3397 | If it's on, this means that the selected buffer major mode is declared |
| 3398 | for major mode processing, so you can turn on/off, as you wish. |
| 3399 | If it's off when a buffer is selected, this means that the selected |
| 3400 | buffer major mode isn't declared for major mode processing, so it'll |
| 3401 | not be possible to turn it on. |
| 3402 | If you want the major mode processing, let this option on. |
| 3403 | If you don't want the major mode processing, let this option off. |
| 3404 | |
| 3405 | NOTE 1: It's possible to customize a major mode printing, just declare |
| 3406 | the customization in `pr-mode-alist' and invoke some of |
| 3407 | `*-mode*' commands or select Mode option in Printing menu. An |
| 3408 | example for major mode usage is when you're using gnus (or mh, |
| 3409 | or rmail, etc.) and you're in the *Summary* buffer, if you |
| 3410 | forget to switch to the *Article* buffer before printing, |
| 3411 | you'll get a nicely formatted list of article subjects shows |
| 3412 | up at the printer. With major mode printing you don't need to |
| 3413 | switch from gnus *Summary* buffer first. |
| 3414 | |
| 3415 | 1b. Directory: |
| 3416 | |
| 3417 | * Directory: |
| 3418 | Specify a valid directory path. |
| 3419 | |
| 3420 | * File Regexp: |
| 3421 | Specify a file name regexp. All file names in the directory that |
| 3422 | match with regexp will be printed/previewed. An empty file name |
| 3423 | regexp means to print/preview all files in the directory. |
| 3424 | |
| 3425 | * List Directory Entry: |
| 3426 | If it's turned on, list directory entries besides file entries. |
| 3427 | |
| 3428 | 1c. PostScript file: |
| 3429 | |
| 3430 | * PostScript File: |
| 3431 | Specify an existent PostScript file to print/preview. |
| 3432 | |
| 3433 | * PostScript Utility: |
| 3434 | Select a PostScript utility. |
| 3435 | See `pr-ps-utility-alist' and `pr-setting-database' for documentation. |
| 3436 | |
| 3437 | NOTE 2: Don't forget to download and install the utilities declared on |
| 3438 | `pr-ps-utility-alist'. |
| 3439 | |
| 3440 | * No Preprocessing: |
| 3441 | If it's turned on, don't use the PostScript utility to preprocess the |
| 3442 | PostScript file before printing/previewing. |
| 3443 | |
| 3444 | 2. PostScript printer: |
| 3445 | |
| 3446 | * PostScript Printer: |
| 3447 | You can select a new PostScript printer to send PostScript code |
| 3448 | generated. For selection it's used all PostScript printers defined |
| 3449 | in `pr-ps-printer-alist' variable (see it for documentation). |
| 3450 | See also `pr-setting-database'. |
| 3451 | |
| 3452 | * Despool: |
| 3453 | If spooling is on, you can turn it on/off, as you wish. |
| 3454 | If spooling is off, it'll not be possible to turn it on. |
| 3455 | If it's turned on, specify to despools the PostScript spooling buffer in |
| 3456 | a temporary file or in the selected PostScript file when |
| 3457 | printing/previewing. |
| 3458 | |
| 3459 | * Preview: |
| 3460 | Preview the PostScript generated. |
| 3461 | |
| 3462 | * Print: |
| 3463 | Print the PostScript generated. |
| 3464 | |
| 3465 | * Quit: |
| 3466 | Quit from printing interface buffer. |
| 3467 | |
| 3468 | * Send to Printer/Temporary File: |
| 3469 | If it's turned on, the PostScript generated is sent directly to |
| 3470 | PostScript printer or, for previewing, to a temporary file. |
| 3471 | |
| 3472 | * Send to File: |
| 3473 | Specify a file name to send the PostScript generated. |
| 3474 | |
| 3475 | * N-Up: |
| 3476 | Specify n-up printing. |
| 3477 | |
| 3478 | 3. Text printer: |
| 3479 | |
| 3480 | * Text Printer: |
| 3481 | Select a new text printer to send text generated. For selection it's used |
| 3482 | all text printers defined in `pr-txt-printer-alist' variable (see it for |
| 3483 | documentation). See also `pr-setting-database'. |
| 3484 | |
| 3485 | * Printify: |
| 3486 | If you have control characters (character code from \\000 to \\037) in a |
| 3487 | buffer and you want to print them in a text printer, select this |
| 3488 | option. All control characters in your buffer or region will be |
| 3489 | replaced by a printable representation. The printable representations |
| 3490 | use ^ (for ASCII control characters) or hex. The characters tab, |
| 3491 | linefeed, space, return and formfeed are not affected. |
| 3492 | You don't need to select this option if you use any option of section |
| 3493 | I, the PostScript engine treats control characters properly. |
| 3494 | |
| 3495 | * Print: |
| 3496 | To print a directory, buffer, region or major mode in a |
| 3497 | text printer, select this option. See also the NOTE 1 on section 1. |
| 3498 | |
| 3499 | * Quit: |
| 3500 | Quit from printing interface buffer. |
| 3501 | |
| 3502 | 4. Settings: |
| 3503 | |
| 3504 | There are 3 setting columns: |
| 3505 | |
| 3506 | 4a. First column (left column): |
| 3507 | |
| 3508 | * Landscape: |
| 3509 | PostScript landscape printing. |
| 3510 | |
| 3511 | * Print Header: |
| 3512 | To have a header in each page in your PostScript code. |
| 3513 | |
| 3514 | * Print Header Frame: |
| 3515 | To draw a gaudy frame around the header. |
| 3516 | |
| 3517 | * Line Number: |
| 3518 | The line number is printed in your PostScript code. |
| 3519 | |
| 3520 | * Zebra Stripes: |
| 3521 | Background zebra stripes in your PostScript code. |
| 3522 | |
| 3523 | * Duplex: |
| 3524 | Duplex printing (if your PostScript printer has this feature). |
| 3525 | |
| 3526 | * Tumble: |
| 3527 | If duplex printing is on, you can choose if you want to have a |
| 3528 | printing suitable for binding on the left or right (tumble off), or to |
| 3529 | have a printing suitable for binding at top or bottom (tumble on). |
| 3530 | |
| 3531 | * Upside-Down: |
| 3532 | PostScript upside-down printing. |
| 3533 | |
| 3534 | 4b. Second column (middle column): |
| 3535 | |
| 3536 | * Auto Region: |
| 3537 | If you want that region is automagically detected, turn on this |
| 3538 | option. Note that this will only work if you're using transient mark |
| 3539 | mode. When this option is on, the `*-buffer*' commands will behave |
| 3540 | like `*-region*' commands, that is, `*-buffer*' commands will print |
| 3541 | only the region marked instead of all buffer. |
| 3542 | |
| 3543 | * Auto Mode: |
| 3544 | Turn this option on if you want that when current major-mode is |
| 3545 | declared in `pr-mode-alist', the `*-buffer*' and `*-region*' commands |
| 3546 | behave like `*-mode*' commands. |
| 3547 | |
| 3548 | * Menu Lock: |
| 3549 | If you want that Printing menu stays open while you are setting |
| 3550 | toggle options, turn on this option. The variables |
| 3551 | `pr-menu-char-height' and `pr-menu-char-width' are used to guess the |
| 3552 | menu position, so don't forget to adjust these variables if menu |
| 3553 | position is not ok. |
| 3554 | |
| 3555 | * Spool Buffer: |
| 3556 | To spool the PostScript code generated. You can despool later by |
| 3557 | setting Despool option on PostScript printer section. |
| 3558 | |
| 3559 | * Print with faces: |
| 3560 | If you use colors in your buffers and want to see these colors on your |
| 3561 | PostScript code generated, turn on this option. If you have a |
| 3562 | black/white PostScript printer, these colors are displayed in gray |
| 3563 | scale by PostScript printer interpreter. |
| 3564 | |
| 3565 | * Print via Ghostscript: |
| 3566 | If you don't have a PostScript printer to send PostScript files, turn |
| 3567 | on this option. When this option is on, the ghostscript is used to |
| 3568 | print PostScript files. In GNU or Unix system, if ghostscript is set |
| 3569 | as a PostScript filter, you don't need to turn on this option. |
| 3570 | |
| 3571 | * Parity Page Menu: |
| 3572 | To print all pages, odd pages, even pages, odd sheets or even sheets. |
| 3573 | See also `ps-even-or-odd-pages'. |
| 3574 | |
| 3575 | 4c. Third column (right column): |
| 3576 | |
| 3577 | * Verbose: |
| 3578 | That is, to be verbose when editing a field in interface buffer. |
| 3579 | |
| 3580 | 5. Customize: |
| 3581 | |
| 3582 | Besides all options in section 4, you can customize much more PostScript |
| 3583 | options in `ps-print' option. Or you can customize some `lpr' options for |
| 3584 | text printing. Or customize `printing' options. |
| 3585 | |
| 3586 | 6. Show settings: |
| 3587 | |
| 3588 | Show current settings for `printing', `ps-print' or `lpr'. |
| 3589 | |
| 3590 | 7. Help: |
| 3591 | |
| 3592 | Quick help for printing interface buffer and printing menu layout. You can |
| 3593 | also quit the printing interface buffer or kill all printing help buffer. |
| 3594 | ") |
| 3595 | "Printing buffer interface help message.") |
| 3596 | |
| 3597 | |
| 3598 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 3599 | ;; Commands |
| 3600 | |
| 3601 | |
| 3602 | ;;;###autoload |
| 3603 | (defun pr-interface (&optional buffer) |
| 3604 | "Activate the printing interface buffer. |
| 3605 | |
| 3606 | If BUFFER is nil, the current buffer is used for printing. |
| 3607 | |
| 3608 | For more information, type \\[pr-interface-help]." |
| 3609 | (interactive) |
| 3610 | (save-excursion |
| 3611 | (set-buffer (or buffer (current-buffer))) |
| 3612 | (pr-create-interface))) |
| 3613 | |
| 3614 | |
| 3615 | ;;;###autoload |
| 3616 | (defun pr-ps-directory-preview (n-up dir file-regexp &optional filename) |
| 3617 | "Preview directory using ghostview. |
| 3618 | |
| 3619 | Interactively, the command prompts for N-UP printing number, a directory, a |
| 3620 | file name regexp for matching and, when you use a prefix argument (C-u), the |
| 3621 | command prompts the user for a file name, and saves the PostScript image in |
| 3622 | that file instead of saving it in a temporary file. |
| 3623 | |
| 3624 | Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is |
| 3625 | nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for |
| 3626 | FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil, |
| 3627 | save the image in a temporary file. If FILENAME is a string, save the |
| 3628 | PostScript image in a file with that name. If FILENAME is t, prompts for a |
| 3629 | file name. |
| 3630 | |
| 3631 | See also documentation for `pr-list-directory'." |
| 3632 | (interactive (pr-interactive-ps-dir-args (pr-prompt "PS preview dir"))) |
| 3633 | (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename |
| 3634 | (pr-prompt "PS preview dir")) |
| 3635 | (setq filename (pr-ps-file filename)) |
| 3636 | (pr-ps-file-list n-up dir file-regexp filename) |
| 3637 | (or pr-spool-p |
| 3638 | (pr-ps-file-preview filename))) |
| 3639 | |
| 3640 | |
| 3641 | ;;;###autoload |
| 3642 | (defun pr-ps-directory-using-ghostscript (n-up dir file-regexp &optional filename) |
| 3643 | "Print directory using PostScript through ghostscript. |
| 3644 | |
| 3645 | Interactively, the command prompts for N-UP printing number, a directory, a |
| 3646 | file name regexp for matching and, when you use a prefix argument (C-u), the |
| 3647 | command prompts the user for a file name, and saves the PostScript image in |
| 3648 | that file instead of saving it in a temporary file. |
| 3649 | |
| 3650 | Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is |
| 3651 | nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for |
| 3652 | FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil, |
| 3653 | save the image in a temporary file. If FILENAME is a string, save the |
| 3654 | PostScript image in a file with that name. If FILENAME is t, prompts for a |
| 3655 | file name. |
| 3656 | |
| 3657 | See also documentation for `pr-list-directory'." |
| 3658 | (interactive (pr-interactive-ps-dir-args (pr-prompt "PS print dir GS"))) |
| 3659 | (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename |
| 3660 | (pr-prompt "PS print dir GS")) |
| 3661 | (let ((file (pr-ps-file filename))) |
| 3662 | (pr-ps-file-list n-up dir file-regexp file) |
| 3663 | (pr-ps-file-using-ghostscript file) |
| 3664 | (or filename (pr-delete-file file)))) |
| 3665 | |
| 3666 | |
| 3667 | ;;;###autoload |
| 3668 | (defun pr-ps-directory-print (n-up dir file-regexp &optional filename) |
| 3669 | "Print directory using PostScript printer. |
| 3670 | |
| 3671 | Interactively, the command prompts for N-UP printing number, a directory, a |
| 3672 | file name regexp for matching and, when you use a prefix argument (C-u), the |
| 3673 | command prompts the user for a file name, and saves the PostScript image in |
| 3674 | that file instead of saving it in a temporary file. |
| 3675 | |
| 3676 | Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is |
| 3677 | nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for |
| 3678 | FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil, |
| 3679 | save the image in a temporary file. If FILENAME is a string, save the |
| 3680 | PostScript image in a file with that name. If FILENAME is t, prompts for a |
| 3681 | file name. |
| 3682 | |
| 3683 | See also documentation for `pr-list-directory'." |
| 3684 | (interactive (pr-interactive-ps-dir-args (pr-prompt "PS print dir"))) |
| 3685 | (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename |
| 3686 | (pr-prompt "PS print dir")) |
| 3687 | (let ((file (pr-ps-file filename))) |
| 3688 | (pr-ps-file-list n-up dir file-regexp file) |
| 3689 | (pr-ps-file-print file) |
| 3690 | (or filename (pr-delete-file file)))) |
| 3691 | |
| 3692 | |
| 3693 | ;;;###autoload |
| 3694 | (defun pr-ps-directory-ps-print (n-up dir file-regexp &optional filename) |
| 3695 | "Print directory using PostScript printer or through ghostscript. |
| 3696 | |
| 3697 | It depends on `pr-print-using-ghostscript'. |
| 3698 | |
| 3699 | Interactively, the command prompts for N-UP printing number, a directory, a |
| 3700 | file name regexp for matching and, when you use a prefix argument (C-u), the |
| 3701 | command prompts the user for a file name, and saves the PostScript image in |
| 3702 | that file instead of saving it in a temporary file. |
| 3703 | |
| 3704 | Noninteractively, if N-UP is nil, prompts for N-UP printing number. If DIR is |
| 3705 | nil, prompts for DIRectory. If FILE-REGEXP is nil, prompts for |
| 3706 | FILE(name)-REGEXP. The argument FILENAME is treated as follows: if it's nil, |
| 3707 | save the image in a temporary file. If FILENAME is a string, save the |
| 3708 | PostScript image in a file with that name. If FILENAME is t, prompts for a |
| 3709 | file name. |
| 3710 | |
| 3711 | See also documentation for `pr-list-directory'." |
| 3712 | (interactive (pr-interactive-ps-dir-args |
| 3713 | (pr-prompt (pr-prompt-gs "PS print dir")))) |
| 3714 | (pr-set-ps-dir-args 'n-up 'dir 'file-regexp 'filename |
| 3715 | (pr-prompt (pr-prompt-gs "PS print dir"))) |
| 3716 | (if (pr-using-ghostscript-p) |
| 3717 | (pr-ps-directory-using-ghostscript n-up dir file-regexp filename) |
| 3718 | (pr-ps-directory-print n-up dir file-regexp filename))) |
| 3719 | |
| 3720 | |
| 3721 | ;;;###autoload |
| 3722 | (defun pr-ps-buffer-preview (n-up &optional filename) |
| 3723 | "Preview buffer using ghostview. |
| 3724 | |
| 3725 | Interactively, the command prompts for N-UP printing number and, when you use a |
| 3726 | prefix argument (C-u), the command prompts the user for a file name, and saves |
| 3727 | the PostScript image in that file instead of saving it in a temporary file. |
| 3728 | |
| 3729 | Noninteractively, if N-UP is nil, prompts for N-UP printing number. The |
| 3730 | argument FILENAME is treated as follows: if it's nil, save the image in a |
| 3731 | temporary file. If FILENAME is a string, save the PostScript image in a file |
| 3732 | with that name. If FILENAME is t, prompts for a file name." |
| 3733 | (interactive (pr-interactive-n-up-file (pr-prompt "PS preview"))) |
| 3734 | (if (pr-auto-mode-p) |
| 3735 | (pr-ps-mode-preview n-up filename) |
| 3736 | (pr-ps-preview (pr-region-active-symbol) n-up filename |
| 3737 | (pr-region-active-string "PS preview")))) |
| 3738 | |
| 3739 | |
| 3740 | ;;;###autoload |
| 3741 | (defun pr-ps-buffer-using-ghostscript (n-up &optional filename) |
| 3742 | "Print buffer using PostScript through ghostscript. |
| 3743 | |
| 3744 | Interactively, the command prompts for N-UP printing number and, when you use a |
| 3745 | prefix argument (C-u), the command prompts the user for a file name, and saves |
| 3746 | the PostScript image in that file instead of sending it to the printer. |
| 3747 | |
| 3748 | Noninteractively, if N-UP is nil, prompts for N-UP printing number. The |
| 3749 | argument FILENAME is treated as follows: if it's nil, send the image to the |
| 3750 | printer. If FILENAME is a string, save the PostScript image in a file with |
| 3751 | that name. If FILENAME is t, prompts for a file name." |
| 3752 | (interactive (pr-interactive-n-up-file (pr-prompt "PS print GS"))) |
| 3753 | (if (pr-auto-mode-p) |
| 3754 | (pr-ps-mode-using-ghostscript n-up filename) |
| 3755 | (pr-ps-using-ghostscript (pr-region-active-symbol) n-up filename |
| 3756 | (pr-region-active-string "PS print GS")))) |
| 3757 | |
| 3758 | |
| 3759 | ;;;###autoload |
| 3760 | (defun pr-ps-buffer-print (n-up &optional filename) |
| 3761 | "Print buffer using PostScript printer. |
| 3762 | |
| 3763 | Interactively, the command prompts for N-UP printing number and, when you use a |
| 3764 | prefix argument (C-u), the command prompts the user for a file name, and saves |
| 3765 | the PostScript image in that file instead of sending it to the printer. |
| 3766 | |
| 3767 | Noninteractively, if N-UP is nil, prompts for N-UP printing number. The |
| 3768 | argument FILENAME is treated as follows: if it's nil, send the image to the |
| 3769 | printer. If FILENAME is a string, save the PostScript image in a file with |
| 3770 | that name. If FILENAME is t, prompts for a file name." |
| 3771 | (interactive (pr-interactive-n-up-file (pr-prompt "PS print"))) |
| 3772 | (if (pr-auto-mode-p) |
| 3773 | (pr-ps-mode-print n-up filename) |
| 3774 | (pr-ps-print (pr-region-active-symbol) n-up filename |
| 3775 | (pr-region-active-string "PS print")))) |
| 3776 | |
| 3777 | |
| 3778 | ;;;###autoload |
| 3779 | (defun pr-ps-buffer-ps-print (n-up &optional filename) |
| 3780 | "Print buffer using PostScript printer or through ghostscript. |
| 3781 | |
| 3782 | It depends on `pr-print-using-ghostscript'. |
| 3783 | |
| 3784 | Interactively, the command prompts for N-UP printing number and, when you use a |
| 3785 | prefix argument (C-u), the command prompts the user for a file name, and saves |
| 3786 | the PostScript image in that file instead of sending it to the printer. |
| 3787 | |
| 3788 | Noninteractively, if N-UP is nil, prompts for N-UP printing number. The |
| 3789 | argument FILENAME is treated as follows: if it's nil, send the image to the |
| 3790 | printer. If FILENAME is a string, save the PostScript image in a file with |
| 3791 | that name. If FILENAME is t, prompts for a file name." |
| 3792 | (interactive (pr-interactive-n-up-file |
| 3793 | (pr-prompt (pr-prompt-gs "PS print")))) |
| 3794 | (cond ((pr-auto-mode-p) |
| 3795 | (pr-ps-mode-ps-print n-up filename)) |
| 3796 | ((pr-using-ghostscript-p) |
| 3797 | (pr-ps-using-ghostscript (pr-region-active-symbol) n-up filename |
| 3798 | (pr-region-active-string "PS print GS"))) |
| 3799 | (t |
| 3800 | (pr-ps-print (pr-region-active-symbol) n-up filename |
| 3801 | (pr-region-active-string "PS print"))))) |
| 3802 | |
| 3803 | |
| 3804 | ;;;###autoload |
| 3805 | (defun pr-ps-region-preview (n-up &optional filename) |
| 3806 | "Preview region using ghostview. |
| 3807 | |
| 3808 | See also `pr-ps-buffer-preview'." |
| 3809 | (interactive (pr-interactive-n-up-file (pr-prompt-region "PS preview"))) |
| 3810 | (if (pr-auto-mode-p) |
| 3811 | (let ((pr-auto-region t)) |
| 3812 | (pr-ps-mode-preview n-up filename)) |
| 3813 | (pr-ps-preview 'region n-up filename "PS preview region"))) |
| 3814 | |
| 3815 | |
| 3816 | ;;;###autoload |
| 3817 | (defun pr-ps-region-using-ghostscript (n-up &optional filename) |
| 3818 | "Print region using PostScript through ghostscript. |
| 3819 | |
| 3820 | See also `pr-ps-buffer-using-ghostscript'." |
| 3821 | (interactive (pr-interactive-n-up-file (pr-prompt-region "PS print GS"))) |
| 3822 | (if (pr-auto-mode-p) |
| 3823 | (let ((pr-auto-region t)) |
| 3824 | (pr-ps-mode-using-ghostscript n-up filename)) |
| 3825 | (pr-ps-using-ghostscript 'region n-up filename "PS print GS region"))) |
| 3826 | |
| 3827 | |
| 3828 | ;;;###autoload |
| 3829 | (defun pr-ps-region-print (n-up &optional filename) |
| 3830 | "Print region using PostScript printer. |
| 3831 | |
| 3832 | See also `pr-ps-buffer-print'." |
| 3833 | (interactive (pr-interactive-n-up-file (pr-prompt-region "PS print"))) |
| 3834 | (if (pr-auto-mode-p) |
| 3835 | (let ((pr-auto-region t)) |
| 3836 | (pr-ps-mode-print n-up filename)) |
| 3837 | (pr-ps-print 'region n-up filename "PS print region"))) |
| 3838 | |
| 3839 | |
| 3840 | ;;;###autoload |
| 3841 | (defun pr-ps-region-ps-print (n-up &optional filename) |
| 3842 | "Print region using PostScript printer or through ghostscript. |
| 3843 | |
| 3844 | See also `pr-ps-buffer-ps-print'." |
| 3845 | (interactive (pr-interactive-n-up-file |
| 3846 | (pr-prompt-region (pr-prompt-gs "PS print")))) |
| 3847 | (cond ((pr-auto-mode-p) |
| 3848 | (let ((pr-auto-region t)) |
| 3849 | (pr-ps-mode-ps-print n-up filename))) |
| 3850 | ((pr-using-ghostscript-p) |
| 3851 | (pr-ps-using-ghostscript 'region n-up filename "PS print GS region")) |
| 3852 | (t |
| 3853 | (pr-ps-print 'region n-up filename "PS print region")))) |
| 3854 | |
| 3855 | |
| 3856 | ;;;###autoload |
| 3857 | (defun pr-ps-mode-preview (n-up &optional filename) |
| 3858 | "Preview major mode using ghostview. |
| 3859 | |
| 3860 | See also `pr-ps-buffer-preview'." |
| 3861 | (interactive (pr-interactive-n-up-file "PS preview mode")) |
| 3862 | (pr-set-n-up-and-filename 'n-up 'filename "PS preview mode") |
| 3863 | (let ((file (pr-ps-file filename))) |
| 3864 | (and (pr-ps-mode n-up file) |
| 3865 | (not pr-spool-p) |
| 3866 | (pr-ps-file-preview file)))) |
| 3867 | |
| 3868 | |
| 3869 | ;;;###autoload |
| 3870 | (defun pr-ps-mode-using-ghostscript (n-up &optional filename) |
| 3871 | "Print major mode using PostScript through ghostscript. |
| 3872 | |
| 3873 | See also `pr-ps-buffer-using-ghostscript'." |
| 3874 | (interactive (pr-interactive-n-up-file "PS print GS mode")) |
| 3875 | (pr-set-n-up-and-filename 'n-up 'filename "PS print GS mode") |
| 3876 | (let ((file (pr-ps-file filename))) |
| 3877 | (when (and (pr-ps-mode n-up file) |
| 3878 | (not pr-spool-p)) |
| 3879 | (pr-ps-file-using-ghostscript file) |
| 3880 | (or filename (pr-delete-file file))))) |
| 3881 | |
| 3882 | |
| 3883 | ;;;###autoload |
| 3884 | (defun pr-ps-mode-print (n-up &optional filename) |
| 3885 | "Print major mode using PostScript printer. |
| 3886 | |
| 3887 | See also `pr-ps-buffer-print'." |
| 3888 | (interactive (pr-interactive-n-up-file "PS print mode")) |
| 3889 | (pr-set-n-up-and-filename 'n-up 'filename "PS print mode") |
| 3890 | (pr-ps-mode n-up filename)) |
| 3891 | |
| 3892 | |
| 3893 | ;;;###autoload |
| 3894 | (defun pr-ps-mode-ps-print (n-up &optional filename) |
| 3895 | "Print major mode using PostScript or through ghostscript. |
| 3896 | |
| 3897 | See also `pr-ps-buffer-ps-print'." |
| 3898 | (interactive (pr-interactive-n-up-file (pr-prompt-gs "PS print mode"))) |
| 3899 | (if (pr-using-ghostscript-p) |
| 3900 | (pr-ps-mode-using-ghostscript n-up filename) |
| 3901 | (pr-ps-mode-print n-up filename))) |
| 3902 | |
| 3903 | |
| 3904 | ;;;###autoload |
| 3905 | (defun pr-printify-directory (&optional dir file-regexp) |
| 3906 | "Replace nonprinting characters in directory with printable representations. |
| 3907 | The printable representations use ^ (for ASCII control characters) or hex. |
| 3908 | The characters tab, linefeed, space, return and formfeed are not affected. |
| 3909 | |
| 3910 | Interactively, the command prompts for a directory and a file name regexp for |
| 3911 | matching. |
| 3912 | |
| 3913 | Noninteractively, if DIR is nil, prompts for DIRectory. If FILE-REGEXP is nil, |
| 3914 | prompts for FILE(name)-REGEXP. |
| 3915 | |
| 3916 | See also documentation for `pr-list-directory'." |
| 3917 | (interactive (pr-interactive-dir-args "Printify dir")) |
| 3918 | (pr-set-dir-args 'dir 'file-regexp "Printify dir") |
| 3919 | (pr-file-list dir file-regexp 'pr-printify-buffer)) |
| 3920 | |
| 3921 | |
| 3922 | ;;;###autoload |
| 3923 | (defun pr-printify-buffer () |
| 3924 | "Replace nonprinting characters in buffer with printable representations. |
| 3925 | The printable representations use ^ (for ASCII control characters) or hex. |
| 3926 | The characters tab, linefeed, space, return and formfeed are not affected." |
| 3927 | (interactive "*") |
| 3928 | (if (pr-region-active-p) |
| 3929 | (pr-printify-region) |
| 3930 | (printify-region (point-min) (point-max)))) |
| 3931 | |
| 3932 | |
| 3933 | ;;;###autoload |
| 3934 | (defun pr-printify-region () |
| 3935 | "Replace nonprinting characters in region with printable representations. |
| 3936 | The printable representations use ^ (for ASCII control characters) or hex. |
| 3937 | The characters tab, linefeed, space, return and formfeed are not affected." |
| 3938 | (interactive "*") |
| 3939 | (printify-region (point) (mark))) |
| 3940 | |
| 3941 | |
| 3942 | ;;;###autoload |
| 3943 | (defun pr-txt-directory (&optional dir file-regexp) |
| 3944 | "Print directory using text printer. |
| 3945 | |
| 3946 | Interactively, the command prompts for a directory and a file name regexp for |
| 3947 | matching. |
| 3948 | |
| 3949 | Noninteractively, if DIR is nil, prompts for DIRectory. If FILE-REGEXP is nil, |
| 3950 | prompts for FILE(name)-REGEXP. |
| 3951 | |
| 3952 | See also documentation for `pr-list-directory'." |
| 3953 | (interactive (pr-interactive-dir-args "Print dir")) |
| 3954 | (pr-set-dir-args 'dir 'file-regexp "Print dir") |
| 3955 | (pr-file-list dir file-regexp 'pr-txt-buffer)) |
| 3956 | |
| 3957 | |
| 3958 | ;;;###autoload |
| 3959 | (defun pr-txt-buffer () |
| 3960 | "Print buffer using text printer." |
| 3961 | (interactive) |
| 3962 | (cond ((pr-auto-mode-p) |
| 3963 | (pr-txt-mode)) |
| 3964 | ((pr-region-active-p) |
| 3965 | (pr-txt-region)) |
| 3966 | (t |
| 3967 | (pr-txt-print (point-min) (point-max))))) |
| 3968 | |
| 3969 | |
| 3970 | ;;;###autoload |
| 3971 | (defun pr-txt-region () |
| 3972 | "Print region using text printer." |
| 3973 | (interactive) |
| 3974 | (if (pr-auto-mode-p) |
| 3975 | (let ((pr-auto-region t)) |
| 3976 | (pr-txt-mode)) |
| 3977 | (pr-txt-print (point) (mark)))) |
| 3978 | |
| 3979 | |
| 3980 | ;;;###autoload |
| 3981 | (defun pr-txt-mode () |
| 3982 | "Print major mode using text printer." |
| 3983 | (interactive) |
| 3984 | (let ((args (pr-mode-alist-p))) |
| 3985 | (if args |
| 3986 | (funcall (car args) (nthcdr 2 args)) |
| 3987 | (ding) |
| 3988 | (message "`%s' major mode not declared." major-mode)))) |
| 3989 | |
| 3990 | |
| 3991 | ;;;###autoload |
| 3992 | (defun pr-despool-preview (&optional filename) |
| 3993 | "Preview spooled PostScript. |
| 3994 | |
| 3995 | Interactively, when you use a prefix argument (C-u), the command prompts the |
| 3996 | user for a file name, and saves the spooled PostScript image in that file |
| 3997 | instead of saving it in a temporary file. |
| 3998 | |
| 3999 | Noninteractively, the argument FILENAME is treated as follows: if it is nil, |
| 4000 | save the image in a temporary file. If FILENAME is a string, save the |
| 4001 | PostScript image in a file with that name." |
| 4002 | (interactive (list (ps-print-preprint current-prefix-arg))) |
| 4003 | (let ((file (pr-ps-file filename))) |
| 4004 | (when (stringp file) |
| 4005 | (pr-despool-print file) |
| 4006 | (pr-ps-file-preview file)))) |
| 4007 | |
| 4008 | |
| 4009 | ;;;###autoload |
| 4010 | (defun pr-despool-using-ghostscript (&optional filename) |
| 4011 | "Print spooled PostScript using ghostscript. |
| 4012 | |
| 4013 | Interactively, when you use a prefix argument (C-u), the command prompts the |
| 4014 | user for a file name, and saves the spooled PostScript image in that file |
| 4015 | instead of sending it to the printer. |
| 4016 | |
| 4017 | Noninteractively, the argument FILENAME is treated as follows: if it is nil, |
| 4018 | send the image to the printer. If FILENAME is a string, save the PostScript |
| 4019 | image in a file with that name." |
| 4020 | (interactive (list (ps-print-preprint current-prefix-arg))) |
| 4021 | (let ((file (pr-ps-file filename))) |
| 4022 | (when (stringp file) |
| 4023 | (pr-despool-print file) |
| 4024 | (pr-ps-file-using-ghostscript file) |
| 4025 | (or filename (pr-delete-file file))))) |
| 4026 | |
| 4027 | |
| 4028 | ;;;###autoload |
| 4029 | (defun pr-despool-print (&optional filename) |
| 4030 | "Send the spooled PostScript to the printer. |
| 4031 | |
| 4032 | Interactively, when you use a prefix argument (C-u), the command prompts the |
| 4033 | user for a file name, and saves the spooled PostScript image in that file |
| 4034 | instead of sending it to the printer. |
| 4035 | |
| 4036 | Noninteractively, the argument FILENAME is treated as follows: if it is nil, |
| 4037 | send the image to the printer. If FILENAME is a string, save the PostScript |
| 4038 | image in a file with that name." |
| 4039 | (interactive (list (ps-print-preprint current-prefix-arg))) |
| 4040 | (pr-save-file-modes |
| 4041 | (let ((ps-lpr-command (pr-command pr-ps-command)) |
| 4042 | (ps-lpr-switches pr-ps-switches) |
| 4043 | (ps-printer-name-option pr-ps-printer-switch) |
| 4044 | (ps-printer-name pr-ps-printer)) |
| 4045 | (ps-despool filename)))) |
| 4046 | |
| 4047 | |
| 4048 | ;;;###autoload |
| 4049 | (defun pr-despool-ps-print (&optional filename) |
| 4050 | "Send the spooled PostScript to the printer or use ghostscript to print it. |
| 4051 | |
| 4052 | Interactively, when you use a prefix argument (C-u), the command prompts the |
| 4053 | user for a file name, and saves the spooled PostScript image in that file |
| 4054 | instead of sending it to the printer. |
| 4055 | |
| 4056 | Noninteractively, the argument FILENAME is treated as follows: if it is nil, |
| 4057 | send the image to the printer. If FILENAME is a string, save the PostScript |
| 4058 | image in a file with that name." |
| 4059 | (interactive (list (ps-print-preprint current-prefix-arg))) |
| 4060 | (if pr-print-using-ghostscript |
| 4061 | (pr-despool-using-ghostscript filename) |
| 4062 | (pr-despool-print filename))) |
| 4063 | |
| 4064 | |
| 4065 | ;;;###autoload |
| 4066 | (defun pr-ps-file-preview (filename) |
| 4067 | "Preview PostScript file FILENAME." |
| 4068 | (interactive (list (pr-ps-infile-preprint "Preview "))) |
| 4069 | (and (stringp filename) (file-exists-p filename) |
| 4070 | (pr-call-process pr-gv-command filename))) |
| 4071 | |
| 4072 | |
| 4073 | ;;;###autoload |
| 4074 | (defun pr-ps-file-up-preview (n-up ifilename &optional ofilename) |
| 4075 | "Preview PostScript file FILENAME." |
| 4076 | (interactive (pr-interactive-n-up-inout "PS preview")) |
| 4077 | (let ((outfile (pr-ps-utility-args 'n-up 'ifilename 'ofilename |
| 4078 | "PS preview "))) |
| 4079 | (pr-ps-utility-process n-up ifilename outfile) |
| 4080 | (pr-ps-file-preview outfile))) |
| 4081 | |
| 4082 | |
| 4083 | ;;;###autoload |
| 4084 | (defun pr-ps-file-using-ghostscript (filename) |
| 4085 | "Print PostScript file FILENAME using ghostscript." |
| 4086 | (interactive (list (pr-ps-infile-preprint "Print preview "))) |
| 4087 | (and (stringp filename) (file-exists-p filename) |
| 4088 | (let* ((file (pr-expand-file-name filename)) |
| 4089 | (tempfile (pr-dosify-file-name (make-temp-file file)))) |
| 4090 | ;; gs use |
| 4091 | (pr-call-process pr-gs-command |
| 4092 | (format "-sDEVICE=%s" pr-gs-device) |
| 4093 | (format "-r%d" pr-gs-resolution) |
| 4094 | (pr-switches-string pr-gs-switches "pr-gs-switches") |
| 4095 | (format "-sOutputFile=\"%s\"" tempfile) |
| 4096 | file |
| 4097 | "-c quit") |
| 4098 | ;; printing |
| 4099 | (pr-ps-file-print tempfile) |
| 4100 | ;; deleting |
| 4101 | (pr-delete-file tempfile)))) |
| 4102 | |
| 4103 | |
| 4104 | ;;;###autoload |
| 4105 | (defun pr-ps-file-print (filename) |
| 4106 | "Print PostScript file FILENAME." |
| 4107 | (interactive (list (pr-ps-infile-preprint "Print "))) |
| 4108 | (and (stringp filename) (file-exists-p filename) |
| 4109 | ;; printing |
| 4110 | (let ((file (pr-expand-file-name filename))) |
| 4111 | (if (string= pr-ps-command "") |
| 4112 | ;; default action |
| 4113 | (let ((ps-spool-buffer (get-buffer-create ps-spool-buffer-name))) |
| 4114 | (save-excursion |
| 4115 | (set-buffer ps-spool-buffer) |
| 4116 | (erase-buffer) |
| 4117 | (insert-file-contents-literally file)) |
| 4118 | (pr-despool-print)) |
| 4119 | ;; use `pr-ps-command' to print |
| 4120 | (apply 'pr-call-process |
| 4121 | pr-ps-command |
| 4122 | (pr-switches-string pr-ps-switches "pr-ps-switches") |
| 4123 | (if (string-match "cp" pr-ps-command) |
| 4124 | ;; for "cp" (cmd in out) |
| 4125 | (list file |
| 4126 | (concat pr-ps-printer-switch pr-ps-printer)) |
| 4127 | ;; else, for others (cmd out in) |
| 4128 | (list (concat pr-ps-printer-switch pr-ps-printer) |
| 4129 | file))))))) |
| 4130 | |
| 4131 | |
| 4132 | ;;;###autoload |
| 4133 | (defun pr-ps-file-ps-print (filename) |
| 4134 | "Send PostScript file FILENAME to printer or use ghostscript to print it." |
| 4135 | (interactive (list (pr-ps-infile-preprint |
| 4136 | (if pr-print-using-ghostscript |
| 4137 | "Print preview " |
| 4138 | "Print ")))) |
| 4139 | (if pr-print-using-ghostscript |
| 4140 | (pr-ps-file-using-ghostscript filename) |
| 4141 | (pr-ps-file-print filename))) |
| 4142 | |
| 4143 | |
| 4144 | ;;;###autoload |
| 4145 | (defun pr-ps-file-up-ps-print (n-up ifilename &optional ofilename) |
| 4146 | "Process a PostScript file IFILENAME and send it to printer. |
| 4147 | |
| 4148 | Interactively, the command prompts for N-UP printing number, for an input |
| 4149 | PostScript file IFILENAME and, when you use a prefix argument (C-u), the |
| 4150 | command prompts the user for an output PostScript file name OFILENAME, and |
| 4151 | saves the PostScript image in that file instead of sending it to the printer. |
| 4152 | |
| 4153 | Noninteractively, if N-UP is nil, prompts for N-UP printing number. The |
| 4154 | argument IFILENAME is treated as follows: if it's t, prompts for an input |
| 4155 | PostScript file name; otherwise, it *must* be a string that it's an input |
| 4156 | PostScript file name. The argument OFILENAME is treated as follows: if it's |
| 4157 | nil, send the image to the printer. If OFILENAME is a string, save the |
| 4158 | PostScript image in a file with that name. If OFILENAME is t, prompts for a |
| 4159 | file name." |
| 4160 | (interactive (pr-interactive-n-up-inout |
| 4161 | (if pr-print-using-ghostscript |
| 4162 | "PS print GS" |
| 4163 | "PS print"))) |
| 4164 | (let ((outfile (pr-ps-utility-args 'n-up 'ifilename 'ofilename |
| 4165 | (if pr-print-using-ghostscript |
| 4166 | "PS print GS " |
| 4167 | "PS print ")))) |
| 4168 | (pr-ps-utility-process n-up ifilename outfile) |
| 4169 | (unless ofilename |
| 4170 | (pr-ps-file-ps-print outfile) |
| 4171 | (pr-delete-file outfile)))) |
| 4172 | |
| 4173 | |
| 4174 | ;;;###autoload |
| 4175 | (defun pr-toggle-file-duplex () |
| 4176 | "Toggle duplex for PostScript file." |
| 4177 | (interactive) |
| 4178 | (pr-toggle-file-duplex-menu t)) |
| 4179 | |
| 4180 | |
| 4181 | ;;;###autoload |
| 4182 | (defun pr-toggle-file-tumble () |
| 4183 | "Toggle tumble for PostScript file. |
| 4184 | |
| 4185 | If tumble is off, produces a printing suitable for binding on the left or |
| 4186 | right. |
| 4187 | If tumble is on, produces a printing suitable for binding at the top or |
| 4188 | bottom." |
| 4189 | (interactive) |
| 4190 | (pr-toggle-file-tumble-menu t)) |
| 4191 | |
| 4192 | |
| 4193 | ;;;###autoload |
| 4194 | (defun pr-toggle-file-landscape () |
| 4195 | "Toggle landscape for PostScript file." |
| 4196 | (interactive) |
| 4197 | (pr-toggle-file-landscape-menu t)) |
| 4198 | |
| 4199 | |
| 4200 | ;;;###autoload |
| 4201 | (defun pr-toggle-ghostscript () |
| 4202 | "Toggle printing using ghostscript." |
| 4203 | (interactive) |
| 4204 | (pr-toggle-ghostscript-menu t)) |
| 4205 | |
| 4206 | |
| 4207 | ;;;###autoload |
| 4208 | (defun pr-toggle-faces () |
| 4209 | "Toggle printing with faces." |
| 4210 | (interactive) |
| 4211 | (pr-toggle-faces-menu t)) |
| 4212 | |
| 4213 | |
| 4214 | ;;;###autoload |
| 4215 | (defun pr-toggle-spool () |
| 4216 | "Toggle spooling." |
| 4217 | (interactive) |
| 4218 | (pr-toggle-spool-menu t)) |
| 4219 | |
| 4220 | |
| 4221 | ;;;###autoload |
| 4222 | (defun pr-toggle-duplex () |
| 4223 | "Toggle duplex." |
| 4224 | (interactive) |
| 4225 | (pr-toggle-duplex-menu t)) |
| 4226 | |
| 4227 | |
| 4228 | ;;;###autoload |
| 4229 | (defun pr-toggle-tumble () |
| 4230 | "Toggle tumble. |
| 4231 | |
| 4232 | If tumble is off, produces a printing suitable for binding on the left or |
| 4233 | right. |
| 4234 | If tumble is on, produces a printing suitable for binding at the top or |
| 4235 | bottom." |
| 4236 | (interactive) |
| 4237 | (pr-toggle-tumble-menu t)) |
| 4238 | |
| 4239 | |
| 4240 | ;;;###autoload |
| 4241 | (defun pr-toggle-landscape () |
| 4242 | "Toggle landscape." |
| 4243 | (interactive) |
| 4244 | (pr-toggle-landscape-menu t)) |
| 4245 | |
| 4246 | |
| 4247 | ;;;###autoload |
| 4248 | (defun pr-toggle-upside-down () |
| 4249 | "Toggle upside-down." |
| 4250 | (interactive) |
| 4251 | (pr-toggle-upside-down-menu t)) |
| 4252 | |
| 4253 | |
| 4254 | ;;;###autoload |
| 4255 | (defun pr-toggle-line () |
| 4256 | "Toggle line number." |
| 4257 | (interactive) |
| 4258 | (pr-toggle-line-menu t)) |
| 4259 | |
| 4260 | |
| 4261 | ;;;###autoload |
| 4262 | (defun pr-toggle-zebra () |
| 4263 | "Toggle zebra stripes." |
| 4264 | (interactive) |
| 4265 | (pr-toggle-zebra-menu t)) |
| 4266 | |
| 4267 | |
| 4268 | ;;;###autoload |
| 4269 | (defun pr-toggle-header () |
| 4270 | "Toggle printing header." |
| 4271 | (interactive) |
| 4272 | (pr-toggle-header-menu t)) |
| 4273 | |
| 4274 | |
| 4275 | ;;;###autoload |
| 4276 | (defun pr-toggle-header-frame () |
| 4277 | "Toggle printing header frame." |
| 4278 | (interactive) |
| 4279 | (pr-toggle-header-frame-menu t)) |
| 4280 | |
| 4281 | |
| 4282 | ;;;###autoload |
| 4283 | (defun pr-toggle-lock () |
| 4284 | "Toggle menu lock." |
| 4285 | (interactive) |
| 4286 | (pr-toggle-lock-menu t)) |
| 4287 | |
| 4288 | |
| 4289 | ;;;###autoload |
| 4290 | (defun pr-toggle-region () |
| 4291 | "Toggle auto region." |
| 4292 | (interactive) |
| 4293 | (pr-toggle-region-menu t)) |
| 4294 | |
| 4295 | |
| 4296 | ;;;###autoload |
| 4297 | (defun pr-toggle-mode () |
| 4298 | "Toggle auto mode." |
| 4299 | (interactive) |
| 4300 | (pr-toggle-mode-menu t)) |
| 4301 | |
| 4302 | |
| 4303 | ;;;###autoload |
| 4304 | (defun pr-customize (&rest ignore) |
| 4305 | "Customization of the `printing' group." |
| 4306 | (interactive) |
| 4307 | (customize-group 'printing)) |
| 4308 | |
| 4309 | |
| 4310 | ;;;###autoload |
| 4311 | (defun lpr-customize (&rest ignore) |
| 4312 | "Customization of the `lpr' group." |
| 4313 | (interactive) |
| 4314 | (customize-group 'lpr)) |
| 4315 | |
| 4316 | |
| 4317 | ;;;###autoload |
| 4318 | (defun pr-help (&rest ignore) |
| 4319 | "Help for the printing package." |
| 4320 | (interactive) |
| 4321 | (pr-show-setup pr-help-message "*Printing Help*")) |
| 4322 | |
| 4323 | |
| 4324 | ;;;###autoload |
| 4325 | (defun pr-ps-name () |
| 4326 | "Interactively select a PostScript printer." |
| 4327 | (interactive) |
| 4328 | (pr-menu-set-ps-title |
| 4329 | (pr-complete-alist "PostScript printer" |
| 4330 | pr-ps-printer-alist pr-ps-name))) |
| 4331 | |
| 4332 | |
| 4333 | ;;;###autoload |
| 4334 | (defun pr-txt-name () |
| 4335 | "Interactively select a text printer." |
| 4336 | (interactive) |
| 4337 | (pr-menu-set-txt-title |
| 4338 | (pr-complete-alist "Text printer" |
| 4339 | pr-txt-printer-alist pr-txt-name))) |
| 4340 | |
| 4341 | |
| 4342 | ;;;###autoload |
| 4343 | (defun pr-ps-utility () |
| 4344 | "Interactively select a PostScript utility." |
| 4345 | (interactive) |
| 4346 | (pr-menu-set-utility-title |
| 4347 | (pr-complete-alist "Postscript utility" |
| 4348 | pr-ps-utility-alist pr-ps-utility))) |
| 4349 | |
| 4350 | |
| 4351 | ;;;###autoload |
| 4352 | (defun pr-show-ps-setup (&rest ignore) |
| 4353 | "Show current ps-print settings." |
| 4354 | (interactive) |
| 4355 | (pr-show-setup (ps-setup) "*PS Setup*")) |
| 4356 | |
| 4357 | |
| 4358 | ;;;###autoload |
| 4359 | (defun pr-show-pr-setup (&rest ignore) |
| 4360 | "Show current printing settings." |
| 4361 | (interactive) |
| 4362 | (pr-show-setup (pr-setup) "*PR Setup*")) |
| 4363 | |
| 4364 | |
| 4365 | ;;;###autoload |
| 4366 | (defun pr-show-lpr-setup (&rest ignore) |
| 4367 | "Show current lpr settings." |
| 4368 | (interactive) |
| 4369 | (pr-show-setup (lpr-setup) "*LPR Setup*")) |
| 4370 | |
| 4371 | |
| 4372 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 4373 | ;; Fast Commands |
| 4374 | |
| 4375 | |
| 4376 | ;;;###autoload |
| 4377 | (defun pr-ps-fast-fire (n-up &optional select) |
| 4378 | "Fast fire function for PostScript printing. |
| 4379 | |
| 4380 | If a region is active, the region will be printed instead of the whole buffer. |
| 4381 | Also if the current major-mode is defined in `pr-mode-alist', the settings in |
| 4382 | `pr-mode-alist' will be used, that is, the current buffer or region will be |
| 4383 | printed using `pr-ps-mode-ps-print'. |
| 4384 | |
| 4385 | |
| 4386 | Interactively, you have the following situations: |
| 4387 | |
| 4388 | M-x pr-ps-fast-fire RET |
| 4389 | The command prompts the user for a N-UP value and printing will |
| 4390 | immediatelly be done using the current active printer. |
| 4391 | |
| 4392 | C-u M-x pr-ps-fast-fire RET |
| 4393 | C-u 0 M-x pr-ps-fast-fire RET |
| 4394 | The command prompts the user for a N-UP value and also for a current |
| 4395 | PostScript printer, then printing will immediatelly be done using the new |
| 4396 | current active printer. |
| 4397 | |
| 4398 | C-u 1 M-x pr-ps-fast-fire RET |
| 4399 | The command prompts the user for a N-UP value and also for a file name, |
| 4400 | and saves the PostScript image in that file instead of sending it to the |
| 4401 | printer. |
| 4402 | |
| 4403 | C-u 2 M-x pr-ps-fast-fire RET |
| 4404 | The command prompts the user for a N-UP value, then for a current |
| 4405 | PostScript printer and, finally, for a file name. Then change the active |
| 4406 | printer to that choosen by user and saves the PostScript image in |
| 4407 | that file instead of sending it to the printer. |
| 4408 | |
| 4409 | |
| 4410 | Noninteractively, the argument N-UP should be a positive integer greater than |
| 4411 | zero and the argument SELECT is treated as follows: |
| 4412 | |
| 4413 | If it's nil, send the image to the printer. |
| 4414 | |
| 4415 | If it's a list or an integer lesser or equal to zero, the command prompts |
| 4416 | the user for a current PostScript printer, then printing will immediatelly |
| 4417 | be done using the new current active printer. |
| 4418 | |
| 4419 | If it's an integer equal to 1, the command prompts the user for a file name |
| 4420 | and saves the PostScript image in that file instead of sending it to the |
| 4421 | printer. |
| 4422 | |
| 4423 | If it's an integer greater or equal to 2, the command prompts the user for a |
| 4424 | current PostScript printer and for a file name. Then change the active |
| 4425 | printer to that choosen by user and saves the PostScript image in that file |
| 4426 | instead of sending it to the printer. |
| 4427 | |
| 4428 | If it's a symbol which it's defined in `pr-ps-printer-alist', it's the new |
| 4429 | active printer and printing will immediatelly be done using the new active |
| 4430 | printer. |
| 4431 | |
| 4432 | Otherwise, send the image to the printer. |
| 4433 | |
| 4434 | |
| 4435 | Note that this command always behaves as if `pr-auto-region' and `pr-auto-mode' |
| 4436 | are both set to t." |
| 4437 | (interactive (list (pr-interactive-n-up (pr-prompt-gs "PS print fast")) |
| 4438 | current-prefix-arg)) |
| 4439 | (let ((pr-auto-region t) |
| 4440 | (pr-auto-mode t) |
| 4441 | filename) |
| 4442 | (cond ((null select)) |
| 4443 | ((listp select) |
| 4444 | (pr-ps-name)) |
| 4445 | ((and (symbolp select) |
| 4446 | (assq select pr-ps-printer-alist)) |
| 4447 | (pr-menu-set-ps-title select)) |
| 4448 | ((integerp select) |
| 4449 | (and (/= select 1) |
| 4450 | (pr-ps-name)) |
| 4451 | (and (>= select 1) (not pr-spool-p) |
| 4452 | (setq filename (pr-ps-outfile-preprint |
| 4453 | (if pr-print-using-ghostscript |
| 4454 | "Fast GS " |
| 4455 | "Fast ")))))) |
| 4456 | (pr-ps-buffer-ps-print |
| 4457 | (if (integerp n-up) |
| 4458 | (min (max n-up 1) 100) |
| 4459 | (error "n-up must be an integer greater than zero")) |
| 4460 | filename))) |
| 4461 | |
| 4462 | |
| 4463 | ;;;###autoload |
| 4464 | (defun pr-txt-fast-fire (&optional select-printer) |
| 4465 | "Fast fire function for text printing. |
| 4466 | |
| 4467 | If a region is active, the region will be printed instead of the whole buffer. |
| 4468 | Also if the current major-mode is defined in `pr-mode-alist', the settings in |
| 4469 | `pr-mode-alist' will be used, that is, the current buffer or region will be |
| 4470 | printed using `pr-txt-mode'. |
| 4471 | |
| 4472 | Interactively, when you use a prefix argument (C-u), the command prompts the |
| 4473 | user for a new active text printer. |
| 4474 | |
| 4475 | Noninteractively, the argument SELECT-PRINTER is treated as follows: |
| 4476 | |
| 4477 | If it's nil, the printing is sent to the current active text printer. |
| 4478 | |
| 4479 | If it's a symbol which it's defined in `pr-txt-printer-alist', it's the new |
| 4480 | active printer and printing will immediatelly be done using the new active |
| 4481 | printer. |
| 4482 | |
| 4483 | If it's non-nil, the command prompts the user for a new active text printer. |
| 4484 | |
| 4485 | Note that this command always behaves as if `pr-auto-region' and `pr-auto-mode' |
| 4486 | are both set to t." |
| 4487 | (interactive (list current-prefix-arg)) |
| 4488 | (cond ((null select-printer)) |
| 4489 | ((and (symbolp select-printer) |
| 4490 | (assq select-printer pr-txt-printer-alist)) |
| 4491 | (pr-menu-set-txt-title select-printer)) |
| 4492 | (t |
| 4493 | (pr-txt-name))) |
| 4494 | (let ((pr-auto-region t) |
| 4495 | (pr-auto-mode t)) |
| 4496 | (pr-txt-buffer))) |
| 4497 | |
| 4498 | |
| 4499 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 4500 | ;; Utilities |
| 4501 | |
| 4502 | |
| 4503 | (defun pr-setup () |
| 4504 | "Return the current `printing' setup. |
| 4505 | |
| 4506 | This is *not* an interactive command. |
| 4507 | One way to see `printing' setup is to switch to a *Scratch* buffer and type: |
| 4508 | |
| 4509 | M-: (insert (pr-setup)) RET |
| 4510 | |
| 4511 | Or choose the menu option Printing/Show Settings/printing." |
| 4512 | (let (ps-prefix-quote) |
| 4513 | (mapconcat |
| 4514 | #'ps-print-quote |
| 4515 | (list |
| 4516 | (concat "\n;;; printing.el version " pr-version "\n") |
| 4517 | ";; internal vars" |
| 4518 | (ps-comment-string "emacs-version " emacs-version) |
| 4519 | (ps-comment-string "pr-txt-command " pr-txt-command) |
| 4520 | (ps-comment-string "pr-txt-switches " |
| 4521 | (pr-switches-string pr-txt-switches "pr-txt-switches")) |
| 4522 | (ps-comment-string "pr-txt-printer " pr-txt-printer) |
| 4523 | (ps-comment-string "pr-ps-command " pr-ps-command) |
| 4524 | (ps-comment-string "pr-ps-switches " |
| 4525 | (pr-switches-string pr-ps-switches "pr-ps-switches")) |
| 4526 | (ps-comment-string "pr-ps-printer-switch" pr-ps-printer-switch) |
| 4527 | (ps-comment-string "pr-ps-printer " pr-ps-printer) |
| 4528 | (ps-comment-string "pr-cygwin-system " pr-cygwin-system) |
| 4529 | (ps-comment-string "ps-windows-system " ps-windows-system) |
| 4530 | (ps-comment-string "ps-lp-system " ps-lp-system) |
| 4531 | nil |
| 4532 | '(14 . pr-path-style) |
| 4533 | '(14 . pr-path-alist) |
| 4534 | nil |
| 4535 | '(21 . pr-txt-name) |
| 4536 | '(21 . pr-txt-printer-alist) |
| 4537 | nil |
| 4538 | '(20 . pr-ps-name) |
| 4539 | '(20 . pr-ps-printer-alist) |
| 4540 | nil |
| 4541 | '(20 . pr-temp-dir) |
| 4542 | '(20 . pr-ps-temp-file) |
| 4543 | '(20 . pr-file-modes) |
| 4544 | '(20 . pr-delete-temp-file) |
| 4545 | '(20 . pr-list-directory) |
| 4546 | nil |
| 4547 | '(17 . pr-gv-command) |
| 4548 | '(17 . pr-gs-command) |
| 4549 | '(17 . pr-gs-switches) |
| 4550 | '(17 . pr-gs-device) |
| 4551 | '(17 . pr-gs-resolution) |
| 4552 | nil |
| 4553 | '(27 . pr-print-using-ghostscript) |
| 4554 | '(27 . pr-faces-p) |
| 4555 | '(27 . pr-spool-p) |
| 4556 | '(27 . pr-file-landscape) |
| 4557 | '(27 . pr-file-duplex) |
| 4558 | '(27 . pr-file-tumble) |
| 4559 | '(27 . pr-auto-region) |
| 4560 | '(27 . pr-auto-mode) |
| 4561 | nil |
| 4562 | '(20 . pr-ps-utility) |
| 4563 | '(20 . pr-ps-utility-alist) |
| 4564 | nil |
| 4565 | '(14 . pr-mode-alist) |
| 4566 | nil |
| 4567 | '(20 . pr-menu-lock) |
| 4568 | '(20 . pr-menu-char-height) |
| 4569 | '(20 . pr-menu-char-width) |
| 4570 | nil |
| 4571 | '(20 . pr-setting-database) |
| 4572 | nil |
| 4573 | '(22 . pr-visible-entry-list) |
| 4574 | nil |
| 4575 | '(22 . pr-buffer-verbose) |
| 4576 | '(22 . pr-buffer-name) |
| 4577 | '(22 . pr-buffer-name-ignore) |
| 4578 | ")\n\n;;; printing.el - end of settings\n") |
| 4579 | "\n"))) |
| 4580 | |
| 4581 | |
| 4582 | (defun lpr-setup () |
| 4583 | "Return the current `lpr' setup. |
| 4584 | |
| 4585 | This is *not* an interactive command. |
| 4586 | One way to see `lpr' setup is to switch to a *Scratch* buffer and type: |
| 4587 | |
| 4588 | M-: (insert (lpr-setup)) RET |
| 4589 | |
| 4590 | Or choose the menu option Printing/Show Settings/lpr." |
| 4591 | (let (ps-prefix-quote) |
| 4592 | (mapconcat |
| 4593 | #'ps-print-quote |
| 4594 | (list |
| 4595 | "\n;;; lpr.el settings\n" |
| 4596 | (ps-comment-string "emacs-version" emacs-version) |
| 4597 | nil |
| 4598 | '(25 . printer-name) |
| 4599 | '(25 . lpr-switches) |
| 4600 | '(25 . lpr-add-switches) |
| 4601 | '(25 . lpr-command) |
| 4602 | '(25 . lpr-headers-switches) |
| 4603 | '(25 . print-region-function) |
| 4604 | '(25 . lpr-page-header-program) |
| 4605 | '(25 . lpr-page-header-switches) |
| 4606 | ")\n\n;;; lpr.el - end of settings\n") |
| 4607 | "\n"))) |
| 4608 | |
| 4609 | |
| 4610 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 4611 | ;; mh-e (adapted from mh-e-init.el -- Tom Vogels <tov@ece.cmu.edu>) |
| 4612 | |
| 4613 | |
| 4614 | (defalias 'pr-mh-get-msg-num 'mh-get-msg-num) |
| 4615 | (defalias 'pr-mh-show 'mh-show) |
| 4616 | (defalias 'pr-mh-start-of-uncleaned-message 'mh-start-of-uncleaned-message) |
| 4617 | (defvar mh-show-buffer nil) |
| 4618 | |
| 4619 | |
| 4620 | (defun pr-article-date () |
| 4621 | "Find the date of an article or mail message in current buffer. |
| 4622 | Return only the dayname, if present, weekday, month, and year." |
| 4623 | (save-excursion |
| 4624 | (goto-char (point-min)) |
| 4625 | (if (re-search-forward |
| 4626 | "^Date:[ \t]+\\(\\([A-Za-z]+, \\)?[0-9]+ [A-Za-z]+ [0-9]+\\)" nil t) |
| 4627 | (buffer-substring (match-beginning 1) (match-end 1)) |
| 4628 | (format-time-string "%Y/%m/%d")))) |
| 4629 | |
| 4630 | |
| 4631 | (defun pr-mh-current-message () |
| 4632 | "Go to mh-inbox current message." |
| 4633 | (let ((msg (or (pr-mh-get-msg-num nil) 0))) |
| 4634 | (pr-mh-show) |
| 4635 | (set-buffer mh-show-buffer) |
| 4636 | (goto-char (point-min)) |
| 4637 | (pr-mh-start-of-uncleaned-message) |
| 4638 | (message "Printing message %d" msg))) |
| 4639 | |
| 4640 | |
| 4641 | (defun pr-mh-print-1 (n-up filename header-list) |
| 4642 | "Print mh-inbox current message in PostScript." |
| 4643 | (save-excursion |
| 4644 | (save-window-excursion |
| 4645 | (pr-mh-current-message) |
| 4646 | (pr-mode-print n-up filename header-list (point))))) |
| 4647 | |
| 4648 | |
| 4649 | (defun pr-mh-lpr-1 (header-list) |
| 4650 | "Print mh-inbox current message in text printer." |
| 4651 | (save-excursion |
| 4652 | (save-window-excursion |
| 4653 | (pr-mh-current-message) |
| 4654 | (pr-mode-lpr header-list (point))))) |
| 4655 | |
| 4656 | |
| 4657 | (defalias 'pr-mh-print-2 'pr-mode-print) |
| 4658 | |
| 4659 | |
| 4660 | (defalias 'pr-mh-lpr-2 'pr-mode-lpr) |
| 4661 | |
| 4662 | |
| 4663 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 4664 | ;; rmail (hacked from ps-print.el) |
| 4665 | |
| 4666 | |
| 4667 | (defun pr-rmail-lpr (header-list) |
| 4668 | "Print RMAIL current message in text printer." |
| 4669 | (pr-lpr-message-from-summary header-list |
| 4670 | 'rmail-buffer 'rmail-summary-buffer)) |
| 4671 | |
| 4672 | |
| 4673 | (defun pr-rmail-print (n-up filename header-list) |
| 4674 | "Print RMAIL current message in PostScript." |
| 4675 | (pr-ps-message-from-summary n-up filename header-list |
| 4676 | 'rmail-buffer 'rmail-summary-buffer)) |
| 4677 | |
| 4678 | |
| 4679 | (defun pr-ps-message-from-summary (n-up filename header-list |
| 4680 | summary-buffer summary-default) |
| 4681 | "Print current message in PostScript." |
| 4682 | (let ((buf (or (and (boundp summary-buffer) |
| 4683 | (symbol-value summary-buffer)) |
| 4684 | (symbol-value summary-default)))) |
| 4685 | (and (get-buffer buf) |
| 4686 | (save-excursion |
| 4687 | (set-buffer buf) |
| 4688 | (pr-mode-print n-up filename header-list))))) |
| 4689 | |
| 4690 | |
| 4691 | (defun pr-lpr-message-from-summary (header-list summary-buffer summary-default) |
| 4692 | "Print current message in text printer." |
| 4693 | (let ((buf (or (and (boundp summary-buffer) |
| 4694 | (symbol-value summary-buffer)) |
| 4695 | (symbol-value summary-default)))) |
| 4696 | (and (get-buffer buf) |
| 4697 | (save-excursion |
| 4698 | (set-buffer buf) |
| 4699 | (pr-mode-lpr header-list))))) |
| 4700 | |
| 4701 | |
| 4702 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 4703 | ;; gnus (hacked from ps-print.el) |
| 4704 | |
| 4705 | |
| 4706 | (defvar pr-gnus-article "*Article*") |
| 4707 | |
| 4708 | |
| 4709 | (defun pr-gnus-print (n-up filename header-list) |
| 4710 | "Print *Article* current message in PostScript." |
| 4711 | (pr-ps-message-from-summary n-up filename header-list |
| 4712 | 'gnus-article-buffer 'pr-gnus-article)) |
| 4713 | |
| 4714 | |
| 4715 | (defun pr-gnus-lpr (header-list) |
| 4716 | "Print *Article* current message in text printer." |
| 4717 | (pr-lpr-message-from-summary header-list |
| 4718 | 'gnus-article-buffer 'pr-gnus-article)) |
| 4719 | |
| 4720 | |
| 4721 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 4722 | ;; vm (hacked from ps-print.el) |
| 4723 | |
| 4724 | |
| 4725 | (defvar pr-vm-summary "") |
| 4726 | |
| 4727 | |
| 4728 | (defun pr-vm-print (n-up filename header-list) |
| 4729 | "Print current vm message in PostScript." |
| 4730 | (pr-ps-message-from-summary n-up filename header-list |
| 4731 | 'vm-mail-buffer 'pr-vm-summary)) |
| 4732 | |
| 4733 | |
| 4734 | (defun pr-vm-lpr (header-list) |
| 4735 | "Print current vm message in text printer." |
| 4736 | (pr-lpr-message-from-summary header-list |
| 4737 | 'vm-mail-buffer 'pr-vm-summary)) |
| 4738 | |
| 4739 | |
| 4740 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 4741 | ;; Mode Functions |
| 4742 | |
| 4743 | |
| 4744 | (defun pr-ps-mode (n-up filename) |
| 4745 | "If current major mode is declared, print it in PostScript." |
| 4746 | (let ((args (pr-mode-alist-p))) |
| 4747 | (if args |
| 4748 | (let ((fun (cdr args))) |
| 4749 | (funcall (car fun) n-up filename (cdr fun)) |
| 4750 | t) |
| 4751 | (ding) |
| 4752 | (message "`%s' major mode not declared." major-mode) |
| 4753 | nil))) |
| 4754 | |
| 4755 | |
| 4756 | (defmacro pr-local-variable (header-list &rest body) |
| 4757 | `(save-excursion |
| 4758 | (let ((ps-header-lines (or (nth 0 ,header-list) ps-header-lines)) |
| 4759 | (ps-left-header (or (nth 1 ,header-list) ps-left-header)) |
| 4760 | (ps-right-header (or (nth 2 ,header-list) ps-right-header)) |
| 4761 | ps-razzle-dazzle) |
| 4762 | (let ((local-var-list (pr-eval-local-alist (nthcdr 4 ,header-list)))) |
| 4763 | ,@body |
| 4764 | (and (nth 3 ,header-list) |
| 4765 | (pr-kill-local-variable local-var-list)))))) |
| 4766 | |
| 4767 | |
| 4768 | (defun pr-mode-print (n-up filename header-list &optional from to) |
| 4769 | "Print current major mode in PostScript." |
| 4770 | (pr-local-variable |
| 4771 | header-list |
| 4772 | (let ((file (pr-ps-file filename)) |
| 4773 | (start (cond (from) |
| 4774 | ((pr-region-active-p) (region-beginning)) |
| 4775 | (t nil) |
| 4776 | ))) |
| 4777 | (pr-text2ps (pr-region-active-symbol start) n-up file start |
| 4778 | (cond (to) |
| 4779 | ((pr-region-active-p) (region-end)) |
| 4780 | (from (point-max)) |
| 4781 | )) |
| 4782 | (unless (or pr-spool-p filename) |
| 4783 | (pr-ps-file-print file) |
| 4784 | (pr-delete-file file))))) |
| 4785 | |
| 4786 | |
| 4787 | (defun pr-mode-lpr (header-list &optional from to) |
| 4788 | "Print current major mode in text printer." |
| 4789 | (pr-local-variable |
| 4790 | header-list |
| 4791 | (pr-txt-print (cond (from) |
| 4792 | ((pr-region-active-p) (region-beginning)) |
| 4793 | (t (point-min))) |
| 4794 | (cond (to) |
| 4795 | ((pr-region-active-p) (region-end)) |
| 4796 | (t (point-max)))))) |
| 4797 | |
| 4798 | |
| 4799 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 4800 | ;; Menu Lock |
| 4801 | |
| 4802 | |
| 4803 | (defconst pr-menu-entry-alist |
| 4804 | '((postscript . 3) |
| 4805 | (text . 3) |
| 4806 | (postscript-options . 9) |
| 4807 | (postscript-process . 3) |
| 4808 | (printing . 3) |
| 4809 | (help . 3) |
| 4810 | ) |
| 4811 | "Alist that associates menu part with number of items per part. |
| 4812 | |
| 4813 | It's used by `pr-menu-index'. |
| 4814 | |
| 4815 | Each element has the form: |
| 4816 | |
| 4817 | (MENU-PART . NUMBER-OF-ITEMS) |
| 4818 | |
| 4819 | See `pr-visible-entry-alist'.") |
| 4820 | |
| 4821 | |
| 4822 | (defun pr-menu-index (entry index) |
| 4823 | (let ((base-list |
| 4824 | (cond ((eq entry 'text) |
| 4825 | '(postscript)) |
| 4826 | ((eq entry 'postscript-options) |
| 4827 | '(postscript text)) |
| 4828 | ((eq entry 'postscript-process) |
| 4829 | '(postscript text postscript-options)) |
| 4830 | ((eq entry 'printing) |
| 4831 | '(postscript text postscript-options postscript-process)) |
| 4832 | (t |
| 4833 | nil) |
| 4834 | )) |
| 4835 | key) |
| 4836 | (while base-list |
| 4837 | (setq key (car base-list) |
| 4838 | base-list (cdr base-list)) |
| 4839 | (and (pr-visible-p key) |
| 4840 | (setq index (+ index |
| 4841 | (cdr (assq key pr-menu-entry-alist))))))) |
| 4842 | (+ index 2)) |
| 4843 | |
| 4844 | |
| 4845 | (defvar pr-menu-position nil) |
| 4846 | (defvar pr-menu-state nil) |
| 4847 | |
| 4848 | |
| 4849 | (cond |
| 4850 | ((featurep 'xemacs) |
| 4851 | ;; XEmacs |
| 4852 | (defvar current-mouse-event nil) ; to avoid compilation gripes |
| 4853 | (defun pr-menu-position (entry index horizontal) |
| 4854 | (pr-x-make-event |
| 4855 | 'button-release |
| 4856 | (list 'button 1 |
| 4857 | 'x (- (pr-x-event-x-pixel current-mouse-event) ; X |
| 4858 | (* horizontal pr-menu-char-width)) |
| 4859 | 'y (- (pr-x-event-y-pixel current-mouse-event) ; Y |
| 4860 | (* (pr-menu-index entry index) pr-menu-char-height))))) |
| 4861 | ) |
| 4862 | (ps-windows-system |
| 4863 | ;; GNU Emacs for Windows 9x/NT |
| 4864 | (defun pr-menu-position (entry index horizontal) |
| 4865 | (let ((pos (cdr (pr-e-mouse-pixel-position)))) |
| 4866 | (list |
| 4867 | (list (or (car pos) 0) ; X |
| 4868 | (- (or (cdr pos) 0) ; Y |
| 4869 | (* (pr-menu-index entry index) pr-menu-char-height))) |
| 4870 | (selected-frame)))) ; frame |
| 4871 | ) |
| 4872 | (t |
| 4873 | ;; GNU Emacs |
| 4874 | (defun pr-menu-position (entry index horizontal) |
| 4875 | (let ((pos (cdr (pr-e-mouse-pixel-position)))) |
| 4876 | (list |
| 4877 | (list (- (or (car pos) 0) ; X |
| 4878 | (* horizontal pr-menu-char-width)) |
| 4879 | (- (or (cdr pos) 0) ; Y |
| 4880 | (* (pr-menu-index entry index) pr-menu-char-height))) |
| 4881 | (selected-frame)))) ; frame |
| 4882 | )) |
| 4883 | |
| 4884 | (cond |
| 4885 | ((featurep 'xemacs) |
| 4886 | ;; XEmacs |
| 4887 | (defvar current-menubar nil) ; to avoid compilation gripes |
| 4888 | (defun pr-menu-lookup (path) |
| 4889 | (car (pr-x-find-menu-item current-menubar (cons "Printing" path)))) |
| 4890 | |
| 4891 | ;; XEmacs |
| 4892 | (defun pr-menu-lock (entry index horizontal state path) |
| 4893 | (when pr-menu-lock |
| 4894 | (or (and pr-menu-position (eq state pr-menu-state)) |
| 4895 | (setq pr-menu-position (pr-menu-position entry index horizontal) |
| 4896 | pr-menu-state state)) |
| 4897 | (let* ((menu (pr-menu-lookup path)) |
| 4898 | (result (pr-x-get-popup-menu-response menu pr-menu-position))) |
| 4899 | (and (pr-x-misc-user-event-p result) |
| 4900 | (funcall (pr-x-event-function result) |
| 4901 | (pr-x-event-object result)))) |
| 4902 | (setq pr-menu-position nil)))) |
| 4903 | |
| 4904 | |
| 4905 | (t |
| 4906 | ;; GNU Emacs |
| 4907 | (defun pr-menu-lookup (path) |
| 4908 | (lookup-key global-map |
| 4909 | (if path |
| 4910 | (vconcat pr-menu-bar |
| 4911 | (mapcar 'pr-get-symbol |
| 4912 | (if (listp path) |
| 4913 | path |
| 4914 | (list path)))) |
| 4915 | pr-menu-bar))) |
| 4916 | |
| 4917 | ;; GNU Emacs |
| 4918 | (defun pr-menu-lock (entry index horizontal state path) |
| 4919 | (when pr-menu-lock |
| 4920 | (or (and pr-menu-position (eq state pr-menu-state)) |
| 4921 | (setq pr-menu-position (pr-menu-position entry index horizontal) |
| 4922 | pr-menu-state state)) |
| 4923 | (let* ((menu (pr-menu-lookup path)) |
| 4924 | (result (x-popup-menu pr-menu-position menu))) |
| 4925 | (and result |
| 4926 | (let ((command (lookup-key menu (vconcat result)))) |
| 4927 | (if (fboundp command) |
| 4928 | (funcall command) |
| 4929 | (eval command))))) |
| 4930 | (setq pr-menu-position nil))))) |
| 4931 | |
| 4932 | |
| 4933 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 4934 | ;; Printer & Utility Selection |
| 4935 | |
| 4936 | |
| 4937 | (defun pr-update-var (var-sym alist) |
| 4938 | (or (assq (symbol-value var-sym) alist) |
| 4939 | (set var-sym (car (car alist))))) |
| 4940 | |
| 4941 | |
| 4942 | (defun pr-update-menus (&optional force) |
| 4943 | "Update utility, PostScript and text printer menus. |
| 4944 | |
| 4945 | If FORCE is non-nil, update menus doesn't matter if `pr-ps-printer-alist', |
| 4946 | `pr-txt-printer-alist' or `pr-ps-utility-alist' were modified or not; |
| 4947 | otherwise, update PostScript printer menu iff `pr-ps-printer-menu-modified' is |
| 4948 | non-nil, update text printer menu iff `pr-txt-printer-menu-modified' is |
| 4949 | non-nil, and update PostScript File menus iff `pr-ps-utility-menu-modified' is |
| 4950 | non-nil. |
| 4951 | |
| 4952 | If menu binding was not done, calls `pr-menu-bind'." |
| 4953 | (interactive "P") |
| 4954 | (if pr-menu-print-item ; since v6.8.4 |
| 4955 | ;; There was no menu binding yet, so do it now! |
| 4956 | ;; This is a hack to be compatible with old versions of printing. |
| 4957 | ;; So, user does not need to change printing calling in init files. |
| 4958 | (pr-menu-bind) |
| 4959 | ;; Here menu binding is ok. |
| 4960 | (pr-update-var 'pr-ps-name pr-ps-printer-alist) |
| 4961 | (pr-update-var 'pr-txt-name pr-txt-printer-alist) |
| 4962 | (pr-update-var 'pr-ps-utility pr-ps-utility-alist) |
| 4963 | (pr-do-update-menus force))) |
| 4964 | |
| 4965 | |
| 4966 | (defvar pr-ps-printer-menu-modified t |
| 4967 | "Non-nil means `pr-ps-printer-alist' was modified and we need to update menu.") |
| 4968 | (defvar pr-txt-printer-menu-modified t |
| 4969 | "Non-nil means `pr-txt-printer-alist' was modified and we need to update menu.") |
| 4970 | (defvar pr-ps-utility-menu-modified t |
| 4971 | "Non-nil means `pr-ps-utility-alist' was modified and we need to update menu.") |
| 4972 | |
| 4973 | |
| 4974 | (defconst pr-even-or-odd-alist |
| 4975 | '((nil . "Print All Pages") |
| 4976 | (even-page . "Print Even Pages") |
| 4977 | (odd-page . "Print Odd Pages") |
| 4978 | (even-sheet . "Print Even Sheets") |
| 4979 | (odd-sheet . "Print Odd Sheets"))) |
| 4980 | |
| 4981 | |
| 4982 | (defun pr-menu-create (name alist var-sym fun entry index) |
| 4983 | (cons name |
| 4984 | (mapcar |
| 4985 | #'(lambda (elt) |
| 4986 | (let ((sym (car elt))) |
| 4987 | (vector |
| 4988 | (symbol-name sym) |
| 4989 | (list fun (list 'quote sym) nil (list 'quote entry) index) |
| 4990 | :style 'radio |
| 4991 | :selected (list 'eq var-sym (list 'quote sym))))) |
| 4992 | alist))) |
| 4993 | |
| 4994 | |
| 4995 | (cond |
| 4996 | ((featurep 'xemacs) |
| 4997 | ;; XEmacs |
| 4998 | (defalias 'pr-update-mode-line 'set-menubar-dirty-flag) |
| 4999 | |
| 5000 | ;; XEmacs |
| 5001 | (defvar pr-ps-name-old "PostScript Printers") |
| 5002 | (defvar pr-txt-name-old "Text Printers") |
| 5003 | (defvar pr-ps-utility-old "PostScript Utility") |
| 5004 | (defvar pr-even-or-odd-old "Print All Pages") |
| 5005 | |
| 5006 | ;; XEmacs |
| 5007 | (defun pr-do-update-menus (&optional force) |
| 5008 | (pr-menu-alist pr-ps-printer-alist |
| 5009 | 'pr-ps-name |
| 5010 | 'pr-menu-set-ps-title |
| 5011 | '("Printing") |
| 5012 | 'pr-ps-printer-menu-modified |
| 5013 | force |
| 5014 | pr-ps-name-old |
| 5015 | 'postscript 2) |
| 5016 | (pr-menu-alist pr-txt-printer-alist |
| 5017 | 'pr-txt-name |
| 5018 | 'pr-menu-set-txt-title |
| 5019 | '("Printing") |
| 5020 | 'pr-txt-printer-menu-modified |
| 5021 | force |
| 5022 | pr-txt-name-old |
| 5023 | 'text 2) |
| 5024 | (let ((save-var pr-ps-utility-menu-modified)) |
| 5025 | (pr-menu-alist pr-ps-utility-alist |
| 5026 | 'pr-ps-utility |
| 5027 | 'pr-menu-set-utility-title |
| 5028 | '("Printing" "PostScript Print" "File") |
| 5029 | 'save-var |
| 5030 | force |
| 5031 | pr-ps-utility-old |
| 5032 | nil 1)) |
| 5033 | (pr-menu-alist pr-ps-utility-alist |
| 5034 | 'pr-ps-utility |
| 5035 | 'pr-menu-set-utility-title |
| 5036 | '("Printing" "PostScript Preview" "File") |
| 5037 | 'pr-ps-utility-menu-modified |
| 5038 | force |
| 5039 | pr-ps-utility-old |
| 5040 | nil 1) |
| 5041 | (pr-even-or-odd-pages ps-even-or-odd-pages force)) |
| 5042 | |
| 5043 | ;; XEmacs |
| 5044 | (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name |
| 5045 | entry index) |
| 5046 | (when (and alist (or force (symbol-value modified-sym))) |
| 5047 | (pr-xemacs-global-menubar |
| 5048 | (pr-x-add-submenu menu-path |
| 5049 | (pr-menu-create name alist var-sym |
| 5050 | fun entry index))) |
| 5051 | (funcall fun (symbol-value var-sym)) |
| 5052 | (set modified-sym nil))) |
| 5053 | |
| 5054 | ;; XEmacs |
| 5055 | (defun pr-relabel-menu-item (newname var-sym) |
| 5056 | (pr-xemacs-global-menubar |
| 5057 | (pr-x-relabel-menu-item |
| 5058 | (list "Printing" (symbol-value var-sym)) |
| 5059 | newname) |
| 5060 | (set var-sym newname))) |
| 5061 | |
| 5062 | ;; XEmacs |
| 5063 | (defun pr-menu-set-ps-title (value &optional item entry index) |
| 5064 | (pr-relabel-menu-item (format "PostScript Printer: %s" value) |
| 5065 | 'pr-ps-name-old) |
| 5066 | (pr-ps-set-printer value) |
| 5067 | (and index |
| 5068 | (pr-menu-lock entry index 12 'toggle nil))) |
| 5069 | |
| 5070 | ;; XEmacs |
| 5071 | (defun pr-menu-set-txt-title (value &optional item entry index) |
| 5072 | (pr-relabel-menu-item (format "Text Printer: %s" value) |
| 5073 | 'pr-txt-name-old) |
| 5074 | (pr-txt-set-printer value) |
| 5075 | (and index |
| 5076 | (pr-menu-lock entry index 12 'toggle nil))) |
| 5077 | |
| 5078 | ;; XEmacs |
| 5079 | (defun pr-menu-set-utility-title (value &optional item entry index) |
| 5080 | (pr-xemacs-global-menubar |
| 5081 | (let ((newname (format "%s" value))) |
| 5082 | (pr-x-relabel-menu-item |
| 5083 | (list "Printing" "PostScript Print" "File" pr-ps-utility-old) |
| 5084 | newname) |
| 5085 | (pr-x-relabel-menu-item |
| 5086 | (list "Printing" "PostScript Preview" "File" pr-ps-utility-old) |
| 5087 | newname) |
| 5088 | (setq pr-ps-utility-old newname))) |
| 5089 | (pr-ps-set-utility value) |
| 5090 | (and index |
| 5091 | (pr-menu-lock entry index 5 nil '("PostScript Print" "File")))) |
| 5092 | |
| 5093 | ;; XEmacs |
| 5094 | (defun pr-even-or-odd-pages (value &optional no-lock) |
| 5095 | (pr-relabel-menu-item (cdr (assq value pr-even-or-odd-alist)) |
| 5096 | 'pr-even-or-odd-old) |
| 5097 | (setq ps-even-or-odd-pages value) |
| 5098 | (or no-lock |
| 5099 | (pr-menu-lock 'postscript-options 8 12 'toggle nil)))) |
| 5100 | |
| 5101 | |
| 5102 | (t |
| 5103 | ;; GNU Emacs |
| 5104 | (defalias 'pr-update-mode-line 'force-mode-line-update) |
| 5105 | |
| 5106 | ;; GNU Emacs |
| 5107 | (defun pr-do-update-menus (&optional force) |
| 5108 | (pr-menu-alist pr-ps-printer-alist |
| 5109 | 'pr-ps-name |
| 5110 | 'pr-menu-set-ps-title |
| 5111 | "PostScript Printers" |
| 5112 | 'pr-ps-printer-menu-modified |
| 5113 | force |
| 5114 | "PostScript Printers" |
| 5115 | 'postscript 2) |
| 5116 | (pr-menu-alist pr-txt-printer-alist |
| 5117 | 'pr-txt-name |
| 5118 | 'pr-menu-set-txt-title |
| 5119 | "Text Printers" |
| 5120 | 'pr-txt-printer-menu-modified |
| 5121 | force |
| 5122 | "Text Printers" |
| 5123 | 'text 2) |
| 5124 | (let ((save-var pr-ps-utility-menu-modified)) |
| 5125 | (pr-menu-alist pr-ps-utility-alist |
| 5126 | 'pr-ps-utility |
| 5127 | 'pr-menu-set-utility-title |
| 5128 | '("PostScript Print" "File" "PostScript Utility") |
| 5129 | 'save-var |
| 5130 | force |
| 5131 | "PostScript Utility" |
| 5132 | nil 1)) |
| 5133 | (pr-menu-alist pr-ps-utility-alist |
| 5134 | 'pr-ps-utility |
| 5135 | 'pr-menu-set-utility-title |
| 5136 | '("PostScript Preview" "File" "PostScript Utility") |
| 5137 | 'pr-ps-utility-menu-modified |
| 5138 | force |
| 5139 | "PostScript Utility" |
| 5140 | nil 1) |
| 5141 | (pr-even-or-odd-pages ps-even-or-odd-pages force)) |
| 5142 | |
| 5143 | ;; GNU Emacs |
| 5144 | (defun pr-menu-get-item (name-list) |
| 5145 | ;; NAME-LIST is a string or a list of strings. |
| 5146 | (or (listp name-list) |
| 5147 | (setq name-list (list name-list))) |
| 5148 | (and name-list |
| 5149 | (let* ((reversed (reverse name-list)) |
| 5150 | (name (pr-get-symbol (car reversed))) |
| 5151 | (path (nreverse (cdr reversed))) |
| 5152 | (menu (lookup-key |
| 5153 | global-map |
| 5154 | (vconcat pr-menu-bar |
| 5155 | (mapcar 'pr-get-symbol path))))) |
| 5156 | (assq name (nthcdr 2 menu))))) |
| 5157 | |
| 5158 | ;; GNU Emacs |
| 5159 | (defvar pr-temp-menu nil) |
| 5160 | |
| 5161 | ;; GNU Emacs |
| 5162 | (defun pr-menu-alist (alist var-sym fun menu-path modified-sym force name |
| 5163 | entry index) |
| 5164 | (when (and alist (or force (symbol-value modified-sym))) |
| 5165 | (easy-menu-define pr-temp-menu nil "" |
| 5166 | (pr-menu-create name alist var-sym fun entry index)) |
| 5167 | (let ((item (pr-menu-get-item menu-path))) |
| 5168 | (and item |
| 5169 | (let* ((binding (nthcdr 3 item)) |
| 5170 | (key-binding (cdr binding))) |
| 5171 | (setcar binding pr-temp-menu) |
| 5172 | (and key-binding (listp (car key-binding)) |
| 5173 | (setcdr binding (cdr key-binding))) ; skip KEY-BINDING |
| 5174 | (funcall fun (symbol-value var-sym) item)))) |
| 5175 | (set modified-sym nil))) |
| 5176 | |
| 5177 | ;; GNU Emacs |
| 5178 | (defun pr-menu-set-item-name (item name) |
| 5179 | (and item |
| 5180 | (setcar (nthcdr 2 item) name))) ; ITEM-NAME |
| 5181 | |
| 5182 | ;; GNU Emacs |
| 5183 | (defun pr-menu-set-ps-title (value &optional item entry index) |
| 5184 | (pr-menu-set-item-name (or item |
| 5185 | (pr-menu-get-item "PostScript Printers")) |
| 5186 | (format "PostScript Printer: %s" value)) |
| 5187 | (pr-ps-set-printer value) |
| 5188 | (and index |
| 5189 | (pr-menu-lock entry index 12 'toggle nil))) |
| 5190 | |
| 5191 | ;; GNU Emacs |
| 5192 | (defun pr-menu-set-txt-title (value &optional item entry index) |
| 5193 | (pr-menu-set-item-name (or item |
| 5194 | (pr-menu-get-item "Text Printers")) |
| 5195 | (format "Text Printer: %s" value)) |
| 5196 | (pr-txt-set-printer value) |
| 5197 | (and index |
| 5198 | (pr-menu-lock entry index 12 'toggle nil))) |
| 5199 | |
| 5200 | ;; GNU Emacs |
| 5201 | (defun pr-menu-set-utility-title (value &optional item entry index) |
| 5202 | (let ((name (symbol-name value))) |
| 5203 | (if item |
| 5204 | (pr-menu-set-item-name item name) |
| 5205 | (pr-menu-set-item-name |
| 5206 | (pr-menu-get-item |
| 5207 | '("PostScript Print" "File" "PostScript Utility")) |
| 5208 | name) |
| 5209 | (pr-menu-set-item-name |
| 5210 | (pr-menu-get-item |
| 5211 | '("PostScript Preview" "File" "PostScript Utility")) |
| 5212 | name))) |
| 5213 | (pr-ps-set-utility value) |
| 5214 | (and index |
| 5215 | (pr-menu-lock entry index 5 nil '("PostScript Print" "File")))) |
| 5216 | |
| 5217 | ;; GNU Emacs |
| 5218 | (defun pr-even-or-odd-pages (value &optional no-lock) |
| 5219 | (pr-menu-set-item-name (pr-menu-get-item "Print All Pages") |
| 5220 | (cdr (assq value pr-even-or-odd-alist))) |
| 5221 | (setq ps-even-or-odd-pages value) |
| 5222 | (or no-lock |
| 5223 | (pr-menu-lock 'postscript-options 8 12 'toggle nil))))) |
| 5224 | |
| 5225 | |
| 5226 | (defun pr-ps-set-utility (value) |
| 5227 | (let ((item (cdr (assq value pr-ps-utility-alist)))) |
| 5228 | (or item |
| 5229 | (error |
| 5230 | "Invalid PostScript utility name `%s' for variable `pr-ps-utility'" |
| 5231 | value)) |
| 5232 | (setq pr-ps-utility value) |
| 5233 | (pr-eval-alist (nthcdr 9 item))) |
| 5234 | (pr-update-mode-line)) |
| 5235 | |
| 5236 | |
| 5237 | (defun pr-ps-set-printer (value) |
| 5238 | (let ((ps (cdr (assq value pr-ps-printer-alist)))) |
| 5239 | (or ps |
| 5240 | (error |
| 5241 | "Invalid PostScript printer name `%s' for variable `pr-ps-name'" |
| 5242 | value)) |
| 5243 | (setq pr-ps-name value |
| 5244 | pr-ps-command (pr-dosify-file-name (nth 0 ps)) |
| 5245 | pr-ps-switches (nth 1 ps) |
| 5246 | pr-ps-printer-switch (nth 2 ps) |
| 5247 | pr-ps-printer (nth 3 ps)) |
| 5248 | (or (stringp pr-ps-command) |
| 5249 | (setq pr-ps-command |
| 5250 | (cond (ps-windows-system "print") |
| 5251 | (ps-lp-system "lp") |
| 5252 | (t "lpr") |
| 5253 | ))) |
| 5254 | (or (stringp pr-ps-printer-switch) |
| 5255 | (setq pr-ps-printer-switch |
| 5256 | (cond (ps-windows-system "/D:") |
| 5257 | (ps-lp-system "-d") |
| 5258 | (t "-P") |
| 5259 | ))) |
| 5260 | (pr-eval-alist (nthcdr 4 ps))) |
| 5261 | (pr-update-mode-line)) |
| 5262 | |
| 5263 | |
| 5264 | (defun pr-txt-set-printer (value) |
| 5265 | (let ((txt (cdr (assq value pr-txt-printer-alist)))) |
| 5266 | (or txt |
| 5267 | (error "Invalid text printer name `%s' for variable `pr-txt-name'" |
| 5268 | value)) |
| 5269 | (setq pr-txt-name value |
| 5270 | pr-txt-command (pr-dosify-file-name (nth 0 txt)) |
| 5271 | pr-txt-switches (nth 1 txt) |
| 5272 | pr-txt-printer (nth 2 txt))) |
| 5273 | (or (stringp pr-txt-command) |
| 5274 | (setq pr-txt-command |
| 5275 | (cond (ps-windows-system "print") |
| 5276 | (ps-lp-system "lp") |
| 5277 | (t "lpr") |
| 5278 | ))) |
| 5279 | (pr-update-mode-line)) |
| 5280 | |
| 5281 | |
| 5282 | (defun pr-eval-alist (alist) |
| 5283 | (mapcar #'(lambda (option) |
| 5284 | (let ((var-sym (car option)) |
| 5285 | (value (cdr option))) |
| 5286 | (if (eq var-sym 'inherits-from:) |
| 5287 | (pr-eval-setting-alist value 'global) |
| 5288 | (set var-sym (eval value))))) |
| 5289 | alist)) |
| 5290 | |
| 5291 | |
| 5292 | (defun pr-eval-local-alist (alist) |
| 5293 | (let (local-list) |
| 5294 | (mapcar #'(lambda (option) |
| 5295 | (let ((var-sym (car option)) |
| 5296 | (value (cdr option))) |
| 5297 | (setq local-list |
| 5298 | (if (eq var-sym 'inherits-from:) |
| 5299 | (nconc (pr-eval-setting-alist value) local-list) |
| 5300 | (set (make-local-variable var-sym) (eval value)) |
| 5301 | (cons var-sym local-list))))) |
| 5302 | alist) |
| 5303 | local-list)) |
| 5304 | |
| 5305 | |
| 5306 | (defun pr-eval-setting-alist (key &optional global old) |
| 5307 | (let ((setting (cdr (assq key pr-setting-database)))) |
| 5308 | (and setting |
| 5309 | (let ((inherits (nth 0 setting)) |
| 5310 | (local (nth 1 setting)) |
| 5311 | (kill (nth 2 setting)) |
| 5312 | local-list) |
| 5313 | (and local global |
| 5314 | (progn |
| 5315 | (ding) |
| 5316 | (message "There are local buffer settings for `%S'." key) |
| 5317 | (setq global nil))) |
| 5318 | (and inherits |
| 5319 | (if (memq inherits old) |
| 5320 | (error "Circular inheritance for `%S'" inherits) |
| 5321 | (setq local-list |
| 5322 | (pr-eval-setting-alist inherits global |
| 5323 | (cons inherits old))))) |
| 5324 | (mapcar |
| 5325 | (cond ((not local) ; global settings |
| 5326 | #'(lambda (option) |
| 5327 | (let ((var-sym (car option))) |
| 5328 | (or (eq var-sym 'inherits-from:) |
| 5329 | (set var-sym (eval (cdr option))))))) |
| 5330 | (kill ; local settings with killing |
| 5331 | #'(lambda (option) |
| 5332 | (let ((var-sym (car option))) |
| 5333 | (unless (eq var-sym 'inherits-from:) |
| 5334 | (setq local-list (cons var-sym local-list)) |
| 5335 | (set (make-local-variable var-sym) |
| 5336 | (eval (cdr option))))))) |
| 5337 | (t ; local settings without killing |
| 5338 | #'(lambda (option) |
| 5339 | (let ((var-sym (car option))) |
| 5340 | (or (eq var-sym 'inherits-from:) |
| 5341 | (set (make-local-variable var-sym) |
| 5342 | (eval (cdr option)))))))) |
| 5343 | (nthcdr 3 setting)) |
| 5344 | local-list)))) |
| 5345 | |
| 5346 | |
| 5347 | (defun pr-kill-local-variable (local-var-list) |
| 5348 | (mapcar 'kill-local-variable local-var-list)) |
| 5349 | |
| 5350 | |
| 5351 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 5352 | ;; Internal Functions (II) |
| 5353 | |
| 5354 | |
| 5355 | (defun pr-toggle (var-sym mess entry index horizontal state |
| 5356 | &optional path no-menu) |
| 5357 | (set var-sym (not (symbol-value var-sym))) |
| 5358 | (message "%s is %s" mess (if (symbol-value var-sym) "on" "off")) |
| 5359 | (or no-menu |
| 5360 | (pr-menu-lock entry index horizontal state path))) |
| 5361 | |
| 5362 | |
| 5363 | (defun pr-toggle-file-duplex-menu (&optional no-menu) |
| 5364 | (interactive) |
| 5365 | (pr-toggle 'pr-file-duplex "PS file duplex" nil 7 5 nil |
| 5366 | '("PostScript Print" "File") no-menu)) |
| 5367 | |
| 5368 | |
| 5369 | (defun pr-toggle-file-tumble-menu (&optional no-menu) |
| 5370 | (interactive) |
| 5371 | (pr-toggle 'pr-file-tumble "PS file tumble" nil 8 5 nil |
| 5372 | '("PostScript Print" "File") no-menu)) |
| 5373 | |
| 5374 | |
| 5375 | (defun pr-toggle-file-landscape-menu (&optional no-menu) |
| 5376 | (interactive) |
| 5377 | (pr-toggle 'pr-file-landscape "PS file landscape" nil 6 5 nil |
| 5378 | '("PostScript Print" "File") no-menu)) |
| 5379 | |
| 5380 | |
| 5381 | (defun pr-toggle-ghostscript-menu (&optional no-menu) |
| 5382 | (interactive) |
| 5383 | (pr-toggle 'pr-print-using-ghostscript "Printing using ghostscript" |
| 5384 | 'postscript-process 2 12 'toggle nil no-menu)) |
| 5385 | |
| 5386 | |
| 5387 | (defun pr-toggle-faces-menu (&optional no-menu) |
| 5388 | (interactive) |
| 5389 | (pr-toggle 'pr-faces-p "Printing with faces" |
| 5390 | 'postscript-process 1 12 'toggle nil no-menu)) |
| 5391 | |
| 5392 | |
| 5393 | (defun pr-toggle-spool-menu (&optional no-menu) |
| 5394 | (interactive) |
| 5395 | (pr-toggle 'pr-spool-p "Spooling printing" |
| 5396 | 'postscript-process 0 12 'toggle nil no-menu)) |
| 5397 | |
| 5398 | |
| 5399 | (defun pr-toggle-duplex-menu (&optional no-menu) |
| 5400 | (interactive) |
| 5401 | (pr-toggle 'ps-spool-duplex "Printing duplex" |
| 5402 | 'postscript-options 5 12 'toggle nil no-menu)) |
| 5403 | |
| 5404 | |
| 5405 | (defun pr-toggle-tumble-menu (&optional no-menu) |
| 5406 | (interactive) |
| 5407 | (pr-toggle 'ps-spool-tumble "Tumble" |
| 5408 | 'postscript-options 6 12 'toggle nil no-menu)) |
| 5409 | |
| 5410 | |
| 5411 | (defun pr-toggle-landscape-menu (&optional no-menu) |
| 5412 | (interactive) |
| 5413 | (pr-toggle 'ps-landscape-mode "Landscape" |
| 5414 | 'postscript-options 0 12 'toggle nil no-menu)) |
| 5415 | |
| 5416 | |
| 5417 | (defun pr-toggle-upside-down-menu (&optional no-menu) |
| 5418 | (interactive) |
| 5419 | (pr-toggle 'ps-print-upside-down "Upside-Down" |
| 5420 | 'postscript-options 7 12 'toggle nil no-menu)) |
| 5421 | |
| 5422 | |
| 5423 | (defun pr-toggle-line-menu (&optional no-menu) |
| 5424 | (interactive) |
| 5425 | (pr-toggle 'ps-line-number "Line number" |
| 5426 | 'postscript-options 3 12 'toggle nil no-menu)) |
| 5427 | |
| 5428 | |
| 5429 | (defun pr-toggle-zebra-menu (&optional no-menu) |
| 5430 | (interactive) |
| 5431 | (pr-toggle 'ps-zebra-stripes "Zebra stripe" |
| 5432 | 'postscript-options 4 12 'toggle nil no-menu)) |
| 5433 | |
| 5434 | |
| 5435 | (defun pr-toggle-header-menu (&optional no-menu) |
| 5436 | (interactive) |
| 5437 | (pr-toggle 'ps-print-header "Print header" |
| 5438 | 'postscript-options 1 12 'toggle nil no-menu)) |
| 5439 | |
| 5440 | |
| 5441 | (defun pr-toggle-header-frame-menu (&optional no-menu) |
| 5442 | (interactive) |
| 5443 | (pr-toggle 'ps-print-header-frame "Print header frame" |
| 5444 | 'postscript-options 2 12 'toggle nil no-menu)) |
| 5445 | |
| 5446 | |
| 5447 | (defun pr-toggle-lock-menu (&optional no-menu) |
| 5448 | (interactive) |
| 5449 | (pr-toggle 'pr-menu-lock "Menu lock" |
| 5450 | 'printing 2 12 'toggle nil no-menu)) |
| 5451 | |
| 5452 | |
| 5453 | (defun pr-toggle-region-menu (&optional no-menu) |
| 5454 | (interactive) |
| 5455 | (pr-toggle 'pr-auto-region "Auto region" |
| 5456 | 'printing 0 12 'toggle nil no-menu)) |
| 5457 | |
| 5458 | |
| 5459 | (defun pr-toggle-mode-menu (&optional no-menu) |
| 5460 | (interactive) |
| 5461 | (pr-toggle 'pr-auto-mode "Auto mode" |
| 5462 | 'printing 1 12 'toggle nil no-menu)) |
| 5463 | |
| 5464 | |
| 5465 | (defun pr-prompt (str) |
| 5466 | (if (pr-auto-mode-p) |
| 5467 | (concat str " mode") |
| 5468 | (pr-region-active-string str))) |
| 5469 | |
| 5470 | |
| 5471 | (defun pr-prompt-region (str) |
| 5472 | (concat str (if (pr-auto-mode-p) |
| 5473 | " mode" |
| 5474 | " region"))) |
| 5475 | |
| 5476 | |
| 5477 | (defun pr-prompt-gs (str) |
| 5478 | (if (pr-using-ghostscript-p) |
| 5479 | (concat str " GS") |
| 5480 | str)) |
| 5481 | |
| 5482 | |
| 5483 | (defun pr-region-active-symbol (&optional region-p) |
| 5484 | (if (or region-p (pr-region-active-p)) |
| 5485 | 'region |
| 5486 | 'buffer)) |
| 5487 | |
| 5488 | |
| 5489 | (defun pr-region-active-string (prefix) |
| 5490 | (concat prefix |
| 5491 | (if (pr-region-active-p) |
| 5492 | " region" |
| 5493 | " buffer"))) |
| 5494 | |
| 5495 | |
| 5496 | (defun pr-show-setup (settings buffer-name) |
| 5497 | (with-output-to-temp-buffer buffer-name |
| 5498 | (princ settings) |
| 5499 | (print-help-return-message))) |
| 5500 | |
| 5501 | |
| 5502 | (defun pr-complete-alist (prompt alist default) |
| 5503 | (let ((collection (mapcar #'(lambda (elt) |
| 5504 | (setq elt (car elt)) |
| 5505 | (cons (symbol-name elt) elt)) |
| 5506 | alist))) |
| 5507 | (cdr (assoc (completing-read (concat prompt ": ") |
| 5508 | collection nil t |
| 5509 | (symbol-name default) nil |
| 5510 | (symbol-name default)) |
| 5511 | collection)))) |
| 5512 | |
| 5513 | |
| 5514 | (defun pr-delete-file (file) |
| 5515 | (and pr-delete-temp-file (file-exists-p file) |
| 5516 | (delete-file file))) |
| 5517 | |
| 5518 | |
| 5519 | (defun pr-expand-file-name (filename) |
| 5520 | (pr-dosify-file-name (expand-file-name filename))) |
| 5521 | |
| 5522 | |
| 5523 | (defun pr-ps-outfile-preprint (&optional mess) |
| 5524 | (let* ((prompt (format "%soutput PostScript file name: " (or mess ""))) |
| 5525 | (res (read-file-name prompt default-directory "" nil))) |
| 5526 | (while (cond ((not (file-writable-p res)) |
| 5527 | (ding) |
| 5528 | (setq prompt "is unwritable")) |
| 5529 | ((file-directory-p res) |
| 5530 | (ding) |
| 5531 | (setq prompt "is a directory")) |
| 5532 | ((file-exists-p res) |
| 5533 | (ding) |
| 5534 | (setq prompt "exists") |
| 5535 | (not (y-or-n-p (format "File `%s' exists; overwrite? " |
| 5536 | res)))) |
| 5537 | (t nil)) |
| 5538 | (setq res (read-file-name |
| 5539 | (format "File %s; PostScript file: " prompt) |
| 5540 | (file-name-directory res) nil nil |
| 5541 | (file-name-nondirectory res)))) |
| 5542 | (pr-expand-file-name res))) |
| 5543 | |
| 5544 | |
| 5545 | (defun pr-ps-infile-preprint (&optional mess) |
| 5546 | (let* ((prompt (format "%sinput PostScript file name: " (or mess ""))) |
| 5547 | (res (read-file-name prompt default-directory "" nil))) |
| 5548 | (while (cond ((not (file-exists-p res)) |
| 5549 | (ding) |
| 5550 | (setq prompt "doesn't exist")) |
| 5551 | ((not (file-readable-p res)) |
| 5552 | (ding) |
| 5553 | (setq prompt "is unreadable")) |
| 5554 | ((file-directory-p res) |
| 5555 | (ding) |
| 5556 | (setq prompt "is a directory")) |
| 5557 | (t nil)) |
| 5558 | (setq res (read-file-name |
| 5559 | (format "File %s; PostScript file: " prompt) |
| 5560 | (file-name-directory res) nil nil |
| 5561 | (file-name-nondirectory res)))) |
| 5562 | (pr-expand-file-name res))) |
| 5563 | |
| 5564 | |
| 5565 | (defun pr-ps-utility-args (n-up-sym infile-sym outfile-sym prompt) |
| 5566 | ;; check arguments for PostScript file processing. |
| 5567 | ;; n-up |
| 5568 | (or (symbol-value n-up-sym) |
| 5569 | (set n-up-sym (pr-interactive-n-up prompt))) |
| 5570 | ;; input file |
| 5571 | (and (eq (symbol-value infile-sym) t) |
| 5572 | (set infile-sym (pr-ps-infile-preprint prompt))) |
| 5573 | (or (symbol-value infile-sym) |
| 5574 | (error "%s: input PostScript file name is missing" prompt)) |
| 5575 | (set infile-sym (pr-dosify-file-name (symbol-value infile-sym))) |
| 5576 | ;; output file |
| 5577 | (and (eq (symbol-value outfile-sym) t) |
| 5578 | (set outfile-sym (and current-prefix-arg |
| 5579 | (pr-ps-outfile-preprint prompt)))) |
| 5580 | (and (symbol-value outfile-sym) |
| 5581 | (set outfile-sym (pr-dosify-file-name (symbol-value outfile-sym)))) |
| 5582 | (pr-ps-file (symbol-value outfile-sym))) |
| 5583 | |
| 5584 | |
| 5585 | (defun pr-ps-utility-process (n-up infile outfile) |
| 5586 | ;; activate utility to process a PostScript file. |
| 5587 | (let (item) |
| 5588 | (and (stringp infile) (file-exists-p infile) |
| 5589 | (setq item (cdr (assq pr-ps-utility pr-ps-utility-alist))) |
| 5590 | (pr-call-process (nth 0 item) |
| 5591 | (pr-switches-string (nth 1 item) |
| 5592 | "pr-ps-utility-alist entry") |
| 5593 | (pr-switches-string (nth 8 item) |
| 5594 | "pr-ps-utility-alist entry") |
| 5595 | (and (nth 2 item) |
| 5596 | (format (nth 2 item) ps-paper-type)) |
| 5597 | (format (nth 3 item) n-up) |
| 5598 | (and pr-file-landscape (nth 4 item)) |
| 5599 | (and pr-file-duplex (nth 5 item)) |
| 5600 | (and pr-file-tumble (nth 6 item)) |
| 5601 | (pr-expand-file-name infile) |
| 5602 | (nth 7 item) |
| 5603 | (pr-expand-file-name outfile))))) |
| 5604 | |
| 5605 | |
| 5606 | (defun pr-remove-nil-from-list (lst) |
| 5607 | (while (and lst (null (car lst))) |
| 5608 | (setq lst (cdr lst))) |
| 5609 | (let ((b lst) |
| 5610 | (l (cdr lst))) |
| 5611 | (while l |
| 5612 | (if (car l) |
| 5613 | (setq b l |
| 5614 | l (cdr l)) |
| 5615 | (setq l (cdr l)) |
| 5616 | (setcdr b l)))) |
| 5617 | lst) |
| 5618 | |
| 5619 | |
| 5620 | (defun pr-call-process (command &rest args) |
| 5621 | (let ((buffer (get-buffer-create "*Printing Command Output*")) |
| 5622 | (cmd (pr-command command)) |
| 5623 | status) |
| 5624 | (setq args (pr-remove-nil-from-list args)) |
| 5625 | ;; *Printing Command Output* == show command & args |
| 5626 | (save-excursion |
| 5627 | (set-buffer buffer) |
| 5628 | (goto-char (point-max)) |
| 5629 | (insert (format "%s %S\n" cmd args))) |
| 5630 | ;; *Printing Command Output* == show any return message from command |
| 5631 | (pr-save-file-modes |
| 5632 | (setq status |
| 5633 | (condition-case data |
| 5634 | (apply 'call-process cmd nil buffer nil args) |
| 5635 | ((quit error) |
| 5636 | (error-message-string data))))) |
| 5637 | ;; *Printing Command Output* == show exit status |
| 5638 | (save-excursion |
| 5639 | (set-buffer buffer) |
| 5640 | (goto-char (point-max)) |
| 5641 | (insert (format "Exit status: %s\n\n" status))) |
| 5642 | ;; message if error status |
| 5643 | (if (or (stringp status) |
| 5644 | (and (integerp status) (/= status 0))) |
| 5645 | (message |
| 5646 | "Printing error status: %s (see *Printing Command Output* buffer)" |
| 5647 | status)))) |
| 5648 | |
| 5649 | |
| 5650 | (defun pr-txt-print (from to) |
| 5651 | (let ((lpr-command (pr-standard-file-name (pr-command pr-txt-command))) |
| 5652 | (lpr-switches (pr-switches pr-txt-switches "pr-txt-switches")) |
| 5653 | (printer-name pr-txt-printer)) |
| 5654 | (lpr-region from to))) |
| 5655 | |
| 5656 | |
| 5657 | (defun pr-switches-string (switches mess) |
| 5658 | ;; If SWITCHES is nil, return nil. |
| 5659 | ;; Otherwise, return the list of string in a string. |
| 5660 | (and switches |
| 5661 | (mapconcat 'identity (pr-switches switches mess) " "))) |
| 5662 | |
| 5663 | |
| 5664 | (defun pr-switches (switches mess) |
| 5665 | (or (listp switches) |
| 5666 | (error "%S should have a list of strings" mess)) |
| 5667 | (ps-flatten-list ; dynamic evaluation |
| 5668 | (mapcar 'ps-eval-switch switches))) |
| 5669 | |
| 5670 | |
| 5671 | (defun pr-ps-preview (kind n-up filename mess) |
| 5672 | (pr-set-n-up-and-filename 'n-up 'filename mess) |
| 5673 | (let ((file (pr-ps-file filename))) |
| 5674 | (pr-text2ps kind n-up file) |
| 5675 | (or pr-spool-p (pr-ps-file-preview file)))) |
| 5676 | |
| 5677 | |
| 5678 | (defun pr-ps-using-ghostscript (kind n-up filename mess) |
| 5679 | (pr-set-n-up-and-filename 'n-up 'filename mess) |
| 5680 | (let ((file (pr-ps-file filename))) |
| 5681 | (pr-text2ps kind n-up file) |
| 5682 | (unless (or pr-spool-p filename) |
| 5683 | (pr-ps-file-using-ghostscript file) |
| 5684 | (pr-delete-file file)))) |
| 5685 | |
| 5686 | |
| 5687 | (defun pr-ps-print (kind n-up filename mess) |
| 5688 | (pr-set-n-up-and-filename 'n-up 'filename mess) |
| 5689 | (let ((file (pr-ps-file filename))) |
| 5690 | (pr-text2ps kind n-up file) |
| 5691 | (unless (or pr-spool-p filename) |
| 5692 | (pr-ps-file-print file) |
| 5693 | (pr-delete-file file)))) |
| 5694 | |
| 5695 | |
| 5696 | (defun pr-ps-file (&optional filename) |
| 5697 | (pr-dosify-file-name (or filename |
| 5698 | (make-temp-file |
| 5699 | (convert-standard-filename |
| 5700 | (expand-file-name pr-ps-temp-file pr-temp-dir)) |
| 5701 | nil ".ps")))) |
| 5702 | |
| 5703 | |
| 5704 | (defun pr-interactive-n-up (mess) |
| 5705 | (or (stringp mess) (setq mess "*")) |
| 5706 | (save-match-data |
| 5707 | (let* ((fmt-prompt "%s[%s] N-up printing: (default 1) ") |
| 5708 | (prompt "") |
| 5709 | (str (pr-f-read-string (format fmt-prompt prompt mess) "1" nil "1")) |
| 5710 | int) |
| 5711 | (while (if (string-match "^\\s *[0-9]+$" str) |
| 5712 | (setq int (string-to-number str) |
| 5713 | prompt (cond ((< int 1) "Integer below 1; ") |
| 5714 | ((> int 100) "Integer above 100; ") |
| 5715 | (t nil))) |
| 5716 | (setq prompt "Invalid integer syntax; ")) |
| 5717 | (ding) |
| 5718 | (setq str |
| 5719 | (pr-f-read-string (format fmt-prompt prompt mess) str nil "1"))) |
| 5720 | int))) |
| 5721 | |
| 5722 | |
| 5723 | (defun pr-interactive-dir (mess) |
| 5724 | (let* ((dir-name (file-name-directory (or (buffer-file-name) |
| 5725 | default-directory))) |
| 5726 | (fmt-prompt (concat "%s[" mess "] Directory to print: ")) |
| 5727 | (dir (read-file-name (format fmt-prompt "") |
| 5728 | "" dir-name nil dir-name)) |
| 5729 | prompt) |
| 5730 | (while (cond ((not (file-directory-p dir)) |
| 5731 | (ding) |
| 5732 | (setq prompt "It's not a directory! ")) |
| 5733 | ((not (file-readable-p dir)) |
| 5734 | (ding) |
| 5735 | (setq prompt "Directory is unreadable! ")) |
| 5736 | (t nil)) |
| 5737 | (setq dir-name (file-name-directory dir) |
| 5738 | dir (read-file-name (format fmt-prompt prompt) |
| 5739 | "" dir-name nil dir-name))) |
| 5740 | (file-name-as-directory dir))) |
| 5741 | |
| 5742 | |
| 5743 | (defun pr-interactive-regexp (mess) |
| 5744 | (pr-f-read-string (format "[%s] File regexp to print: " mess) "" nil "")) |
| 5745 | |
| 5746 | |
| 5747 | (defun pr-interactive-dir-args (mess) |
| 5748 | (list |
| 5749 | ;; get directory argument |
| 5750 | (pr-interactive-dir mess) |
| 5751 | ;; get file name regexp |
| 5752 | (pr-interactive-regexp mess))) |
| 5753 | |
| 5754 | |
| 5755 | (defun pr-interactive-ps-dir-args (mess) |
| 5756 | (list |
| 5757 | ;; get n-up argument |
| 5758 | (pr-interactive-n-up mess) |
| 5759 | ;; get directory argument |
| 5760 | (pr-interactive-dir mess) |
| 5761 | ;; get file name regexp |
| 5762 | (pr-interactive-regexp mess) |
| 5763 | ;; get output file name |
| 5764 | (and (not pr-spool-p) |
| 5765 | (ps-print-preprint current-prefix-arg)))) |
| 5766 | |
| 5767 | |
| 5768 | (defun pr-interactive-n-up-file (mess) |
| 5769 | (list |
| 5770 | ;; get n-up argument |
| 5771 | (pr-interactive-n-up mess) |
| 5772 | ;; get output file name |
| 5773 | (and (not pr-spool-p) |
| 5774 | (ps-print-preprint current-prefix-arg)))) |
| 5775 | |
| 5776 | |
| 5777 | (defun pr-interactive-n-up-inout (mess) |
| 5778 | (list |
| 5779 | ;; get n-up argument |
| 5780 | (pr-interactive-n-up mess) |
| 5781 | ;; get input file name |
| 5782 | (pr-ps-infile-preprint (concat mess " ")) |
| 5783 | ;; get output file name |
| 5784 | (ps-print-preprint current-prefix-arg))) |
| 5785 | |
| 5786 | |
| 5787 | (defun pr-set-outfilename (filename-sym) |
| 5788 | (and (not pr-spool-p) |
| 5789 | (eq (symbol-value filename-sym) t) |
| 5790 | (set filename-sym (and current-prefix-arg |
| 5791 | (ps-print-preprint current-prefix-arg)))) |
| 5792 | (and (symbol-value filename-sym) |
| 5793 | (set filename-sym (pr-dosify-file-name (symbol-value filename-sym))))) |
| 5794 | |
| 5795 | |
| 5796 | (defun pr-set-n-up-and-filename (n-up-sym filename-sym mess) |
| 5797 | ;; n-up |
| 5798 | (or (symbol-value n-up-sym) |
| 5799 | (set n-up-sym (pr-interactive-n-up mess))) |
| 5800 | ;; output file |
| 5801 | (pr-set-outfilename filename-sym)) |
| 5802 | |
| 5803 | |
| 5804 | (defun pr-set-dir-args (dir-sym regexp-sym mess) |
| 5805 | ;; directory |
| 5806 | (or (symbol-value dir-sym) |
| 5807 | (set dir-sym (pr-interactive-dir mess))) |
| 5808 | ;; file name regexp |
| 5809 | (or (symbol-value regexp-sym) |
| 5810 | (set regexp-sym (pr-interactive-regexp mess)))) |
| 5811 | |
| 5812 | |
| 5813 | (defun pr-set-ps-dir-args (n-up-sym dir-sym regexp-sym filename-sym mess) |
| 5814 | ;; n-up |
| 5815 | (or (symbol-value n-up-sym) |
| 5816 | (set n-up-sym (pr-interactive-n-up mess))) |
| 5817 | ;; directory & file name regexp |
| 5818 | (pr-set-dir-args dir-sym regexp-sym mess) |
| 5819 | ;; output file |
| 5820 | (pr-set-outfilename filename-sym)) |
| 5821 | |
| 5822 | |
| 5823 | (defun pr-find-buffer-visiting (file) |
| 5824 | (if (not (file-directory-p file)) |
| 5825 | (find-buffer-visiting (if ps-windows-system |
| 5826 | (downcase file) |
| 5827 | file)) |
| 5828 | (let ((truename (file-truename file)) |
| 5829 | (blist (buffer-list)) |
| 5830 | found) |
| 5831 | (while (and (not found) blist) |
| 5832 | (save-excursion |
| 5833 | (set-buffer (car blist)) |
| 5834 | (and (eq major-mode 'dired-mode) |
| 5835 | (save-excursion |
| 5836 | (goto-char (point-min)) |
| 5837 | (string= (buffer-substring-no-properties |
| 5838 | (+ (point-min) 2) |
| 5839 | (progn |
| 5840 | (end-of-line) |
| 5841 | (1- (point)))) |
| 5842 | truename)) |
| 5843 | (setq found (car blist)))) |
| 5844 | (setq blist (cdr blist))) |
| 5845 | found))) |
| 5846 | |
| 5847 | |
| 5848 | (defun pr-file-list (dir file-regexp fun) |
| 5849 | (mapcar #'(lambda (file) |
| 5850 | (and (or pr-list-directory |
| 5851 | (not (file-directory-p file))) |
| 5852 | (let ((buffer (pr-find-buffer-visiting file)) |
| 5853 | pop-up-windows |
| 5854 | pop-up-frames) |
| 5855 | (and (or buffer |
| 5856 | (file-readable-p file)) |
| 5857 | (save-excursion |
| 5858 | (set-buffer (or buffer |
| 5859 | (find-file-noselect file))) |
| 5860 | (funcall fun) |
| 5861 | (or buffer |
| 5862 | (kill-buffer (current-buffer)))))))) |
| 5863 | (directory-files dir t file-regexp))) |
| 5864 | |
| 5865 | |
| 5866 | (defun pr-delete-file-if-exists (filename) |
| 5867 | (and (not pr-spool-p) (stringp filename) (file-exists-p filename) |
| 5868 | (delete-file filename))) |
| 5869 | |
| 5870 | |
| 5871 | (defun pr-ps-file-list (n-up dir file-regexp filename) |
| 5872 | (pr-delete-file-if-exists (setq filename (pr-expand-file-name filename))) |
| 5873 | (let ((pr-spool-p t)) |
| 5874 | (pr-file-list dir file-regexp |
| 5875 | #'(lambda () |
| 5876 | (if (pr-auto-mode-p) |
| 5877 | (pr-ps-mode n-up filename) |
| 5878 | (pr-text2ps 'buffer n-up filename))))) |
| 5879 | (or pr-spool-p |
| 5880 | (pr-despool-print filename))) |
| 5881 | |
| 5882 | |
| 5883 | (defun pr-text2ps (kind n-up filename &optional from to) |
| 5884 | (pr-save-file-modes |
| 5885 | (let ((ps-n-up-printing n-up) |
| 5886 | (ps-spool-config (and (eq ps-spool-config 'setpagedevice) |
| 5887 | 'setpagedevice))) |
| 5888 | (pr-delete-file-if-exists filename) |
| 5889 | (cond (pr-faces-p |
| 5890 | (cond (pr-spool-p |
| 5891 | ;; pr-faces-p and pr-spool-p |
| 5892 | ;; here FILENAME arg is ignored |
| 5893 | (cond ((eq kind 'buffer) |
| 5894 | (ps-spool-buffer-with-faces)) |
| 5895 | ((eq kind 'region) |
| 5896 | (ps-spool-region-with-faces (or from (point)) |
| 5897 | (or to (mark)))) |
| 5898 | )) |
| 5899 | ;; pr-faces-p and not pr-spool-p |
| 5900 | ((eq kind 'buffer) |
| 5901 | (ps-print-buffer-with-faces filename)) |
| 5902 | ((eq kind 'region) |
| 5903 | (ps-print-region-with-faces (or from (point)) |
| 5904 | (or to (mark)) filename)) |
| 5905 | )) |
| 5906 | (pr-spool-p |
| 5907 | ;; not pr-faces-p and pr-spool-p |
| 5908 | ;; here FILENAME arg is ignored |
| 5909 | (cond ((eq kind 'buffer) |
| 5910 | (ps-spool-buffer)) |
| 5911 | ((eq kind 'region) |
| 5912 | (ps-spool-region (or from (point)) (or to (mark)))) |
| 5913 | )) |
| 5914 | ;; not pr-faces-p and not pr-spool-p |
| 5915 | ((eq kind 'buffer) |
| 5916 | (ps-print-buffer filename)) |
| 5917 | ((eq kind 'region) |
| 5918 | (ps-print-region (or from (point)) (or to (mark)) filename)) |
| 5919 | )))) |
| 5920 | |
| 5921 | |
| 5922 | (defun pr-command (command) |
| 5923 | "Return absolute file name specification for COMMAND. |
| 5924 | |
| 5925 | If COMMAND is an empty string, return it. |
| 5926 | |
| 5927 | If COMMAND is already an absolute file name specification, return it. |
| 5928 | Else it uses `pr-path-alist' to find COMMAND, if find it then return it; |
| 5929 | otherwise, gives an error. |
| 5930 | |
| 5931 | When using `pr-path-alist' to find COMMAND, the entries `cygwin', `windows' and |
| 5932 | `unix' are used (see `pr-path-alist' for documentation). |
| 5933 | |
| 5934 | If Emacs is running on Windows 95/98/NT/2000, tries to find COMMAND, |
| 5935 | COMMAND.exe, COMMAND.bat and COMMAND.com in this order." |
| 5936 | (if (string= command "") |
| 5937 | command |
| 5938 | (pr-dosify-file-name |
| 5939 | (or (pr-find-command command) |
| 5940 | (pr-path-command (cond (pr-cygwin-system 'cygwin) |
| 5941 | (ps-windows-system 'windows) |
| 5942 | (t 'unix)) |
| 5943 | (file-name-nondirectory command) |
| 5944 | nil) |
| 5945 | (error "Command not found: %s" |
| 5946 | (file-name-nondirectory command)))))) |
| 5947 | |
| 5948 | |
| 5949 | (defun pr-path-command (symbol command sym-list) |
| 5950 | (let ((lpath (cdr (assq symbol pr-path-alist))) |
| 5951 | cmd) |
| 5952 | ;; PATH expansion |
| 5953 | (and (eq symbol 'PATH) (null lpath) |
| 5954 | (setq lpath (parse-colon-path (getenv "PATH")))) |
| 5955 | (while (and lpath |
| 5956 | (not |
| 5957 | (setq cmd |
| 5958 | (let ((path (car lpath))) |
| 5959 | (cond |
| 5960 | ;; symbol expansion |
| 5961 | ((symbolp path) |
| 5962 | (and (not (memq path sym-list)) |
| 5963 | (pr-path-command path command |
| 5964 | (cons path sym-list)))) |
| 5965 | ;; normal path |
| 5966 | ((stringp path) |
| 5967 | (pr-find-command |
| 5968 | (expand-file-name |
| 5969 | (substitute-in-file-name |
| 5970 | (concat (file-name-as-directory path) |
| 5971 | command))))) |
| 5972 | ))))) |
| 5973 | (setq lpath (cdr lpath))) |
| 5974 | cmd)) |
| 5975 | |
| 5976 | |
| 5977 | (defun pr-find-command (cmd) |
| 5978 | (if ps-windows-system |
| 5979 | ;; windows system |
| 5980 | (let ((ext (cons (file-name-extension cmd t) |
| 5981 | (list ".exe" ".bat" ".com"))) |
| 5982 | found) |
| 5983 | (setq cmd (file-name-sans-extension cmd)) |
| 5984 | (while (and ext |
| 5985 | (setq found (concat cmd (car ext))) |
| 5986 | (not (and (file-regular-p found) |
| 5987 | (file-executable-p found)))) |
| 5988 | (setq ext (cdr ext) |
| 5989 | found nil)) |
| 5990 | found) |
| 5991 | ;; non-windows systems |
| 5992 | (and (file-regular-p cmd) |
| 5993 | (file-executable-p cmd) |
| 5994 | cmd))) |
| 5995 | |
| 5996 | |
| 5997 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 5998 | ;; Printing Interface (inspired on ps-print-interface.el) |
| 5999 | |
| 6000 | |
| 6001 | (require 'widget) |
| 6002 | (require 'wid-edit) |
| 6003 | (require 'cus-edit) |
| 6004 | |
| 6005 | |
| 6006 | (defvar pr-i-window-configuration nil) |
| 6007 | |
| 6008 | (defvar pr-i-buffer nil) |
| 6009 | (defvar pr-i-region nil) |
| 6010 | (defvar pr-i-mode nil) |
| 6011 | (defvar pr-i-despool nil) |
| 6012 | (defvar pr-i-ps-as-is t) |
| 6013 | (defvar pr-i-n-up 1) |
| 6014 | (defvar pr-i-directory "./") |
| 6015 | (defvar pr-i-regexp "") |
| 6016 | (defvar pr-i-ps-file "") |
| 6017 | (defvar pr-i-out-file "") |
| 6018 | (defvar pr-i-answer-yes nil) |
| 6019 | (defvar pr-i-process 'buffer) |
| 6020 | (defvar pr-i-ps-send 'printer) |
| 6021 | |
| 6022 | |
| 6023 | (defvar pr-interface-map nil |
| 6024 | "Keymap for pr-interface.") |
| 6025 | |
| 6026 | (unless pr-interface-map |
| 6027 | (setq pr-interface-map (make-sparse-keymap)) |
| 6028 | (cond ((featurep 'xemacs) ; XEmacs |
| 6029 | (pr-f-set-keymap-parents pr-interface-map (list widget-keymap)) |
| 6030 | (pr-f-set-keymap-name pr-interface-map 'pr-interface-map)) |
| 6031 | (t ; GNU Emacs |
| 6032 | (pr-f-set-keymap-parents pr-interface-map widget-keymap))) |
| 6033 | (define-key pr-interface-map "q" 'pr-interface-quit) |
| 6034 | (define-key pr-interface-map "?" 'pr-interface-help)) |
| 6035 | |
| 6036 | |
| 6037 | (defmacro pr-interface-save (&rest body) |
| 6038 | `(save-excursion |
| 6039 | (set-buffer pr-i-buffer) |
| 6040 | ,@body)) |
| 6041 | |
| 6042 | |
| 6043 | (defun pr-create-interface () |
| 6044 | "Create the front end for printing package." |
| 6045 | (setq pr-i-buffer (buffer-name (current-buffer)) |
| 6046 | pr-i-region (ps-mark-active-p) |
| 6047 | pr-i-mode (pr-mode-alist-p) |
| 6048 | pr-i-window-configuration (current-window-configuration)) |
| 6049 | |
| 6050 | (put 'pr-i-process 'pr-widget-list nil) |
| 6051 | (put 'pr-i-ps-send 'pr-widget-list nil) |
| 6052 | |
| 6053 | (delete-other-windows) |
| 6054 | (kill-buffer (get-buffer-create pr-buffer-name)) |
| 6055 | (switch-to-buffer (get-buffer-create pr-buffer-name)) |
| 6056 | |
| 6057 | ;; header |
| 6058 | (let ((versions (concat "printing v" pr-version |
| 6059 | " ps-print v" ps-print-version))) |
| 6060 | (widget-insert (make-string (- 79 (length versions)) ?\s) versions)) |
| 6061 | (pr-insert-italic "\nCurrent Directory : " 1) |
| 6062 | (pr-insert-italic default-directory) |
| 6063 | |
| 6064 | (pr-insert-section-1) ; 1. Print |
| 6065 | (pr-insert-section-2) ; 2. PostScript Printer |
| 6066 | (pr-insert-section-3) ; 3. Text Printer |
| 6067 | |
| 6068 | ;; separator |
| 6069 | (widget-insert "\n\n " (make-string 77 ?-)) |
| 6070 | |
| 6071 | (pr-insert-section-4) ; 4. Settings |
| 6072 | (pr-insert-section-5) ; 5. Customize |
| 6073 | (pr-insert-section-6) ; 6. Show Settings |
| 6074 | (pr-insert-section-7) ; 7. Help |
| 6075 | |
| 6076 | (use-local-map pr-interface-map) |
| 6077 | (widget-setup) |
| 6078 | (goto-char (point-min)) |
| 6079 | |
| 6080 | (and pr-i-region ; let region activated |
| 6081 | (pr-keep-region-active))) |
| 6082 | |
| 6083 | |
| 6084 | (defun pr-insert-section-1 () |
| 6085 | ;; 1. Print: |
| 6086 | (pr-insert-italic "\nPrint :" 1) |
| 6087 | |
| 6088 | ;; 1a. Buffer: |
| 6089 | ;; 1a. Buffer: Buffer List |
| 6090 | (pr-insert-radio-button 'pr-i-process 'buffer) |
| 6091 | (pr-insert-menu "Buffer List" 'pr-i-buffer |
| 6092 | (let ((blist (buffer-list)) |
| 6093 | case-fold-search choices) |
| 6094 | (while blist |
| 6095 | (let ((name (buffer-name (car blist))) |
| 6096 | (ignore pr-buffer-name-ignore) |
| 6097 | found) |
| 6098 | (setq blist (cdr blist)) |
| 6099 | (while (and ignore (not found)) |
| 6100 | (setq found (string-match (car ignore) name) |
| 6101 | ignore (cdr ignore))) |
| 6102 | (or found |
| 6103 | (setq choices |
| 6104 | (cons (list 'quote |
| 6105 | (list 'choice-item |
| 6106 | :format "%[%t%]" |
| 6107 | name)) |
| 6108 | choices))))) |
| 6109 | (nreverse choices)) |
| 6110 | " Buffer : " nil |
| 6111 | '(progn |
| 6112 | (pr-interface-save |
| 6113 | (setq pr-i-region (ps-mark-active-p) |
| 6114 | pr-i-mode (pr-mode-alist-p))) |
| 6115 | (pr-update-checkbox 'pr-i-region) |
| 6116 | (pr-update-checkbox 'pr-i-mode))) |
| 6117 | ;; 1a. Buffer: Region |
| 6118 | (put 'pr-i-region 'pr-widget |
| 6119 | (pr-insert-checkbox |
| 6120 | "\n " |
| 6121 | 'pr-i-region |
| 6122 | #'(lambda (widget &rest ignore) |
| 6123 | (let ((region-p (pr-interface-save |
| 6124 | (ps-mark-active-p)))) |
| 6125 | (cond ((null (widget-value widget)) ; widget is nil |
| 6126 | (setq pr-i-region nil)) |
| 6127 | (region-p ; widget is true and there is a region |
| 6128 | (setq pr-i-region t) |
| 6129 | (widget-value-set widget t) |
| 6130 | (widget-setup)) ; MUST be called after widget-value-set |
| 6131 | (t ; widget is true and there is no region |
| 6132 | (ding) |
| 6133 | (message "There is no region active") |
| 6134 | (setq pr-i-region nil) |
| 6135 | (widget-value-set widget nil) |
| 6136 | (widget-setup))))) ; MUST be called after widget-value-set |
| 6137 | " Region")) |
| 6138 | ;; 1a. Buffer: Mode |
| 6139 | (put 'pr-i-mode 'pr-widget |
| 6140 | (pr-insert-checkbox |
| 6141 | " " |
| 6142 | 'pr-i-mode |
| 6143 | #'(lambda (widget &rest ignore) |
| 6144 | (let ((mode-p (pr-interface-save |
| 6145 | (pr-mode-alist-p)))) |
| 6146 | (cond |
| 6147 | ((null (widget-value widget)) ; widget is nil |
| 6148 | (setq pr-i-mode nil)) |
| 6149 | (mode-p ; widget is true and there is a `mode' |
| 6150 | (setq pr-i-mode t) |
| 6151 | (widget-value-set widget t) |
| 6152 | (widget-setup)) ; MUST be called after widget-value-set |
| 6153 | (t ; widget is true and there is no `mode' |
| 6154 | (ding) |
| 6155 | (message |
| 6156 | "This buffer isn't in a mode that printing treats specially.") |
| 6157 | (setq pr-i-mode nil) |
| 6158 | (widget-value-set widget nil) |
| 6159 | (widget-setup))))) ; MUST be called after widget-value-set |
| 6160 | " Mode\n")) |
| 6161 | |
| 6162 | ;; 1b. Directory: |
| 6163 | (pr-insert-radio-button 'pr-i-process 'directory) |
| 6164 | (widget-create |
| 6165 | 'directory |
| 6166 | :size 58 |
| 6167 | :format " Directory : %v" |
| 6168 | :notify 'pr-interface-directory |
| 6169 | :action (lambda (widget &optional event) |
| 6170 | (if (pr-interface-directory widget) |
| 6171 | (pr-widget-field-action widget event) |
| 6172 | (ding) |
| 6173 | (message "Please specify a readable directory"))) |
| 6174 | pr-i-directory) |
| 6175 | ;; 1b. Directory: File Regexp |
| 6176 | (widget-create 'regexp |
| 6177 | :size 58 |
| 6178 | :format "\n File Regexp : %v\n" |
| 6179 | :notify (lambda (widget &rest ignore) |
| 6180 | (setq pr-i-regexp (widget-value widget))) |
| 6181 | pr-i-regexp) |
| 6182 | ;; 1b. Directory: List Directory Entry |
| 6183 | (widget-insert " ") |
| 6184 | (pr-insert-toggle 'pr-list-directory " List Directory Entry\n") |
| 6185 | |
| 6186 | ;; 1c. PostScript File: |
| 6187 | (pr-insert-radio-button 'pr-i-process 'file) |
| 6188 | (widget-create |
| 6189 | 'file |
| 6190 | :size 51 |
| 6191 | :format " PostScript File : %v" |
| 6192 | :notify 'pr-interface-infile |
| 6193 | :action (lambda (widget &rest event) |
| 6194 | (if (pr-interface-infile widget) |
| 6195 | (pr-widget-field-action widget event) |
| 6196 | (ding) |
| 6197 | (message "Please specify a readable PostScript file"))) |
| 6198 | pr-i-ps-file) |
| 6199 | ;; 1c. PostScript File: PostScript Utility |
| 6200 | (pr-insert-menu "PostScript Utility" 'pr-ps-utility |
| 6201 | (pr-choice-alist pr-ps-utility-alist) |
| 6202 | "\n PostScript Utility : " |
| 6203 | " ") |
| 6204 | ;; 1c. PostScript File: No Preprocessing |
| 6205 | (pr-insert-toggle 'pr-i-ps-as-is " No Preprocessing")) |
| 6206 | |
| 6207 | |
| 6208 | (defun pr-insert-section-2 () |
| 6209 | ;; 2. PostScript Printer: |
| 6210 | ;; 2. PostScript Printer: PostScript Printer List |
| 6211 | (pr-insert-italic "\n\nPostScript Printer : " 2 20) |
| 6212 | (pr-insert-menu "PostScript Printer" 'pr-ps-name |
| 6213 | (pr-choice-alist pr-ps-printer-alist)) |
| 6214 | ;; 2. PostScript Printer: Despool |
| 6215 | (put 'pr-i-despool 'pr-widget |
| 6216 | (pr-insert-checkbox |
| 6217 | " " |
| 6218 | 'pr-i-despool |
| 6219 | #'(lambda (widget &rest ignore) |
| 6220 | (if pr-spool-p |
| 6221 | (setq pr-i-despool (not pr-i-despool)) |
| 6222 | (ding) |
| 6223 | (message "Can despool only when spooling is actually selected") |
| 6224 | (setq pr-i-despool nil)) |
| 6225 | (widget-value-set widget pr-i-despool) |
| 6226 | (widget-setup)) ; MUST be called after widget-value-set |
| 6227 | " Despool ")) |
| 6228 | ;; 2. PostScript Printer: Preview Print Quit |
| 6229 | (pr-insert-button 'pr-interface-preview "Preview" " ") |
| 6230 | (pr-insert-button 'pr-interface-ps-print "Print" " ") |
| 6231 | (pr-insert-button 'pr-interface-quit "Quit") |
| 6232 | ;; 2. PostScript Printer: Send to Printer/Temporary File |
| 6233 | (pr-insert-radio-button 'pr-i-ps-send 'printer) |
| 6234 | (widget-insert " Send to Printer/Temporary File") |
| 6235 | ;; 2. PostScript Printer: Send to File |
| 6236 | (pr-insert-radio-button 'pr-i-ps-send 'file) |
| 6237 | (widget-create |
| 6238 | 'file |
| 6239 | :size 57 |
| 6240 | :format " Send to File : %v" |
| 6241 | :notify 'pr-interface-outfile |
| 6242 | :action (lambda (widget &rest event) |
| 6243 | (if (and (pr-interface-outfile widget) |
| 6244 | (or (not (file-exists-p pr-i-out-file)) |
| 6245 | (setq pr-i-answer-yes |
| 6246 | (y-or-n-p "File exists; overwrite? ")))) |
| 6247 | (pr-widget-field-action widget event) |
| 6248 | (ding) |
| 6249 | (message "Please specify a writable PostScript file"))) |
| 6250 | pr-i-out-file) |
| 6251 | ;; 2. PostScript Printer: N-Up |
| 6252 | (widget-create |
| 6253 | 'integer |
| 6254 | :size 3 |
| 6255 | :format "\n N-Up : %v" |
| 6256 | :notify (lambda (widget &rest ignore) |
| 6257 | (let ((value (if (string= (widget-apply widget :value-get) "") |
| 6258 | 0 |
| 6259 | (widget-value widget)))) |
| 6260 | (if (and (integerp value) |
| 6261 | (<= 1 value) (<= value 100)) |
| 6262 | (progn |
| 6263 | (message " ") |
| 6264 | (setq pr-i-n-up value)) |
| 6265 | (ding) |
| 6266 | (message "Please specify an integer between 1 and 100")))) |
| 6267 | pr-i-n-up)) |
| 6268 | |
| 6269 | |
| 6270 | (defun pr-insert-section-3 () |
| 6271 | ;; 3. Text Printer: |
| 6272 | (pr-insert-italic "\n\nText Printer : " 2 14) |
| 6273 | (pr-insert-menu "Text Printer" 'pr-txt-name |
| 6274 | (pr-choice-alist pr-txt-printer-alist) |
| 6275 | nil " ") |
| 6276 | (pr-insert-button 'pr-interface-printify "Printify" " ") |
| 6277 | (pr-insert-button 'pr-interface-txt-print "Print" " ") |
| 6278 | (pr-insert-button 'pr-interface-quit "Quit")) |
| 6279 | |
| 6280 | |
| 6281 | (defun pr-insert-section-4 () |
| 6282 | ;; 4. Settings: |
| 6283 | ;; 4. Settings: Landscape Auto Region Verbose |
| 6284 | (pr-insert-checkbox "\n\n " 'ps-landscape-mode |
| 6285 | #'(lambda (&rest ignore) |
| 6286 | (setq ps-landscape-mode (not ps-landscape-mode) |
| 6287 | pr-file-landscape ps-landscape-mode)) |
| 6288 | " Landscape ") |
| 6289 | (pr-insert-toggle 'pr-auto-region " Auto Region ") |
| 6290 | (pr-insert-toggle 'pr-buffer-verbose " Verbose\n ") |
| 6291 | |
| 6292 | ;; 4. Settings: Print Header Auto Mode |
| 6293 | (pr-insert-toggle 'ps-print-header " Print Header ") |
| 6294 | (pr-insert-toggle 'pr-auto-mode " Auto Mode\n ") |
| 6295 | |
| 6296 | ;; 4. Settings: Print Header Frame Menu Lock |
| 6297 | (pr-insert-toggle 'ps-print-header-frame " Print Header Frame ") |
| 6298 | (pr-insert-toggle 'pr-menu-lock " Menu Lock\n ") |
| 6299 | |
| 6300 | ;; 4. Settings: Line Number |
| 6301 | (pr-insert-toggle 'ps-line-number " Line Number\n ") |
| 6302 | |
| 6303 | ;; 4. Settings: Zebra Stripes Spool Buffer |
| 6304 | (pr-insert-toggle 'ps-zebra-stripes " Zebra Stripes") |
| 6305 | (pr-insert-checkbox " " |
| 6306 | 'pr-spool-p |
| 6307 | #'(lambda (&rest ignore) |
| 6308 | (setq pr-spool-p (not pr-spool-p)) |
| 6309 | (unless pr-spool-p |
| 6310 | (setq pr-i-despool nil) |
| 6311 | (pr-update-checkbox 'pr-i-despool))) |
| 6312 | " Spool Buffer") |
| 6313 | |
| 6314 | ;; 4. Settings: Duplex Print with faces |
| 6315 | (pr-insert-checkbox "\n " |
| 6316 | 'ps-spool-duplex |
| 6317 | #'(lambda (&rest ignore) |
| 6318 | (setq ps-spool-duplex (not ps-spool-duplex) |
| 6319 | pr-file-duplex ps-spool-duplex)) |
| 6320 | " Duplex ") |
| 6321 | (pr-insert-toggle 'pr-faces-p " Print with faces") |
| 6322 | |
| 6323 | ;; 4. Settings: Tumble Print via Ghostscript |
| 6324 | (pr-insert-checkbox "\n " |
| 6325 | 'ps-spool-tumble |
| 6326 | #'(lambda (&rest ignore) |
| 6327 | (setq ps-spool-tumble (not ps-spool-tumble) |
| 6328 | pr-file-tumble ps-spool-tumble)) |
| 6329 | " Tumble ") |
| 6330 | (pr-insert-toggle 'pr-print-using-ghostscript " Print via Ghostscript\n ") |
| 6331 | |
| 6332 | ;; 4. Settings: Upside-Down Page Parity |
| 6333 | (pr-insert-toggle 'ps-print-upside-down " Upside-Down") |
| 6334 | (pr-insert-italic "\n\nSelect Pages : " 2 14) |
| 6335 | (pr-insert-menu "Page Parity" 'ps-even-or-odd-pages |
| 6336 | (mapcar #'(lambda (alist) |
| 6337 | (list 'quote |
| 6338 | (list 'choice-item |
| 6339 | :format "%[%t%]" |
| 6340 | :tag (cdr alist) |
| 6341 | :value (car alist)))) |
| 6342 | pr-even-or-odd-alist))) |
| 6343 | |
| 6344 | |
| 6345 | (defun pr-insert-section-5 () |
| 6346 | ;; 5. Customize: |
| 6347 | (pr-insert-italic "\n\nCustomize : " 2 11) |
| 6348 | (pr-insert-button 'pr-customize "printing" " ") |
| 6349 | (pr-insert-button #'(lambda (&rest ignore) (ps-print-customize)) |
| 6350 | "ps-print" " ") |
| 6351 | (pr-insert-button 'lpr-customize "lpr")) |
| 6352 | |
| 6353 | |
| 6354 | (defun pr-insert-section-6 () |
| 6355 | ;; 6. Show Settings: |
| 6356 | (pr-insert-italic "\nShow Settings : " 1 14) |
| 6357 | (pr-insert-button 'pr-show-pr-setup "printing" " ") |
| 6358 | (pr-insert-button 'pr-show-ps-setup "ps-print" " ") |
| 6359 | (pr-insert-button 'pr-show-lpr-setup "lpr")) |
| 6360 | |
| 6361 | |
| 6362 | (defun pr-insert-section-7 () |
| 6363 | ;; 7. Help: |
| 6364 | (pr-insert-italic "\nHelp : " 1 5) |
| 6365 | (pr-insert-button 'pr-interface-help "Interface Help" " ") |
| 6366 | (pr-insert-button 'pr-help "Menu Help" " ") |
| 6367 | (pr-insert-button 'pr-interface-quit "Quit" "\n ") |
| 6368 | (pr-insert-button 'pr-kill-help "Kill All Printing Help Buffer")) |
| 6369 | |
| 6370 | |
| 6371 | (defun pr-kill-help (&rest ignore) |
| 6372 | "Kill all printing help buffer." |
| 6373 | (interactive) |
| 6374 | (let ((help '("*Printing Interface Help*" "*Printing Help*" |
| 6375 | "*LPR Setup*" "*PR Setup*" "*PS Setup*"))) |
| 6376 | (while help |
| 6377 | (let ((buffer (get-buffer (car help)))) |
| 6378 | (setq help (cdr help)) |
| 6379 | (when buffer |
| 6380 | (delete-windows-on buffer) |
| 6381 | (kill-buffer buffer))))) |
| 6382 | (recenter (- (window-height) 2))) |
| 6383 | |
| 6384 | |
| 6385 | (defun pr-interface-quit (&rest ignore) |
| 6386 | "Kill the printing buffer interface and quit." |
| 6387 | (interactive) |
| 6388 | (kill-buffer pr-buffer-name) |
| 6389 | (set-window-configuration pr-i-window-configuration)) |
| 6390 | |
| 6391 | |
| 6392 | (defun pr-interface-help (&rest ignore) |
| 6393 | "printing buffer interface help." |
| 6394 | (interactive) |
| 6395 | (pr-show-setup pr-interface-help-message "*Printing Interface Help*")) |
| 6396 | |
| 6397 | |
| 6398 | (defun pr-interface-txt-print (&rest ignore) |
| 6399 | "Print using lpr package." |
| 6400 | (interactive) |
| 6401 | (condition-case data |
| 6402 | (cond |
| 6403 | ((eq pr-i-process 'directory) |
| 6404 | (pr-i-directory) |
| 6405 | (pr-interface-save |
| 6406 | (pr-txt-directory pr-i-directory pr-i-regexp))) |
| 6407 | ((eq pr-i-process 'buffer) |
| 6408 | (pr-interface-save |
| 6409 | (cond (pr-i-region |
| 6410 | (let ((pr-auto-mode pr-i-mode)) |
| 6411 | (pr-txt-region))) |
| 6412 | (pr-i-mode |
| 6413 | (let (pr-auto-region) |
| 6414 | (pr-txt-mode))) |
| 6415 | (t |
| 6416 | (let (pr-auto-mode pr-auto-region) |
| 6417 | (pr-txt-buffer))) |
| 6418 | ))) |
| 6419 | ((eq pr-i-process 'file) |
| 6420 | (error "Please specify a text file")) |
| 6421 | (t |
| 6422 | (error "Internal error: `pr-i-process' = %S" pr-i-process)) |
| 6423 | ) |
| 6424 | ;; handlers |
| 6425 | ((quit error) |
| 6426 | (ding) |
| 6427 | (message "%s" (error-message-string data))))) |
| 6428 | |
| 6429 | |
| 6430 | (defun pr-interface-printify (&rest ignore) |
| 6431 | "Printify a buffer." |
| 6432 | (interactive) |
| 6433 | (condition-case data |
| 6434 | (cond |
| 6435 | ((eq pr-i-process 'directory) |
| 6436 | (pr-i-directory) |
| 6437 | (pr-interface-save |
| 6438 | (pr-printify-directory pr-i-directory pr-i-regexp))) |
| 6439 | ((eq pr-i-process 'buffer) |
| 6440 | (pr-interface-save |
| 6441 | (if pr-i-region |
| 6442 | (pr-printify-region) |
| 6443 | (pr-printify-buffer)))) |
| 6444 | ((eq pr-i-process 'file) |
| 6445 | (error "Cannot printify a PostScript file")) |
| 6446 | (t |
| 6447 | (error "Internal error: `pr-i-process' = %S" pr-i-process)) |
| 6448 | ) |
| 6449 | ;; handlers |
| 6450 | ((quit error) |
| 6451 | (ding) |
| 6452 | (message "%s" (error-message-string data))))) |
| 6453 | |
| 6454 | |
| 6455 | (defun pr-interface-ps-print (&rest ignore) |
| 6456 | "Print using ps-print package." |
| 6457 | (interactive) |
| 6458 | (pr-interface-ps 'pr-despool-ps-print 'pr-ps-directory-ps-print |
| 6459 | 'pr-ps-file-ps-print 'pr-ps-file-up-ps-print |
| 6460 | 'pr-ps-region-ps-print 'pr-ps-mode-ps-print |
| 6461 | 'pr-ps-buffer-ps-print)) |
| 6462 | |
| 6463 | |
| 6464 | (defun pr-interface-preview (&rest ignore) |
| 6465 | "Preview a PostScript file." |
| 6466 | (interactive) |
| 6467 | (pr-interface-ps 'pr-despool-preview 'pr-ps-directory-preview |
| 6468 | 'pr-ps-file-preview 'pr-ps-file-up-preview |
| 6469 | 'pr-ps-region-preview 'pr-ps-mode-preview |
| 6470 | 'pr-ps-buffer-preview)) |
| 6471 | |
| 6472 | |
| 6473 | (defun pr-interface-ps (ps-despool ps-directory ps-file ps-file-up ps-region |
| 6474 | ps-mode ps-buffer) |
| 6475 | (condition-case data |
| 6476 | (let ((outfile (or (and (eq pr-i-process 'file) pr-i-ps-as-is) |
| 6477 | (pr-i-ps-send)))) |
| 6478 | (cond |
| 6479 | ((and pr-i-despool pr-spool-p) |
| 6480 | (pr-interface-save |
| 6481 | (funcall ps-despool outfile)) |
| 6482 | (setq pr-i-despool nil) |
| 6483 | (pr-update-checkbox 'pr-i-despool)) |
| 6484 | ((eq pr-i-process 'directory) |
| 6485 | (pr-i-directory) |
| 6486 | (pr-interface-save |
| 6487 | (funcall ps-directory |
| 6488 | pr-i-n-up pr-i-directory pr-i-regexp outfile))) |
| 6489 | ((eq pr-i-process 'file) |
| 6490 | (cond ((or (file-directory-p pr-i-ps-file) |
| 6491 | (not (file-readable-p pr-i-ps-file))) |
| 6492 | (error "Please specify a readable PostScript file")) |
| 6493 | (pr-i-ps-as-is |
| 6494 | (pr-interface-save |
| 6495 | (funcall ps-file pr-i-ps-file))) |
| 6496 | (t |
| 6497 | (pr-interface-save |
| 6498 | (funcall ps-file-up pr-i-n-up pr-i-ps-file outfile))) |
| 6499 | )) |
| 6500 | ((eq pr-i-process 'buffer) |
| 6501 | (pr-interface-save |
| 6502 | (cond (pr-i-region |
| 6503 | (let ((pr-auto-mode pr-i-mode)) |
| 6504 | (funcall ps-region pr-i-n-up outfile))) |
| 6505 | (pr-i-mode |
| 6506 | (let (pr-auto-region) |
| 6507 | (funcall ps-mode pr-i-n-up outfile))) |
| 6508 | (t |
| 6509 | (let (pr-auto-mode pr-auto-region) |
| 6510 | (funcall ps-buffer pr-i-n-up outfile))) |
| 6511 | ))) |
| 6512 | (t |
| 6513 | (error "Internal error: `pr-i-process' = %S" pr-i-process)) |
| 6514 | )) |
| 6515 | ;; handlers |
| 6516 | ((quit error) |
| 6517 | (ding) |
| 6518 | (message "%s" (error-message-string data))))) |
| 6519 | |
| 6520 | |
| 6521 | (defun pr-i-ps-send () |
| 6522 | (cond ((eq pr-i-ps-send 'printer) |
| 6523 | nil) |
| 6524 | ((not (eq pr-i-ps-send 'file)) |
| 6525 | (error "Internal error: `pr-i-ps-send' = %S" pr-i-ps-send)) |
| 6526 | ((or (file-directory-p pr-i-out-file) |
| 6527 | (not (file-writable-p pr-i-out-file))) |
| 6528 | (error "Please specify a writable PostScript file")) |
| 6529 | ((or (not (file-exists-p pr-i-out-file)) |
| 6530 | pr-i-answer-yes |
| 6531 | (setq pr-i-answer-yes |
| 6532 | (y-or-n-p (format "File `%s' exists; overwrite? " |
| 6533 | pr-i-out-file)))) |
| 6534 | pr-i-out-file) |
| 6535 | (t |
| 6536 | (error "File already exists")))) |
| 6537 | |
| 6538 | |
| 6539 | (defun pr-i-directory () |
| 6540 | (or (and (file-directory-p pr-i-directory) |
| 6541 | (file-readable-p pr-i-directory)) |
| 6542 | (error "Please specify be a readable directory"))) |
| 6543 | |
| 6544 | |
| 6545 | (defun pr-interface-directory (widget &rest ignore) |
| 6546 | (and pr-buffer-verbose |
| 6547 | (message "You can use M-TAB or ESC TAB for file completion")) |
| 6548 | (let ((dir (widget-value widget))) |
| 6549 | (and (file-directory-p dir) |
| 6550 | (file-readable-p dir) |
| 6551 | (setq pr-i-directory dir)))) |
| 6552 | |
| 6553 | |
| 6554 | (defun pr-interface-infile (widget &rest ignore) |
| 6555 | (and pr-buffer-verbose |
| 6556 | (message "You can use M-TAB or ESC TAB for file completion")) |
| 6557 | (let ((file (widget-value widget))) |
| 6558 | (and (not (file-directory-p file)) |
| 6559 | (file-readable-p file) |
| 6560 | (setq pr-i-ps-file file)))) |
| 6561 | |
| 6562 | |
| 6563 | (defun pr-interface-outfile (widget &rest ignore) |
| 6564 | (setq pr-i-answer-yes nil) |
| 6565 | (and pr-buffer-verbose |
| 6566 | (message "You can use M-TAB or ESC TAB for file completion")) |
| 6567 | (let ((file (widget-value widget))) |
| 6568 | (and (not (file-directory-p file)) |
| 6569 | (file-writable-p file) |
| 6570 | (setq pr-i-out-file file)))) |
| 6571 | |
| 6572 | |
| 6573 | (defun pr-widget-field-action (widget event) |
| 6574 | (and (get-buffer "*Completions*") ; clean frame window |
| 6575 | (delete-windows-on "*Completions*")) |
| 6576 | (message " ") ; clean echo area |
| 6577 | (widget-field-action widget event)) |
| 6578 | |
| 6579 | |
| 6580 | (defun pr-insert-italic (str &optional from to) |
| 6581 | (let ((len (length str))) |
| 6582 | (put-text-property (if from (max from 0) 0) |
| 6583 | (if to (max to len) len) |
| 6584 | 'face 'italic str) |
| 6585 | (widget-insert str))) |
| 6586 | |
| 6587 | |
| 6588 | (defun pr-insert-checkbox (before var-sym fun label) |
| 6589 | (widget-insert before) |
| 6590 | (prog1 |
| 6591 | (widget-create 'checkbox |
| 6592 | :notify fun |
| 6593 | (symbol-value var-sym)) |
| 6594 | (widget-insert label))) |
| 6595 | |
| 6596 | |
| 6597 | (defun pr-insert-toggle (var-sym label) |
| 6598 | (widget-create 'checkbox |
| 6599 | :notify `(lambda (&rest ignore) |
| 6600 | (setq ,var-sym (not ,var-sym))) |
| 6601 | (symbol-value var-sym)) |
| 6602 | (widget-insert label)) |
| 6603 | |
| 6604 | |
| 6605 | (defun pr-insert-button (fun label &optional separator) |
| 6606 | (widget-create 'push-button |
| 6607 | :notify fun |
| 6608 | label) |
| 6609 | (and separator |
| 6610 | (widget-insert separator))) |
| 6611 | |
| 6612 | |
| 6613 | (defun pr-insert-menu (tag var-sym choices &optional before after &rest body) |
| 6614 | (and before (widget-insert before)) |
| 6615 | (eval `(widget-create 'menu-choice |
| 6616 | :tag ,tag |
| 6617 | :format "%v" |
| 6618 | :inline t |
| 6619 | :value ,var-sym |
| 6620 | :notify (lambda (widget &rest ignore) |
| 6621 | (setq ,var-sym (widget-value widget)) |
| 6622 | ,@body) |
| 6623 | :void '(choice-item :format "%[%t%]" |
| 6624 | :tag "Can not display value!") |
| 6625 | ,@choices)) |
| 6626 | (and after (widget-insert after))) |
| 6627 | |
| 6628 | |
| 6629 | (defun pr-insert-radio-button (var-sym sym) |
| 6630 | (widget-insert "\n") |
| 6631 | (let ((wid-list (get var-sym 'pr-widget-list)) |
| 6632 | (wid (eval `(widget-create |
| 6633 | 'radio-button |
| 6634 | :format " %[%v%]" |
| 6635 | :value (eq ,var-sym (quote ,sym)) |
| 6636 | :notify (lambda (&rest ignore) |
| 6637 | (setq ,var-sym (quote ,sym)) |
| 6638 | (pr-update-radio-button (quote ,var-sym))))))) |
| 6639 | (put var-sym 'pr-widget-list (cons (cons wid sym) wid-list)))) |
| 6640 | |
| 6641 | |
| 6642 | (defun pr-update-radio-button (var-sym) |
| 6643 | (let ((wid-list (get var-sym 'pr-widget-list))) |
| 6644 | (while wid-list |
| 6645 | (let ((wid (car (car wid-list))) |
| 6646 | (value (cdr (car wid-list)))) |
| 6647 | (setq wid-list (cdr wid-list)) |
| 6648 | (widget-value-set wid (eq (symbol-value var-sym) value)))) |
| 6649 | (widget-setup))) |
| 6650 | |
| 6651 | |
| 6652 | (defun pr-update-checkbox (var-sym) |
| 6653 | (let ((wid (get var-sym 'pr-widget))) |
| 6654 | (when wid |
| 6655 | (widget-value-set wid (symbol-value var-sym)) |
| 6656 | (widget-setup)))) |
| 6657 | |
| 6658 | |
| 6659 | (defun pr-choice-alist (alist) |
| 6660 | (let ((max (apply 'max (mapcar #'(lambda (alist) |
| 6661 | (length (symbol-name (car alist)))) |
| 6662 | alist)))) |
| 6663 | (mapcar #'(lambda (alist) |
| 6664 | (let* ((sym (car alist)) |
| 6665 | (name (symbol-name sym))) |
| 6666 | (list |
| 6667 | 'quote |
| 6668 | (list |
| 6669 | 'choice-item |
| 6670 | :format "%[%t%]" |
| 6671 | :tag (concat name |
| 6672 | (make-string (- max (length name)) ?_)) |
| 6673 | :value sym)))) |
| 6674 | alist))) |
| 6675 | |
| 6676 | |
| 6677 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
| 6678 | |
| 6679 | |
| 6680 | (provide 'printing) |
| 6681 | |
| 6682 | |
| 6683 | ;; arch-tag: 9ce9ac3f-0f60-4370-900b-1943215d9d18 |
| 6684 | ;;; printing.el ends here |