;;; 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.
;; 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|
;; 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
(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
(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))
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))))
(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
;; 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.
(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)))