annotate lisp/gs.el @ 38995:e3ab893551db

*** empty log message ***
author Gerd Moellmann <gerd@gnu.org>
date Tue, 28 Aug 2001 14:34:17 +0000
parents b1bf1a386c78
children 751bf57c84a1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1 ;;; gs.el --- interface to Ghostscript
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
3 ;; Copyright (C) 1998 Free Software Foundation, Inc.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5 ;; Maintainer: FSF
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; Keywords: internal
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
13 ;; any later version.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
18 ;; GNU General Public License for more details.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;; Boston, MA 02111-1307, USA.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 ;;; Commentary:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27 ;; This code is experimental. Don't use it.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29 ;;; Code:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 (defvar gs-program "gs"
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 "The name of the Ghostscript interpreter.")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 (defvar gs-device "x11"
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 "The Ghostscript device to use to produce images.")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38
35522
9c7789e8882b use replace-regexps-in-string instead of dired- and gs-replace-in-string
Sam Steingold <sds@gnu.org>
parents: 25651
diff changeset
39 (defvar gs-options
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 '("-q"
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41 ;"-dNOPAUSE"
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 "-dBATCH"
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43 "-sDEVICE=<device>"
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44 "<file>")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 "List of command line arguments to pass to Ghostscript.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46 Arguments may contain place-holders `<file>' for the name of the
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47 input file, and `<device>' for the device to use.")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49 (defun gs-options (device file)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50 "Return a list of command line options with place-holders replaced.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 DEVICE is the value to substitute for the place-holder `<device>',
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 FILE is the value to substitute for the place-holder `<file>'."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53 (mapcar #'(lambda (option)
35522
9c7789e8882b use replace-regexps-in-string instead of dired- and gs-replace-in-string
Sam Steingold <sds@gnu.org>
parents: 25651
diff changeset
54 (setq option (replace-regexp-in-string "<device>" device option)
9c7789e8882b use replace-regexps-in-string instead of dired- and gs-replace-in-string
Sam Steingold <sds@gnu.org>
parents: 25651
diff changeset
55 option (replace-regexp-in-string "<file>" file option)))
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 gs-options))
35522
9c7789e8882b use replace-regexps-in-string instead of dired- and gs-replace-in-string
Sam Steingold <sds@gnu.org>
parents: 25651
diff changeset
57
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 ;; The GHOSTVIEW property (taken from gv 3.5.8).
35522
9c7789e8882b use replace-regexps-in-string instead of dired- and gs-replace-in-string
Sam Steingold <sds@gnu.org>
parents: 25651
diff changeset
60 ;;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 ;; Type:
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62 ;;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63 ;; STRING
35522
9c7789e8882b use replace-regexps-in-string instead of dired- and gs-replace-in-string
Sam Steingold <sds@gnu.org>
parents: 25651
diff changeset
64 ;;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 ;; Parameters:
35522
9c7789e8882b use replace-regexps-in-string instead of dired- and gs-replace-in-string
Sam Steingold <sds@gnu.org>
parents: 25651
diff changeset
66 ;;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67 ;; BPIXMAP ORIENT LLX LLY URX URY XDPI YDPI [LEFT BOTTOM TOP RIGHT]
35522
9c7789e8882b use replace-regexps-in-string instead of dired- and gs-replace-in-string
Sam Steingold <sds@gnu.org>
parents: 25651
diff changeset
68 ;;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 ;; Scanf format: "%d %d %d %d %d %d %f %f %d %d %d %d"
35522
9c7789e8882b use replace-regexps-in-string instead of dired- and gs-replace-in-string
Sam Steingold <sds@gnu.org>
parents: 25651
diff changeset
70 ;;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71 ;; Explanation of parameters:
35522
9c7789e8882b use replace-regexps-in-string instead of dired- and gs-replace-in-string
Sam Steingold <sds@gnu.org>
parents: 25651
diff changeset
72 ;;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 ;; BPIXMAP: pixmap id of the backing pixmap for the window. If no
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 ;; pixmap is to be used, this parameter should be zero. This
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 ;; parameter must be zero when drawing on a pixmap.
35522
9c7789e8882b use replace-regexps-in-string instead of dired- and gs-replace-in-string
Sam Steingold <sds@gnu.org>
parents: 25651
diff changeset
76 ;;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 ;; ORIENT: orientation of the page. The number represents clockwise
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 ;; rotation of the paper in degrees. Permitted values are 0, 90, 180,
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 ;; 270.
35522
9c7789e8882b use replace-regexps-in-string instead of dired- and gs-replace-in-string
Sam Steingold <sds@gnu.org>
parents: 25651
diff changeset
80 ;;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 ;; LLX, LLY, URX, URY: Bounding box of the drawable. The bounding box
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 ;; is specified in PostScript points in default user coordinates.
35522
9c7789e8882b use replace-regexps-in-string instead of dired- and gs-replace-in-string
Sam Steingold <sds@gnu.org>
parents: 25651
diff changeset
83 ;;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 ;; XDPI, YDPI: Resolution of window. (This can be derived from the
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 ;; other parameters, but not without roundoff error. These values are
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 ;; included to avoid this error.)
35522
9c7789e8882b use replace-regexps-in-string instead of dired- and gs-replace-in-string
Sam Steingold <sds@gnu.org>
parents: 25651
diff changeset
87 ;;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 ;; LEFT, BOTTOM, TOP, RIGHT: (optional) Margins around the window.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 ;; The margins extend the imageable area beyond the boundaries of the
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 ;; window. This is primarily used for popup zoom windows. I have
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 ;; encountered several instances of PostScript programs that position
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 ;; themselves with respect to the imageable area. The margins are
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 ;; specified in PostScript points. If omitted, the margins are
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 ;; assumed to be 0.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96 (defun gs-width-in-pt (frame pixel-width)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 "Return, on FRAME, pixel width PIXEL-WIDTH tranlated to pt."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 (let ((mm (* (float pixel-width)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 (/ (float (x-display-mm-width frame))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 (float (x-display-pixel-width frame))))))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 (/ (* 25.4 mm) 72.0)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104 (defun gs-height-in-pt (frame pixel-height)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 "Return, on FRAME, pixel height PIXEL-HEIGHT tranlated to pt."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 (let ((mm (* (float pixel-height)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107 (/ (float (x-display-mm-height frame))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 (float (x-display-pixel-height frame))))))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 (/ (* 25.4 mm) 72.0)))
35522
9c7789e8882b use replace-regexps-in-string instead of dired- and gs-replace-in-string
Sam Steingold <sds@gnu.org>
parents: 25651
diff changeset
110
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 (defun gs-set-ghostview-window-prop (frame spec img-width img-height)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 "Set the `GHOSTVIEW' window property of FRAME.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 SPEC is a GS image specification. IMG-WIDTH is the width of the
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 requested image, and IMG-HEIGHT is the height of the requested
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116 image in pixels."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 (let* ((box (plist-get (cdr spec) :bounding-box))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 (llx (nth 0 box))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 (lly (nth 1 box))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120 (urx (nth 2 box))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 (ury (nth 3 box))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 (rotation (or (plist-get (cdr spec) :rotate) 0))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123 ;; The pixel width IMG-WIDTH of the pixmap gives the
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 ;; dots, URX - LLX give the inch.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 (in-width (/ (- urx llx) 72.0))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 (in-height (/ (- ury lly) 72.0))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 (xdpi (/ img-width in-width))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 (ydpi (/ img-height in-height)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 (x-change-window-property "GHOSTVIEW"
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 (format "0 %d %d %d %d %d %g %g"
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 rotation llx lly urx ury xdpi ydpi)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 frame)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 (defun gs-set-ghostview-colors-window-prop (frame pixel-colors)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 "Set the `GHOSTVIEW_COLORS' environment variable depending on FRAME."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 (let ((mode (cond ((x-display-color-p frame) "Color")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 ((x-display-grayscale-p frame) "Grayscale")
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 (t "Monochrome"))))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 (x-change-window-property "GHOSTVIEW_COLORS"
38890
a6653fe3cbb9 (gs-set-ghostview-colors-window-prop): Call
Gerd Moellmann <gerd@gnu.org>
parents: 38412
diff changeset
141 (format "%s %s" mode pixel-colors)
a6653fe3cbb9 (gs-set-ghostview-colors-window-prop): Call
Gerd Moellmann <gerd@gnu.org>
parents: 38412
diff changeset
142 frame)))
35522
9c7789e8882b use replace-regexps-in-string instead of dired- and gs-replace-in-string
Sam Steingold <sds@gnu.org>
parents: 25651
diff changeset
143
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 ;
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 ;;;###autoload
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 (defun gs-load-image (frame spec img-width img-height window-and-pixmap-id
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 pixel-colors)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 "Load a PS image for display on FRAME.
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 SPEC is an image specification, IMG-HEIGHT and IMG-WIDTH are width
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 and height of the image in pixels. WINDOW-AND-PIXMAP-ID is a string of
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152 the form \"WINDOW-ID PIXMAP-ID\". Value is non-nil if successful."
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 (unwind-protect
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 (let ((file (plist-get (cdr spec) :file))
38890
a6653fe3cbb9 (gs-set-ghostview-colors-window-prop): Call
Gerd Moellmann <gerd@gnu.org>
parents: 38412
diff changeset
155 gs
38935
b1bf1a386c78 (gs-load-image): Wait for GHOSTVIEW window property
Gerd Moellmann <gerd@gnu.org>
parents: 38890
diff changeset
156 (timeout 10))
b1bf1a386c78 (gs-load-image): Wait for GHOSTVIEW window property
Gerd Moellmann <gerd@gnu.org>
parents: 38890
diff changeset
157 ;; Wait while property gets freed from a previous ghostscript
b1bf1a386c78 (gs-load-image): Wait for GHOSTVIEW window property
Gerd Moellmann <gerd@gnu.org>
parents: 38890
diff changeset
158 ;; process
b1bf1a386c78 (gs-load-image): Wait for GHOSTVIEW window property
Gerd Moellmann <gerd@gnu.org>
parents: 38890
diff changeset
159 (while (and (not (zerop (length (x-window-property "GHOSTVIEW"
b1bf1a386c78 (gs-load-image): Wait for GHOSTVIEW window property
Gerd Moellmann <gerd@gnu.org>
parents: 38890
diff changeset
160 frame))))
b1bf1a386c78 (gs-load-image): Wait for GHOSTVIEW window property
Gerd Moellmann <gerd@gnu.org>
parents: 38890
diff changeset
161 (not (zerop timeout)))
38890
a6653fe3cbb9 (gs-set-ghostview-colors-window-prop): Call
Gerd Moellmann <gerd@gnu.org>
parents: 38412
diff changeset
162 (sit-for 0 100 t)
38935
b1bf1a386c78 (gs-load-image): Wait for GHOSTVIEW window property
Gerd Moellmann <gerd@gnu.org>
parents: 38890
diff changeset
163 (setq timeout (1- timeout)))
b1bf1a386c78 (gs-load-image): Wait for GHOSTVIEW window property
Gerd Moellmann <gerd@gnu.org>
parents: 38890
diff changeset
164 ;; No use waiting longer. We might want to try killing off
b1bf1a386c78 (gs-load-image): Wait for GHOSTVIEW window property
Gerd Moellmann <gerd@gnu.org>
parents: 38890
diff changeset
165 ;; stuck processes, but there is no point in doing so: either
b1bf1a386c78 (gs-load-image): Wait for GHOSTVIEW window property
Gerd Moellmann <gerd@gnu.org>
parents: 38890
diff changeset
166 ;; they are stuck for good, in which case the user would
b1bf1a386c78 (gs-load-image): Wait for GHOSTVIEW window property
Gerd Moellmann <gerd@gnu.org>
parents: 38890
diff changeset
167 ;; probably be responsible for that, and killing them off will
b1bf1a386c78 (gs-load-image): Wait for GHOSTVIEW window property
Gerd Moellmann <gerd@gnu.org>
parents: 38890
diff changeset
168 ;; make debugging harder, or they are not. In that case, they
b1bf1a386c78 (gs-load-image): Wait for GHOSTVIEW window property
Gerd Moellmann <gerd@gnu.org>
parents: 38890
diff changeset
169 ;; will cause incomplete displays. But the same will happen
b1bf1a386c78 (gs-load-image): Wait for GHOSTVIEW window property
Gerd Moellmann <gerd@gnu.org>
parents: 38890
diff changeset
170 ;; if they are killed, anyway.
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171 (gs-set-ghostview-window-prop frame spec img-width img-height)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 (gs-set-ghostview-colors-window-prop frame pixel-colors)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 (setenv "GHOSTVIEW" window-and-pixmap-id)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 (setq gs (apply 'start-process "gs" "*GS*" gs-program
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175 (gs-options gs-device file)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176 (process-kill-without-query gs)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 gs)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 nil))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 ;(defun gs-put-tiger ()
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182 ; (let* ((ps-file "/usr/local/share/ghostscript/5.10/examples/tiger.ps")
25651
e65a0e39a0a9 Change `ghostscript' to `postscript' in comment.
Gerd Moellmann <gerd@gnu.org>
parents: 25003
diff changeset
183 ; (spec `(image :type postscript
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184 ; :pt-width 200 :pt-height 200
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 ; :bounding-box (22 171 567 738)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186 ; :file ,ps-file)))
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 ; (put-text-property 1 2 'display spec)))
35522
9c7789e8882b use replace-regexps-in-string instead of dired- and gs-replace-in-string
Sam Steingold <sds@gnu.org>
parents: 25651
diff changeset
188 ;
25003
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190 (provide 'gs)
bb68fe3c72f8 New file.
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191
38412
253f761ad37b Some fixes to follow coding conventions in files maintained by FSF.
Pavel Janík <Pavel@Janik.cz>
parents: 35522
diff changeset
192 ;;; gs.el ends here