]> code.delx.au - gnu-emacs/blobdiff - lisp/ps-print.el
(c-macro-expansion): Delete ??! trigraph in uniquestring.
[gnu-emacs] / lisp / ps-print.el
index e3cba874a5b4ff51bc35625e52b073ce8ac9ce0b..cc5066bcf6f079197efcfb38c850f8cb1faf6d5b 100644 (file)
@@ -1,8 +1,9 @@
 ;;; ps-print.el --- Jim's Pretty-Good PostScript Generator for Emacs 19.
 
-;; Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
+;; Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
 
 ;; Author: Jim Thompson <thompson@wg2.waii.com>
+;; Maintainer: FSF
 ;; Keywords: print, PostScript
 
 ;; This file is part of GNU Emacs.
@@ -18,8 +19,9 @@
 ;; GNU General Public License for more details.
 
 ;; You should have received a copy of the GNU General Public License
-;; along with GNU Emacs; see the file COPYING.  If not, write to
-;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+;; along with GNU Emacs; see the file COPYING.  If not, write to the
+;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+;; Boston, MA 02111-1307, USA.
 
 ;; LCD Archive Entry:
 ;; ps-print|James C. Thompson|thompson@wg2.waii.com|
@@ -83,7 +85,7 @@
 ;; printout than to find 50 single-page printouts).
 ;; 
 ;; Ps-print has a hook in the kill-emacs-hooks so that you won't
-;; accidently quit from Emacs while you have unprinted PostScript
+;; accidentally quit from Emacs while you have unprinted PostScript
 ;; waiting in the spool buffer.  If you do attempt to exit with
 ;; spooled PostScript, you'll be asked if you want to print it, and if
 ;; you decline, you'll be asked to confirm the exit; this is modeled
 ;; Ps-print keeps internal lists of which fonts are bold and which are
 ;; italic; these lists are built the first time you invoke ps-print.
 ;; For the sake of efficiency, the lists are built only once; the same
-;; lists are referred in later invokations of ps-print.
+;; lists are referred in later invocations of ps-print.
 ;;
 ;; Because these lists are built only once, it's possible for them to
 ;; get out of sync, if a face changes, or if new faces are added.  To
 ;; or variables.  Functions are called, and should return a string to
 ;; show in the header.  Variables should contain strings to display in
 ;; the header.  In either case, function or variable, the PostScript
-;; strings delimeters are added by ps-print, and should not be part of
+;; string delimiters are added by ps-print, and should not be part of
 ;; the returned value.
 ;;
 ;; Here's an example: say we want the left header to display the text
@@ -1166,9 +1168,11 @@ StandardEncoding 46 82 getinterval aload pop
               (listp filename)))
       (let* ((name (concat (buffer-name) ".ps"))
             (prompt (format "Save PostScript to file: (default %s) "
-                            name)))
-       (read-file-name prompt default-directory
-                       name nil))))
+                            name))
+            (res (read-file-name prompt default-directory name nil)))
+       (if (file-directory-p res)
+           (expand-file-name name (file-name-as-directory res))
+         res))))
 
 ;; The following functions implement a simple list-buffering scheme so
 ;; that ps-print doesn't have to repeatedly switch between buffers
@@ -1759,8 +1763,20 @@ EndDSCPage\n"))
                           (min (next-overlay-change from) to)))
                 (setq position
                       (min property-change overlay-change))
+                ;; The code below is not quite correct,
+                ;; because a non-nil overlay invisible property
+                ;; which is inactive according to the current value
+                ;; of buffer-invisibility-spec nonetheless overrides
+                ;; a face text property.
                 (setq face
-                      (cond ((get-text-property from 'invisible) nil)
+                      (cond ((let ((prop (get-text-property from 'invisible)))
+                               ;; Decide whether this invisible property
+                               ;; really makes the text invisible.
+                               (if (eq buffer-invisibility-spec t)
+                                   (not (null prop))
+                                 (or (memq prop buffer-invisibility-spec)
+                                     (assq prop buffer-invisibility-spec))))
+                             nil)
                             ((get-text-property from 'face))
                             (t 'default)))
                 (let ((overlays (overlays-at from))
@@ -1774,7 +1790,11 @@ EndDSCPage\n"))
                                                  0)))
                       (if (and (or overlay-invisible overlay-face)
                                (> overlay-priority face-priority))
-                          (setq face (cond (overlay-invisible nil)
+                          (setq face (cond ((if (eq buffer-invisibility-spec t)
+                                                (not (null overlay-invisible))
+                                              (or (memq overlay-invisible buffer-invisibility-spec)
+                                                  (assq overlay-invisible buffer-invisibility-spec)))
+                                            nil)
                                            ((and face overlay-face)))
                                 face-priority overlay-priority)))
                     (setq overlays (cdr overlays))))
@@ -1788,7 +1808,10 @@ EndDSCPage\n"))
 
 (defun ps-generate (buffer from to genfunc)
   (let ((from (min to from))
-       (to (max to from)))
+       (to (max to from))
+       ;; This avoids trouble if chars with read-only properties
+       ;; are copied into ps-spool-buffer.
+       (inhibit-read-only t))
     (save-restriction
       (narrow-to-region from to)
       (if ps-razzle-dazzle
@@ -1836,7 +1859,7 @@ EndDSCPage\n"))
              ;; the postscript was generated without error.
              (setq completed-safely t))
 
-         ;; Unwind form: If some bad mojo ocurred while generating
+         ;; Unwind form: If some bad mojo occurred while generating
          ;; postscript, delete all the postscript that was generated.
          ;; This protects the previously spooled files from getting
          ;; corrupted.
@@ -1868,9 +1891,14 @@ EndDSCPage\n"))
          (message "Printing..."))
       (save-excursion
        (set-buffer ps-spool-buffer)
-       (apply 'call-process-region
-              (point-min) (point-max) ps-lpr-command nil 0 nil
-              ps-lpr-switches))
+       (if (and (eq system-type 'ms-dos) (stringp dos-ps-printer))
+           (write-region (point-min) (point-max) dos-ps-printer t 0)
+         (let ((binary-process-input t)) ; for MS-DOS
+           (apply 'call-process-region
+                  (point-min) (point-max) ps-lpr-command nil
+                  (if (fboundp 'start-process) 0 nil)
+                  nil
+                  ps-lpr-switches))))
       (if ps-razzle-dazzle
          (message "Printing...done")))
     (kill-buffer ps-spool-buffer)))