Mercurial > emacs
annotate lisp/progmodes/ps-mode.el @ 25990:2b2b161bac67
New file. Major mode for editing PostScript.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 12 Oct 1999 14:55:35 +0000 |
parents | |
children | 6b9477637c7c |
rev | line source |
---|---|
25990
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1 ;;; ps-mode.el --- PostScript mode for GNU Emacs. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
2 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
3 ;; Copyright (C) 1999 Free Software Foundation, Inc. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
4 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
5 ;; Author: Peter Kleiweg <kleiweg@let.rug.nl> |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
6 ;; Maintainer: Peter Kleiweg <kleiweg@let.rug.nl> |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
7 ;; Created: 20 Aug 1997 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
8 ;; Version: 1.1a, 11 Oct 1999 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
9 ;; Keywords: PostScript, languages |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
10 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
11 ;; This file is part of GNU Emacs. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
12 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
13 ;; GNU Emacs is free software; you can redistribute it and/or modify |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
14 ;; it under the terms of the GNU General Public License as published by |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
15 ;; the Free Software Foundation; either version 2, or (at your option) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
16 ;; any later version. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
17 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
18 ;; GNU Emacs is distributed in the hope that it will be useful, |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
21 ;; GNU General Public License for more details. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
22 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
23 ;; You should have received a copy of the GNU General Public License |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
26 ;; Boston, MA 02111-1307, USA. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
27 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
28 ;;; Commentary: |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
29 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
30 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
31 ;;; Code: |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
32 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
33 (require 'easymenu) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
34 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
35 ;; Define core `PostScript' group. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
36 (defgroup PostScript nil |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
37 "PostScript mode for Emacs." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
38 :group 'languages) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
39 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
40 (defgroup PostScript-edit nil |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
41 "PostScript editing." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
42 :prefix "ps-mode-" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
43 :group 'PostScript) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
44 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
45 (defgroup PostScript-interaction nil |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
46 "PostScript interaction." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
47 :prefix "ps-run-" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
48 :group 'PostScript) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
49 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
50 ;; User variables. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
51 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
52 (defcustom ps-mode-auto-indent t |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
53 "*Should we use autoindent?" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
54 :group 'PostScript-edit |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
55 :type 'boolean) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
56 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
57 (defcustom ps-mode-tab 4 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
58 "*Number of spaces to use when indenting." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
59 :group 'PostScript-edit |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
60 :type 'integer) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
61 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
62 (defcustom ps-mode-paper-size '(595 842) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
63 "*Default paper size. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
64 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
65 When inserting an EPSF template these values are used |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
66 to set the boundingbox to include the whole page. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
67 When the figure is finished these values should be replaced." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
68 :group 'PostScript-edit |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
69 :type '(choice |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
70 (const :tag "letter" (612 792)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
71 (const :tag "legal" (612 1008)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
72 (const :tag "a0" (2380 3368)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
73 (const :tag "a1" (1684 2380)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
74 (const :tag "a2" (1190 1684)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
75 (const :tag "a3" (842 1190)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
76 (const :tag "a4" (595 842)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
77 (const :tag "a5" (421 595)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
78 (const :tag "a6" (297 421)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
79 (const :tag "a7" (210 297)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
80 (const :tag "a8" (148 210)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
81 (const :tag "a9" (105 148)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
82 (const :tag "a10" (74 105)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
83 (const :tag "b0" (2836 4008)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
84 (const :tag "b1" (2004 2836)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
85 (const :tag "b2" (1418 2004)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
86 (const :tag "b3" (1002 1418)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
87 (const :tag "b4" (709 1002)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
88 (const :tag "b5" (501 709)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
89 (const :tag "archE" (2592 3456)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
90 (const :tag "archD" (1728 2592)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
91 (const :tag "archC" (1296 1728)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
92 (const :tag "archB" (864 1296)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
93 (const :tag "archA" (648 864)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
94 (const :tag "flsa" (612 936)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
95 (const :tag "flse" (612 936)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
96 (const :tag "halfletter" (396 612)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
97 (const :tag "11x17" (792 1224)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
98 (const :tag "tabloid" (792 1224)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
99 (const :tag "ledger" (1224 792)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
100 (const :tag "csheet" (1224 1584)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
101 (const :tag "dsheet" (1584 2448)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
102 (const :tag "esheet" (2448 3168)))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
103 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
104 (defcustom ps-mode-print-function '(lambda () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
105 (let ((lpr-switches nil) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
106 (lpr-command \"lpr\")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
107 (lpr-buffer))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
108 "*Lisp function to print current buffer as PostScript." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
109 :group 'PostScript-edit |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
110 :type 'function) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
111 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
112 (defcustom ps-run-prompt "\\(GS\\(<[0-9]+\\)?>\\)+" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
113 "*Regexp to match prompt in interactive PostScript." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
114 :group 'PostScript-interaction |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
115 :type 'regexp) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
116 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
117 (defcustom ps-run-messages |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
118 '((">>showpage, press <return> to continue<<" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
119 (0 font-lock-keyword-face nil nil)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
120 ("^\\(Error\\|Can't\\).*" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
121 (0 font-lock-warning-face nil nil)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
122 ("^\\(Current file position is\\) \\([0-9]+\\)" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
123 (1 font-lock-comment-face nil nil) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
124 (2 font-lock-warning-face nil nil))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
125 "*Medium level highlighting of messages from the PostScript interpreter. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
126 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
127 See documentation on font-lock for details." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
128 :group 'PostScript-interaction |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
129 :type '(repeat (list :tag "Expression with one or more highlighters" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
130 :value ("" (0 default nil t)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
131 (regexp :tag "Expression") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
132 (repeat :tag "Highlighters" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
133 :inline regexp |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
134 (list :tag "Highlighter" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
135 (integer :tag "Subexp") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
136 face |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
137 (boolean :tag "Override") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
138 (boolean :tag "Laxmatch" :value t)))))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
139 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
140 (defcustom ps-run-x '("gs" "-r72" "-sPAPERSIZE=a4") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
141 "*Command as list to run PostScript with graphic display." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
142 :group 'PostScript-interaction |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
143 :type '(repeat string)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
144 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
145 (defcustom ps-run-dumb '("gs" "-dNODISPLAY") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
146 "*Command as list to run PostScript without graphic display." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
147 :group 'PostScript-interaction |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
148 :type '(repeat string)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
149 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
150 (defcustom ps-run-init nil |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
151 "*String of commands to send to PostScript to start interactive. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
152 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
153 Example: \"executive\\n\" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
154 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
155 You won't need to set this option for Ghostscript. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
156 " |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
157 :group 'PostScript-interaction |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
158 :type '(choice (const nil) string)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
159 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
160 (defcustom ps-run-error-line-numbers nil |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
161 "*What values are used by the PostScript interpreter in error messages?" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
162 :group 'PostScript-interaction |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
163 :type '(choice (const :tag "line numbers" t) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
164 (const :tag "byte counts" nil))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
165 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
166 (defcustom ps-run-tmp-dir nil |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
167 "*Name of directory to place temporary file. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
168 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
169 If nil, the following are tried in turn, until success: |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
170 1. \"$TEMP\" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
171 2. \"$TMP\" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
172 3. \"$HOME/tmp\" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
173 4. \"/tmp\" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
174 " |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
175 :group 'PostScript-interaction |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
176 :type '(choice (const nil) directory)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
177 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
178 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
179 ;; Constants used for font-lock. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
180 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
181 ;; Only a small set of the PostScript operators is selected for fontification. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
182 ;; Fontification is meant to clarify the document structure and process flow, |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
183 ;; fontifying all known PostScript operators would hinder that objective. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
184 (defconst ps-mode-operators |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
185 (let ((ops '("clear" "mark" "cleartomark" "counttomark" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
186 "forall" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
187 "dict" "begin" "end" "def" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
188 "true" "false" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
189 "exec" "if" "ifelse" "for" "repeat" "loop" "exit" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
190 "stop" "stopped" "countexecstack" "execstack" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
191 "quit" "start" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
192 "save" "restore" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
193 "bind" "null" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
194 "gsave" "grestore" "grestoreall" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
195 "showpage"))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
196 (concat "\\<" (regexp-opt ops t) "\\>")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
197 "Regexp of PostScript operators that will be fontified") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
198 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
199 ;; Level 1 font-lock: |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
200 ;; - Special comments (reference face) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
201 ;; - Strings and other comments |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
202 ;; - Partial strings (warning face) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
203 ;; - 8bit characters (warning face) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
204 ;; Multiline strings are not supported. Strings with nested brackets are. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
205 (defconst ps-mode-font-lock-keywords-1 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
206 '(("\\`%!PS.*" . font-lock-reference-face) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
207 ("^%%BoundingBox:[ \t]+-?[0-9]+[ \t]+-?[0-9]+[ \t]+-?[0-9]+[ \t]+-?[0-9]+[ \t]*$" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
208 . font-lock-reference-face) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
209 (ps-mode-match-string-or-comment |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
210 (1 font-lock-comment-face nil t) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
211 (2 font-lock-string-face nil t)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
212 ("([^()\n%]*\\|[^()\n]*)" . font-lock-warning-face) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
213 ("[\200-\377]+" (0 font-lock-warning-face prepend nil))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
214 "Subdued level highlighting for PostScript mode.") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
215 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
216 ;; Level 2 font-lock: |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
217 ;; - All from level 1 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
218 ;; - PostScript operators (keyword face) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
219 (defconst ps-mode-font-lock-keywords-2 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
220 (append |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
221 ps-mode-font-lock-keywords-1 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
222 (list |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
223 (cons |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
224 ;; exclude names prepended by `/' |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
225 (concat "\\(^\\|[^/\n]\\)" ps-mode-operators) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
226 '(2 font-lock-keyword-face)))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
227 "Medium level highlighting for PostScript mode.") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
228 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
229 ;; Level 3 font-lock: |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
230 ;; - All from level 2 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
231 ;; - Immediately evaluated names: those starting with `//' (type face) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
232 ;; - Names that look like they are used for the definition of: |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
233 ;; * a function |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
234 ;; * an array |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
235 ;; * a dictionary |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
236 ;; * a "global" variable |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
237 ;; (function name face) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
238 ;; - Other names (variable name face) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
239 ;; The rules used to determine what names fit in the first category are: |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
240 ;; - Only names that are at the left margin, and one of these on the same line: |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
241 ;; * Nothing after the name except possibly one or more `[' or a comment |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
242 ;; * A `{' or `<<' or `[0-9]+ dict' following the name |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
243 ;; * A `def' somewhere in the same line |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
244 ;; Names are fontified before PostScript operators, allowing the use of |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
245 ;; a more simple (efficient) regexp than the one used in level 2. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
246 (defconst ps-mode-font-lock-keywords-3 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
247 (append |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
248 ps-mode-font-lock-keywords-1 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
249 (list |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
250 '("//\\w+" . font-lock-type-face) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
251 '("^\\(/\\w+\\)\\>[[ \t]*\\(%.*\\)?\r?$" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
252 . (1 font-lock-function-name-face)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
253 '("^\\(/\\w+\\)\\>\\([ \t]*{\\|[ \t]*<<\\|.*\\<def\\>\\|[ \t]+[0-9]+[ \t]+dict\\>\\)" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
254 . (1 font-lock-function-name-face)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
255 '("/\\w+" . font-lock-variable-name-face) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
256 (cons ps-mode-operators 'font-lock-keyword-face))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
257 "High level highliting for PostScript mode.") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
258 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
259 (defconst ps-mode-font-lock-keywords ps-mode-font-lock-keywords-1 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
260 "Default expressions to highlight in PostScript mode.") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
261 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
262 ;; Level 1 font-lock for ps-run-mode |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
263 ;; - prompt (function name face) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
264 (defconst ps-run-font-lock-keywords-1 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
265 (unless (or (not (stringp ps-run-prompt)) (string= "" ps-run-prompt)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
266 (list (cons (concat "^" ps-run-prompt) 'font-lock-function-name-face))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
267 "Subdued level highlighting for PostScript run mode.") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
268 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
269 (defconst ps-run-font-lock-keywords ps-run-font-lock-keywords-1 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
270 "Default expressions to highlight in PostScript run mode.") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
271 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
272 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
273 ;; Variables. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
274 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
275 (defvar ps-mode-map nil |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
276 "Local keymap to use in PostScript mode.") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
277 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
278 (defvar ps-mode-syntax-table nil |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
279 "Syntax table used while in PostScript mode.") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
280 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
281 (defvar ps-run-mode-map nil |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
282 "Local keymap to use in PostScript run mode.") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
283 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
284 (defvar ps-mode-tmp-file nil |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
285 "Name of temporary file, set by `ps-run'.") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
286 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
287 (defvar ps-run-mark nil |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
288 "Mark to start of region that was sent to PostScript interpreter.") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
289 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
290 (defvar ps-run-parent nil |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
291 "Parent window of interactive PostScript.") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
292 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
293 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
294 ;; Menu |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
295 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
296 (defconst ps-mode-menu-main |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
297 '("PostScript" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
298 ["EPSF Template, Sparse" ps-mode-epsf-sparse t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
299 ["EPSF Template, Rich" ps-mode-epsf-rich t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
300 "---" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
301 ("Cookbook" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
302 ["RE" ps-mode-RE t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
303 ["ISOLatin1Extended" ps-mode-latin-extended t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
304 ["center" ps-mode-center t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
305 ["right" ps-mode-right t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
306 ["Heapsort" ps-mode-heapsort t]) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
307 ("Fonts (1)" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
308 ["Times-Roman" (insert "/Times-Roman ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
309 ["Times-Bold" (insert "/Times-Bold ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
310 ["Times-Italic" (insert "/Times-Italic ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
311 ["Times-BoldItalic" (insert "/Times-BoldItalic ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
312 ["Helvetica" (insert "/Helvetica ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
313 ["Helvetica-Bold" (insert "/Helvetica-Bold ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
314 ["Helvetica-Oblique" (insert "/Helvetica-Oblique ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
315 ["Helvetica-BoldOblique" (insert "/Helvetica-BoldOblique ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
316 ["Courier" (insert "/Courier ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
317 ["Courier-Bold" (insert "/Courier-Bold ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
318 ["Courier-Oblique" (insert "/Courier-Oblique ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
319 ["Courier-BoldOblique" (insert "/Courier-BoldOblique ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
320 ["Symbol" (insert "/Symbol") t ]) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
321 ("Fonts (2)" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
322 ["AvantGarde-Book" (insert "/AvantGarde-Book ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
323 ["AvantGarde-Demi" (insert "/AvantGarde-Demi ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
324 ["AvantGarde-BookOblique" (insert "/AvantGarde-BookOblique ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
325 ["AvantGarde-DemiOblique" (insert "/AvantGarde-DemiOblique ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
326 ["Bookman-Light" (insert "/Bookman-Light ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
327 ["Bookman-Demi" (insert "/Bookman-Demi ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
328 ["Bookman-LightItalic" (insert "/Bookman-LightItalic ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
329 ["Bookman-DemiItalic" (insert "/Bookman-DemiItalic ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
330 ["Helvetica-Narrow" (insert "/Helvetica-Narrow ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
331 ["Helvetica-Narrow-Bold" (insert "/Helvetica-Narrow-Bold ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
332 ["Helvetica-Narrow-Oblique" (insert "/Helvetica-Narrow-Oblique ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
333 ["Helvetica-Narrow-BoldOblique" (insert "/Helvetica-Narrow-BoldOblique ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
334 ["NewCenturySchlbk-Roman" (insert "/NewCenturySchlbk-Roman ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
335 ["NewCenturySchlbk-Bold" (insert "/NewCenturySchlbk-Bold ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
336 ["NewCenturySchlbk-Italic" (insert "/NewCenturySchlbk-Italic ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
337 ["NewCenturySchlbk-BoldItalic" (insert "/NewCenturySchlbk-BoldItalic ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
338 ["Palatino-Roman" (insert "/Palatino-Roman ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
339 ["Palatino-Bold" (insert "/Palatino-Bold ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
340 ["Palatino-Italic" (insert "/Palatino-Italic ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
341 ["Palatino-BoldItalic" (insert "/Palatino-BoldItalic ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
342 ["ZapfChancery-MediumItalic" (insert "/ZapfChancery-MediumItalic ") t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
343 ["ZapfDingbats" (insert "/ZapfDingbats ") t]) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
344 "---" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
345 ["Comment Out Region" ps-mode-comment-out-region (mark t)] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
346 ["Uncomment Region" ps-mode-uncomment-region (mark t)] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
347 "---" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
348 ["8-bit to Octal Buffer" ps-mode-octal-buffer t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
349 ["8-bit to Octal Region" ps-mode-octal-region (mark t)] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
350 "---" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
351 ("Auto Indent" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
352 ["On" (setq ps-mode-auto-indent t) (not ps-mode-auto-indent)] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
353 ["Off" (setq ps-mode-auto-indent nil) ps-mode-auto-indent]) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
354 "---" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
355 ["Start PostScript" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
356 ps-run-start |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
357 t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
358 ["Quit PostScript" ps-run-quit (process-status "ps-run")] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
359 ["Kill PostScript" ps-run-kill (process-status "ps-run")] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
360 ["Send Buffer to Interpreter" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
361 ps-run-buffer |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
362 (process-status "ps-run")] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
363 ["Send Region to Interpreter" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
364 ps-run-region |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
365 (and (mark t) (process-status "ps-run"))] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
366 ["Send Newline to Interpreter" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
367 ps-mode-other-newline |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
368 (process-status "ps-run")] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
369 ["View BoundingBox" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
370 ps-run-boundingbox |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
371 (process-status "ps-run")] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
372 ["Clear/Reset PostScript Graphics" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
373 ps-run-clear |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
374 (process-status "ps-run")] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
375 "---" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
376 ["Print Buffer as PostScript" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
377 ps-mode-print-buffer |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
378 t] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
379 ["Print Region as PostScript" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
380 ps-mode-print-region |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
381 (mark t)] |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
382 "---" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
383 ["Customize for PostScript" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
384 (customize-group "PostScript") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
385 t])) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
386 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
387 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
388 ;; Mode maps for PostScript edit mode and PostScript interaction mode. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
389 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
390 (unless ps-mode-map |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
391 (setq ps-mode-map (make-sparse-keymap)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
392 (define-key ps-mode-map [return] 'ps-mode-newline) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
393 (define-key ps-mode-map "\r" 'ps-mode-newline) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
394 (define-key ps-mode-map "\t" 'ps-mode-tabkey) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
395 (define-key ps-mode-map "\177" 'ps-mode-backward-delete-char) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
396 (define-key ps-mode-map "}" 'ps-mode-r-brace) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
397 (define-key ps-mode-map "]" 'ps-mode-r-angle) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
398 (define-key ps-mode-map ">" 'ps-mode-r-gt) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
399 (define-key ps-mode-map "\C-c\C-b" 'ps-run-buffer) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
400 (define-key ps-mode-map "\C-c\C-c" 'ps-run-clear) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
401 (define-key ps-mode-map "\C-c\C-j" 'ps-mode-other-newline) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
402 (define-key ps-mode-map "\C-c\C-k" 'ps-run-kill) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
403 (define-key ps-mode-map "\C-c\C-o" 'ps-mode-comment-out-region) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
404 (define-key ps-mode-map "\C-c\C-p" 'ps-mode-print-buffer) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
405 (define-key ps-mode-map "\C-c\C-q" 'ps-run-quit) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
406 (define-key ps-mode-map "\C-c\C-r" 'ps-run-region) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
407 (define-key ps-mode-map "\C-c\C-s" 'ps-run-start) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
408 (define-key ps-mode-map "\C-c\C-t" 'ps-mode-epsf-rich) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
409 (define-key ps-mode-map "\C-c\C-u" 'ps-mode-uncomment-region) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
410 (define-key ps-mode-map "\C-c\C-v" 'ps-run-boundingbox) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
411 (easy-menu-define ps-mode-main ps-mode-map "PostScript" ps-mode-menu-main)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
412 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
413 (unless ps-run-mode-map |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
414 (setq ps-run-mode-map (make-sparse-keymap)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
415 (define-key ps-run-mode-map [return] 'ps-run-newline) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
416 (define-key ps-run-mode-map "\r" 'ps-run-newline) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
417 (define-key ps-run-mode-map "\C-c\C-q" 'ps-run-quit) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
418 (define-key ps-run-mode-map "\C-c\C-k" 'ps-run-kill) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
419 (define-key ps-run-mode-map "\C-c\C-e" 'ps-run-goto-error) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
420 (define-key ps-run-mode-map [mouse-2] 'ps-run-mouse-goto-error)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
421 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
422 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
423 ;; Syntax table. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
424 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
425 (unless ps-mode-syntax-table |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
426 (setq ps-mode-syntax-table (make-syntax-table)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
427 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
428 (modify-syntax-entry ?\% "< " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
429 (modify-syntax-entry ?\n "> " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
430 (modify-syntax-entry ?\r "> " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
431 (modify-syntax-entry ?\f "> " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
432 (modify-syntax-entry ?\< "(>" ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
433 (modify-syntax-entry ?\> ")<" ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
434 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
435 (modify-syntax-entry ?\! "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
436 (modify-syntax-entry ?\" "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
437 (modify-syntax-entry ?\# "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
438 (modify-syntax-entry ?\$ "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
439 (modify-syntax-entry ?\& "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
440 (modify-syntax-entry ?\' "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
441 (modify-syntax-entry ?\* "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
442 (modify-syntax-entry ?\+ "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
443 (modify-syntax-entry ?\, "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
444 (modify-syntax-entry ?\- "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
445 (modify-syntax-entry ?\. "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
446 (modify-syntax-entry ?\: "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
447 (modify-syntax-entry ?\; "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
448 (modify-syntax-entry ?\= "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
449 (modify-syntax-entry ?\? "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
450 (modify-syntax-entry ?\@ "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
451 (modify-syntax-entry ?\\ "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
452 (modify-syntax-entry ?^ "w " ps-mode-syntax-table) ; NOT: ?\^ |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
453 (modify-syntax-entry ?\_ "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
454 (modify-syntax-entry ?\` "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
455 (modify-syntax-entry ?\| "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
456 (modify-syntax-entry ?\~ "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
457 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
458 (let ((i 128)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
459 (while (< i 256) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
460 (modify-syntax-entry i "w " ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
461 (setq i (1+ i))))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
462 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
463 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
464 ;; PostScript mode. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
465 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
466 ;;;###autoload |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
467 (defun ps-mode () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
468 "Major mode for editing PostScript with GNU Emacs. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
469 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
470 Entry to this mode calls `ps-mode-hook'. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
471 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
472 The following variables hold user options, and can |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
473 be set through the `customize' command: |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
474 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
475 ps-mode-auto-indent |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
476 ps-mode-tab |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
477 ps-mode-paper-size |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
478 ps-mode-print-function |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
479 ps-run-tmp-dir |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
480 ps-run-prompt |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
481 ps-run-x |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
482 ps-run-dumb |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
483 ps-run-init |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
484 ps-run-error-line-numbers |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
485 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
486 Type \\[describe-variable] for documentation on these options. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
487 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
488 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
489 \\{ps-mode-map} |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
490 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
491 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
492 When starting an interactive PostScript process with \\[ps-run-start], |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
493 a second window will be displayed, and `ps-run-mode-hook' will be called. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
494 The keymap for this second window is: |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
495 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
496 \\{ps-run-mode-map} |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
497 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
498 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
499 When Ghostscript encounters an error it displays an error message |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
500 with a file position. Clicking mouse-2 on this number will bring |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
501 point to the corresponding spot in the PostScript window, if input |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
502 to the interpreter was sent from that window. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
503 Typing \\<ps-run-mode-map>\\[ps-run-goto-error] when the cursor is at the number has the same effect. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
504 " |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
505 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
506 (kill-all-local-variables) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
507 (make-local-variable 'font-lock-defaults) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
508 (setq font-lock-defaults '((ps-mode-font-lock-keywords |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
509 ps-mode-font-lock-keywords-1 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
510 ps-mode-font-lock-keywords-2 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
511 ps-mode-font-lock-keywords-3) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
512 t) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
513 major-mode 'ps-mode |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
514 mode-name "PostScript") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
515 (use-local-map ps-mode-map) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
516 (set-syntax-table ps-mode-syntax-table) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
517 (run-hooks 'ps-mode-hook)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
518 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
519 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
520 ;; Helper functions for font-lock. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
521 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
522 ;; When this function is called, point is at an opening bracket. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
523 ;; This function should test if point is at the start of a string |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
524 ;; with nested brackets. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
525 ;; If true: move point to end of string |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
526 ;; set string to match data nr 2 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
527 ;; return new point |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
528 ;; If false: return nil |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
529 (defun ps-mode-looking-at-nested (limit) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
530 (let ((first (point)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
531 (level 1) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
532 pos) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
533 ;; Move past opening bracket. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
534 (forward-char 1) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
535 (setq pos (point)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
536 (while (and (> level 0) (< pos limit)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
537 ;; Search next bracket, stepping over escaped brackets. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
538 (if (not (looking-at "\\([^()\\\n]\\|\\\\.\\)*\\([()]\\)")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
539 (setq level -1) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
540 (if (string= "(" (match-string 2)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
541 (setq level (1+ level)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
542 (setq level (1- level))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
543 (goto-char (setq pos (match-end 0))))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
544 (if (not (= level 0)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
545 nil |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
546 ;; Found string with nested brackets, now set match data nr 2. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
547 (goto-char first) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
548 (re-search-forward "\\(%\\)\\|\\((.*\\)" pos)))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
549 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
550 ;; This function should search for a string or comment |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
551 ;; If comment, return as match data nr 1 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
552 ;; If string, return as match data nr 2 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
553 (defun ps-mode-match-string-or-comment (limit) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
554 ;; Find the first potential match. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
555 (if (not (re-search-forward "[%(]" limit t)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
556 ;; Nothing found: return failure. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
557 nil |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
558 (let (end) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
559 (goto-char (match-beginning 0)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
560 (setq end (match-end 0)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
561 (cond ((looking-at "\\(%.*\\)\\|\\((\\([^()\\\n]\\|\\\\.\\)*)\\)") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
562 ;; It's a comment or string without nested, unescaped brackets. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
563 (goto-char (match-end 0)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
564 (point)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
565 ((ps-mode-looking-at-nested limit) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
566 ;; It's a string with nested brackets. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
567 (point)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
568 (t |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
569 ;; Try next match. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
570 (goto-char end) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
571 (ps-mode-match-string-or-comment limit)))))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
572 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
573 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
574 ;; Key-handlers. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
575 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
576 (defun ps-mode-target-column () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
577 "To what column should text on current line be indented? |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
578 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
579 Identation is increased if the last token on the current line |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
580 defines the beginning of a group. These tokens are: { [ <<" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
581 (save-excursion |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
582 (beginning-of-line) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
583 (if (looking-at "[ \t]*\\(}\\|\\]\\|>>\\)") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
584 (condition-case err |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
585 (progn |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
586 (goto-char (match-end 0)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
587 (backward-sexp 1) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
588 (beginning-of-line) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
589 (if (looking-at "[ \t]+") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
590 (goto-char (match-end 0))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
591 (current-column)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
592 (error |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
593 (ding) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
594 (message (error-message-string err)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
595 0)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
596 (let (target) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
597 (if (not (re-search-backward "[^ \t\n\r\f][ \t\n\r\f]*\\=" nil t)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
598 0 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
599 (goto-char (match-beginning 0)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
600 (beginning-of-line) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
601 (if (looking-at "[ \t]+") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
602 (goto-char (match-end 0))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
603 (setq target (current-column)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
604 (end-of-line) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
605 (if (re-search-backward "\\({\\|\\[\\|<<\\)[ \t]*\\(%[^\n]*\\)?\\=" nil t) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
606 (setq target (+ target ps-mode-tab))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
607 target))))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
608 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
609 (defun ps-mode-newline () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
610 "Insert newline with proper indentation." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
611 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
612 (delete-horizontal-space) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
613 (insert "\n") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
614 (if ps-mode-auto-indent |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
615 (indent-to (ps-mode-target-column)))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
616 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
617 (defun ps-mode-tabkey () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
618 "Indent/reindent current line, or insert tab" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
619 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
620 (let ((column (current-column)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
621 target) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
622 (if (or (not ps-mode-auto-indent) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
623 (< ps-mode-tab 1) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
624 (not (re-search-backward "^[ \t]*\\=" nil t))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
625 (insert "\t") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
626 (setq target (ps-mode-target-column)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
627 (while (<= target column) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
628 (setq target (+ target ps-mode-tab))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
629 (delete-horizontal-space) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
630 (indent-to target)))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
631 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
632 (defun ps-mode-backward-delete-char () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
633 "Delete backward indentation, or delete backward character" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
634 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
635 (let ((column (current-column)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
636 target) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
637 (if (or (not ps-mode-auto-indent) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
638 (< ps-mode-tab 1) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
639 (not (re-search-backward "^[ \t]+\\=" nil t))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
640 (delete-backward-char 1) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
641 (setq target (ps-mode-target-column)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
642 (while (> column target) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
643 (setq target (+ target ps-mode-tab))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
644 (while (>= target column) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
645 (setq target (- target ps-mode-tab))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
646 (if (< target 0) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
647 (setq target 0)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
648 (delete-horizontal-space) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
649 (indent-to target)))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
650 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
651 (defun ps-mode-r-brace () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
652 "Insert `}' and perform balance." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
653 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
654 (insert "}") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
655 (ps-mode-r-balance "}")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
656 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
657 (defun ps-mode-r-angle () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
658 "Insert `]' and perform balance." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
659 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
660 (insert "]") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
661 (ps-mode-r-balance "]")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
662 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
663 (defun ps-mode-r-gt () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
664 "Insert `>' and perform balance." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
665 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
666 (insert ">") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
667 (ps-mode-r-balance ">>")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
668 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
669 (defun ps-mode-r-balance (right) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
670 "Adjust indentification if point after RIGHT." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
671 (if ps-mode-auto-indent |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
672 (save-excursion |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
673 (when (re-search-backward (concat "^[ \t]*" (regexp-quote right) "\\=") nil t) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
674 (delete-horizontal-space) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
675 (indent-to (ps-mode-target-column))))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
676 (blink-matching-open)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
677 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
678 (defun ps-mode-other-newline () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
679 "Perform newline in `*ps run*' buffer" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
680 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
681 (let ((buf (current-buffer))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
682 (set-buffer "*ps run*") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
683 (ps-run-newline) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
684 (set-buffer buf))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
685 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
686 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
687 ;; Print PostScript. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
688 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
689 (defun ps-mode-print-buffer () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
690 "Print buffer as PostScript" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
691 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
692 (eval (list ps-mode-print-function))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
693 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
694 (defun ps-mode-print-region (begin end) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
695 "Print region as PostScript, adding minimal header and footer lines: |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
696 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
697 %!PS |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
698 <region> |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
699 showpage |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
700 " |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
701 (interactive "r") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
702 (let ((oldbuf (current-buffer)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
703 (tmpbuf (get-buffer-create "*ps print*"))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
704 (copy-to-buffer tmpbuf begin end) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
705 (set-buffer tmpbuf) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
706 (goto-char 1) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
707 (insert "%!PS\n") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
708 (goto-char (point-max)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
709 (insert "\nshowpage\n") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
710 (eval (list ps-mode-print-function)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
711 (set-buffer oldbuf) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
712 (kill-buffer tmpbuf))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
713 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
714 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
715 ;; Comment Out / Uncomment. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
716 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
717 (defun ps-mode-comment-out-region (begin end) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
718 "Comment out region." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
719 (interactive "r") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
720 (let ((endm (make-marker))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
721 (set-marker endm end) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
722 (save-excursion |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
723 (goto-char begin) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
724 (if (= (current-column) 0) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
725 (insert "%")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
726 (while (and (= (forward-line) 0) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
727 (< (point) (marker-position endm))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
728 (insert "%"))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
729 (set-marker endm nil))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
730 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
731 (defun ps-mode-uncomment-region (begin end) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
732 "Uncomment region. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
733 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
734 Only one `%' is removed, and it has to be in the first column." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
735 (interactive "r") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
736 (let ((endm (make-marker))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
737 (set-marker endm end) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
738 (save-excursion |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
739 (goto-char begin) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
740 (if (looking-at "^%") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
741 (delete-char 1)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
742 (while (and (= (forward-line) 0) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
743 (< (point) (marker-position endm))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
744 (if (looking-at "%") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
745 (delete-char 1)))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
746 (set-marker endm nil))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
747 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
748 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
749 ;; Convert 8-bit to octal codes. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
750 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
751 (defun ps-mode-octal-buffer () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
752 "Change 8-bit characters to octal codes in buffer." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
753 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
754 (ps-mode-octal-region (point-min) (point-max))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
755 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
756 (defun ps-mode-octal-region (begin end) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
757 "Change 8-bit characters to octal codes in region." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
758 (interactive "r") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
759 (if buffer-read-only |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
760 (progn |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
761 (ding) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
762 (message "Buffer is read only")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
763 (save-excursion |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
764 (let (endm i) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
765 (setq endm (make-marker)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
766 (set-marker endm end) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
767 (goto-char begin) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
768 (setq i 0) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
769 (while (re-search-forward "[\200-\377]" (marker-position endm) t) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
770 (setq i (1+ i)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
771 (backward-char) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
772 (insert (format "\\%03o" (string-to-char (buffer-substring (point) (1+ (point)))))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
773 (delete-char 1)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
774 (message (format "%d change%s made" i (if (= i 1) "" "s"))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
775 (set-marker endm nil))))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
776 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
777 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
778 ;; Cookbook. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
779 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
780 (defun ps-mode-center () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
781 "Insert function /center." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
782 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
783 (insert " |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
784 /center { |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
785 dup stringwidth |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
786 exch 2 div neg |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
787 exch 2 div neg |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
788 rmoveto |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
789 } bind def |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
790 ")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
791 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
792 (defun ps-mode-right () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
793 "Insert function /right." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
794 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
795 (insert " |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
796 /right { |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
797 dup stringwidth |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
798 exch neg |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
799 exch neg |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
800 rmoveto |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
801 } bind def |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
802 ")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
803 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
804 (defun ps-mode-RE () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
805 "Insert function /RE." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
806 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
807 (insert " |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
808 % `new-font-name' `encoding-vector' `old-font-name' RE - |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
809 /RE { |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
810 findfont |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
811 dup maxlength dict begin { |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
812 1 index /FID ne { def } { pop pop } ifelse |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
813 } forall |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
814 /Encoding exch def |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
815 dup /FontName exch def |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
816 currentdict end definefont pop |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
817 } bind def |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
818 ")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
819 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
820 (defun ps-mode-latin-extended () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
821 "Insert array /ISOLatin1Extended. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
822 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
823 This encoding vector contains all the entries from ISOLatin1Encoding |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
824 plus the usually uncoded characters inserted on positions 1 through 28. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
825 " |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
826 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
827 (insert " |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
828 % ISOLatin1Encoding, extended with remaining uncoded glyphs |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
829 /ISOLatin1Extended [ |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
830 /.notdef /Lslash /lslash /OE /oe /Scaron /scaron /Zcaron /zcaron |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
831 /Ydieresis /trademark /bullet /dagger /daggerdbl /ellipsis /emdash |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
832 /endash /fi /fl /florin /fraction /guilsinglleft /guilsinglright |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
833 /perthousand /quotedblbase /quotedblleft /quotedblright |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
834 /quotesinglbase /quotesingle /.notdef /.notdef /.notdef /space |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
835 /exclam /quotedbl /numbersign /dollar /percent /ampersand |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
836 /quoteright /parenleft /parenright /asterisk /plus /comma /minus |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
837 /period /slash /zero /one /two /three /four /five /six /seven /eight |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
838 /nine /colon /semicolon /less /equal /greater /question /at /A /B /C |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
839 /D /E /F /G /H /I /J /K /L /M /N /O /P /Q /R /S /T /U /V /W /X /Y /Z |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
840 /bracketleft /backslash /bracketright /asciicircum /underscore |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
841 /quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o /p /q /r /s |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
842 /t /u /v /w /x /y /z /braceleft /bar /braceright /asciitilde |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
843 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
844 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
845 /.notdef /.notdef /.notdef /dotlessi /grave /acute /circumflex |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
846 /tilde /macron /breve /dotaccent /dieresis /.notdef /ring /cedilla |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
847 /.notdef /hungarumlaut /ogonek /caron /space /exclamdown /cent |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
848 /sterling /currency /yen /brokenbar /section /dieresis /copyright |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
849 /ordfeminine /guillemotleft /logicalnot /hyphen /registered /macron |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
850 /degree /plusminus /twosuperior /threesuperior /acute /mu /paragraph |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
851 /periodcentered /cedilla /onesuperior /ordmasculine /guillemotright |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
852 /onequarter /onehalf /threequarters /questiondown /Agrave /Aacute |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
853 /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla /Egrave /Eacute |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
854 /Ecircumflex /Edieresis /Igrave /Iacute /Icircumflex /Idieresis /Eth |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
855 /Ntilde /Ograve /Oacute /Ocircumflex /Otilde /Odieresis /multiply |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
856 /Oslash /Ugrave /Uacute /Ucircumflex /Udieresis /Yacute /Thorn |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
857 /germandbls /agrave /aacute /acircumflex /atilde /adieresis /aring |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
858 /ae /ccedilla /egrave /eacute /ecircumflex /edieresis /igrave |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
859 /iacute /icircumflex /idieresis /eth /ntilde /ograve /oacute |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
860 /ocircumflex /otilde /odieresis /divide /oslash /ugrave /uacute |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
861 /ucircumflex /udieresis /yacute /thorn /ydieresis |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
862 ] def |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
863 ")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
864 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
865 (defun ps-mode-heapsort () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
866 "Insert function /Heapsort." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
867 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
868 (insert " |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
869 % `array-element' Heapsort-cvi-or-cvr-or-cvs `number-or-string' |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
870 /Heapsort-cvi-or-cvr-or-cvs { |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
871 % 0 get |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
872 } bind def |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
873 % `array' Heapsort `sorted-array' |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
874 /Heapsort { |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
875 dup length /hsR exch def |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
876 /hsL hsR 2 idiv 1 add def |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
877 { |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
878 hsR 2 lt { exit } if |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
879 hsL 1 gt { |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
880 /hsL hsL 1 sub def |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
881 } { |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
882 /hsR hsR 1 sub def |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
883 dup dup dup 0 get exch dup hsR get |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
884 0 exch put |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
885 hsR exch put |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
886 } ifelse |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
887 dup hsL 1 sub get /hsT exch def |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
888 /hsJ hsL def |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
889 { |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
890 /hsS hsJ def |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
891 /hsJ hsJ dup add def |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
892 hsJ hsR gt { exit } if |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
893 hsJ hsR lt { |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
894 dup dup hsJ 1 sub get Heapsort-cvi-or-cvr-or-cvs |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
895 exch hsJ get Heapsort-cvi-or-cvr-or-cvs |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
896 lt { /hsJ hsJ 1 add def } if |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
897 } if |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
898 dup hsJ 1 sub get Heapsort-cvi-or-cvr-or-cvs |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
899 hsT Heapsort-cvi-or-cvr-or-cvs |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
900 le { exit } if |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
901 dup dup hsS 1 sub exch hsJ 1 sub get put |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
902 } loop |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
903 dup hsS 1 sub hsT put |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
904 } loop |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
905 } bind def |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
906 ")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
907 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
908 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
909 ;; EPSF document lay-out. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
910 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
911 (defun ps-mode-epsf-sparse () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
912 "Insert sparse EPSF template." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
913 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
914 (goto-char (point-max)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
915 (unless (re-search-backward "%%EOF[ \t\n]*\\'" nil t) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
916 (goto-char (point-max)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
917 (insert "\n%%EOF\n")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
918 (goto-char (point-max)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
919 (unless (re-search-backward "\\bshowpage[ \t\n]+%%EOF[ \t\n]*\\'" nil t) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
920 (re-search-backward "%%EOF") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
921 (insert "showpage\n")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
922 (goto-char (point-max)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
923 (unless (re-search-backward "\\bend[ \t\n]+\\bshowpage[ \t\n]+%%EOF[ \t\n]*\\'" nil t) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
924 (re-search-backward "showpage") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
925 (insert "\nend\n")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
926 (goto-char (point-min)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
927 (insert "%!PS-Adobe-3.0 EPSF-3.0\n%%BoundingBox: 0 0 ") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
928 (insert (format "%d %d\n\n" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
929 (car ps-mode-paper-size) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
930 (car (cdr ps-mode-paper-size)))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
931 (insert "64 dict begin\n\n")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
932 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
933 (defun ps-mode-epsf-rich () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
934 "Insert rich EPSF template." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
935 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
936 (ps-mode-epsf-sparse) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
937 (forward-line -3) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
938 (when buffer-file-name |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
939 (insert "%%Title: " (file-name-nondirectory buffer-file-name) "\n")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
940 (insert "%%Creator: " (user-full-name) "\n") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
941 (insert "%%CreationDate: " (current-time-string) "\n") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
942 (insert "%%EndComments\n") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
943 (forward-line 3)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
944 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
945 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
946 ;; Interactive PostScript interpreter. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
947 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
948 (defun ps-run-mode () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
949 "Major mode in interactive PostScript window. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
950 This mode is invoked from ps-mode and should not be called directly. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
951 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
952 \\{ps-run-mode-map} |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
953 " |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
954 (kill-all-local-variables) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
955 (make-local-variable 'font-lock-defaults) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
956 (setq font-lock-defaults (list (list 'ps-run-font-lock-keywords |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
957 'ps-run-font-lock-keywords-1 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
958 (append |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
959 ps-run-font-lock-keywords-1 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
960 ps-run-messages)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
961 t) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
962 major-mode 'ps-run-mode |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
963 mode-name "Interactive PS" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
964 mode-line-process '(":%s")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
965 (use-local-map ps-run-mode-map) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
966 (run-hooks 'ps-run-mode-hook)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
967 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
968 (defun ps-run-running () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
969 "Error if not in ps-mode or not running PostScript." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
970 (unless (equal major-mode 'ps-mode) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
971 (error "This function can only be called from PostScript mode")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
972 (unless (equal (process-status "ps-run") 'run) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
973 (error "No PostScript process running"))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
974 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
975 (defun ps-run-start () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
976 "Start interactive PostScript." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
977 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
978 (let ((command (if (and window-system ps-run-x) ps-run-x ps-run-dumb)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
979 (init-file nil) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
980 (process-connection-type nil) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
981 (oldbuf (current-buffer)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
982 (oldwin (selected-window)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
983 i) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
984 (unless command |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
985 (error "No command specified to run interactive PostScript")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
986 (unless (and ps-run-mark (markerp ps-run-mark)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
987 (setq ps-run-mark (make-marker))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
988 (when ps-run-init |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
989 (setq init-file (ps-run-make-tmp-filename)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
990 (write-region ps-run-init 0 init-file) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
991 (setq init-file (list init-file))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
992 (pop-to-buffer "*ps run*") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
993 (ps-run-mode) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
994 (when (process-status "ps-run") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
995 (delete-process "ps-run")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
996 (erase-buffer) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
997 (setq i (append command init-file)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
998 (while i |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
999 (insert (car i) (if (cdr i) " " "\n")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1000 (setq i (cdr i))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1001 (eval (append '(start-process "ps-run" "*ps run*") command init-file)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1002 (select-window oldwin))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1003 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1004 (defun ps-run-quit () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1005 "Quit interactive PostScript." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1006 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1007 (ps-run-send-string "quit" t) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1008 (ps-run-cleanup)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1009 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1010 (defun ps-run-kill () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1011 "Kill interactive PostScript." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1012 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1013 (delete-process "ps-run") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1014 (ps-run-cleanup)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1015 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1016 (defun ps-run-clear () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1017 "Clear/reset PostScript graphics." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1018 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1019 (ps-run-send-string "showpage" t) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1020 (sit-for 1) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1021 (ps-run-send-string "" t)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1022 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1023 (defun ps-run-buffer () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1024 "Send buffer to PostScript interpreter." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1025 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1026 (ps-run-region (point-min) (point-max))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1027 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1028 (defun ps-run-region (begin end) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1029 "Send region to PostScript interpreter." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1030 (interactive "r") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1031 (ps-run-running) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1032 (setq ps-run-parent (buffer-name)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1033 (let ((f (ps-run-make-tmp-filename))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1034 (set-marker ps-run-mark begin) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1035 (write-region begin end f) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1036 (ps-run-send-string (format "(%s) run" f) t))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1037 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1038 (defun ps-run-boundingbox () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1039 "View BoundingBox" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1040 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1041 (ps-run-running) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1042 (let (x1 y1 x2 y2 f |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1043 (buf (current-buffer))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1044 (save-excursion |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1045 (goto-char 1) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1046 (re-search-forward |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1047 "^%%BoundingBox:[ \t]+\\(-?[0-9]+\\)[ \t]+\\(-?[0-9]+\\)[ \t]+\\(-?[0-9]+\\)[ \t]+\\(-?[0-9]+\\)") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1048 (setq x1 (match-string 1) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1049 y1 (match-string 2) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1050 x2 (match-string 3) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1051 y2 (match-string 4))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1052 (unless (< (string-to-number x1) (string-to-number x2)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1053 (error "x1 (%s) should be less than x2 (%s)" x1 x2)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1054 (unless (< (string-to-number y1) (string-to-number y2)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1055 (error "y1 (%s) should be less than y2 (%s)" y1 y2)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1056 (setq f (ps-run-make-tmp-filename)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1057 (write-region |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1058 (format |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1059 "gsave |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1060 initgraphics |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1061 2 setlinewidth |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1062 %s %s moveto |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1063 %s %s lineto |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1064 %s %s lineto |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1065 %s %s lineto |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1066 closepath |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1067 gsave |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1068 [ 4 20 ] 0 setdash |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1069 1 0 0 setrgbcolor |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1070 stroke |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1071 grestore |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1072 gsave |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1073 [ 4 20 ] 8 setdash |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1074 0 1 0 setrgbcolor |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1075 stroke |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1076 grestore |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1077 [ 4 20 ] 16 setdash |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1078 0 0 1 setrgbcolor |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1079 stroke |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1080 grestore |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1081 " x1 y1 x2 y1 x2 y2 x1 y2) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1082 0 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1083 f) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1084 (ps-run-send-string (format "(%s) run" f) t) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1085 (set-buffer buf))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1086 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1087 (defun ps-run-send-string (string &optional echo) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1088 (let ((oldwin (selected-window))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1089 (pop-to-buffer "*ps run*") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1090 (goto-char (point-max)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1091 (when echo |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1092 (insert string "\n")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1093 (set-marker (process-mark (get-process "ps-run")) (point)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1094 (process-send-string "ps-run" (concat string "\n")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1095 (select-window oldwin))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1096 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1097 (defun ps-run-make-tmp-filename () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1098 (unless ps-mode-tmp-file |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1099 (cond (ps-run-tmp-dir) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1100 ((setq ps-run-tmp-dir (getenv "TEMP"))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1101 ((setq ps-run-tmp-dir (getenv "TMP"))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1102 ((setq ps-run-tmp-dir (getenv "HOME")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1103 (setq |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1104 ps-run-tmp-dir |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1105 (concat (file-name-as-directory ps-run-tmp-dir) "tmp")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1106 (unless (file-directory-p ps-run-tmp-dir) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1107 (setq ps-run-tmp-dir nil)))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1108 (unless ps-run-tmp-dir |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1109 (setq ps-run-tmp-dir "/tmp")) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1110 (setq ps-mode-tmp-file |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1111 (make-temp-name |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1112 (concat |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1113 (if ps-run-tmp-dir |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1114 (file-name-as-directory ps-run-tmp-dir) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1115 "") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1116 "ps-run-")))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1117 ps-mode-tmp-file) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1118 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1119 ;; Remove temporary file |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1120 ;; This shouldn't fail twice, because it is called at kill-emacs |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1121 (defun ps-run-cleanup () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1122 (when ps-mode-tmp-file |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1123 (let ((i ps-mode-tmp-file)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1124 (setq ps-mode-tmp-file nil) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1125 (when (file-exists-p i) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1126 (delete-file i))))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1127 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1128 (defun ps-run-mouse-goto-error (event) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1129 "Set point at mouse click, then call ps-run-goto-error." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1130 (interactive "e") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1131 (mouse-set-point event) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1132 (ps-run-goto-error)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1133 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1134 (defun ps-run-newline () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1135 "Process newline in PostScript interpreter window." |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1136 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1137 (end-of-line) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1138 (insert "\n") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1139 (forward-line -1) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1140 (when (and (stringp ps-run-prompt) (looking-at ps-run-prompt)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1141 (goto-char (match-end 0))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1142 (looking-at ".*") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1143 (goto-char (1+ (match-end 0))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1144 (ps-run-send-string (buffer-substring (match-beginning 0) (match-end 0)))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1145 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1146 (defun ps-run-goto-error () |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1147 "Jump to buffer position read as integer at point. |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1148 Use line numbers if ps-run-error-line-numbers is not nil" |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1149 (interactive) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1150 (let ((p (point))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1151 (unless (looking-at "[0-9]") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1152 (goto-char (max 1 (1- (point))))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1153 (when (looking-at "[0-9]") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1154 (forward-char 1) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1155 (forward-word -1) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1156 (when (looking-at "[0-9]+") |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1157 (let (i) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1158 (setq |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1159 i |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1160 (string-to-int |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1161 (buffer-substring (match-beginning 0) (match-end 0)))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1162 (goto-char p) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1163 (pop-to-buffer ps-run-parent) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1164 (if ps-run-error-line-numbers |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1165 (progn |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1166 (goto-char (marker-position ps-run-mark)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1167 (forward-line (1- i)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1168 (end-of-line)) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1169 (goto-char (+ i (marker-position ps-run-mark))))))))) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1170 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1171 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1172 ;; |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1173 (add-hook 'kill-emacs-hook 'ps-run-cleanup) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1174 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1175 (provide 'ps-mode) |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1176 |
2b2b161bac67
New file. Major mode for editing PostScript.
Gerd Moellmann <gerd@gnu.org>
parents:
diff
changeset
|
1177 ;;; ps-mode.el ends here |