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