5 |
;; Author: Peter Kleiweg <kleiweg@let.rug.nl> |
;; Author: Peter Kleiweg <kleiweg@let.rug.nl> |
6 |
;; Maintainer: Peter Kleiweg <kleiweg@let.rug.nl> |
;; Maintainer: Peter Kleiweg <kleiweg@let.rug.nl> |
7 |
;; Created: 20 Aug 1997 |
;; Created: 20 Aug 1997 |
8 |
;; Version: 1.1f, 25 Oct 2001 |
;; Version: 1.1g, 9 Nov 2001 |
9 |
;; Keywords: PostScript, languages |
;; Keywords: PostScript, languages |
10 |
|
|
11 |
;; This file is part of GNU Emacs. |
;; This file is part of GNU Emacs. |
30 |
|
|
31 |
;;; Code: |
;;; Code: |
32 |
|
|
33 |
(defconst ps-mode-version "1.1f, 25 Oct 2001") |
(defconst ps-mode-version "1.1g, 9 Nov 2001") |
34 |
(defconst ps-mode-maintainer-address "Peter Kleiweg <kleiweg@let.rug.nl>") |
(defconst ps-mode-maintainer-address "Peter Kleiweg <kleiweg@let.rug.nl>") |
35 |
|
|
36 |
(require 'easymenu) |
(require 'easymenu) |
256 |
ps-mode-font-lock-keywords-1 |
ps-mode-font-lock-keywords-1 |
257 |
(list |
(list |
258 |
'("//\\w+" . font-lock-type-face) |
'("//\\w+" . font-lock-type-face) |
259 |
'("^\\(/\\w+\\)\\>[[ \t]*\\(%.*\\)?\r?$" |
`(,(concat |
260 |
. (1 font-lock-function-name-face)) |
"^\\(/\\w+\\)\\>" |
261 |
'("^\\(/\\w+\\)\\>\\([ \t]*{\\|[ \t]*<<\\|.*\\<def\\>\\|[ \t]+[0-9]+[ \t]+dict\\>\\)" |
"\\([[ \t]*\\(%.*\\)?\r?$" ; Nothing but `[' or comment after the name. |
262 |
|
"\\|[ \t]*\\({\\|<<\\)" ; `{' or `<<' following the name. |
263 |
|
"\\|[ \t]+[0-9]+[ \t]+dict\\>" ; `[0-9]+ dict' following the name. |
264 |
|
"\\|.*\\<def\\>\\)") ; `def' somewhere on the same line. |
265 |
. (1 font-lock-function-name-face)) |
. (1 font-lock-function-name-face)) |
266 |
'("/\\w+" . font-lock-variable-name-face) |
'("/\\w+" . font-lock-variable-name-face) |
267 |
(cons ps-mode-operators 'font-lock-keyword-face))) |
(cons ps-mode-operators 'font-lock-keyword-face))) |
526 |
ps-mode-font-lock-keywords-1 |
ps-mode-font-lock-keywords-1 |
527 |
ps-mode-font-lock-keywords-2 |
ps-mode-font-lock-keywords-2 |
528 |
ps-mode-font-lock-keywords-3) |
ps-mode-font-lock-keywords-3) |
529 |
t))) |
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 () |
(defun ps-mode-show-version () |
535 |
"Show current version of PostScript mode." |
"Show current version of PostScript mode." |
579 |
;; Search next bracket, stepping over escaped brackets. |
;; Search next bracket, stepping over escaped brackets. |
580 |
(if (not (looking-at "\\([^()\\\n]\\|\\\\.\\)*\\([()]\\)")) |
(if (not (looking-at "\\([^()\\\n]\\|\\\\.\\)*\\([()]\\)")) |
581 |
(setq level -1) |
(setq level -1) |
582 |
(if (string= "(" (match-string 2)) |
(setq level (+ level (if (string= "(" (match-string 2)) 1 -1))) |
583 |
(setq level (1+ level)) |
(goto-char (setq pos (match-end 0))))) |
|
(setq level (1- level))) |
|
|
(goto-char (setq pos (match-end 0))))) |
|
584 |
(if (not (= level 0)) |
(if (not (= level 0)) |
585 |
nil |
nil |
586 |
;; Found string with nested brackets, now set match data nr 2. |
;; Found string with nested brackets, now set match data nr 2. |
587 |
(goto-char first) |
(set-match-data (list first pos nil nil first pos)) |
588 |
(re-search-forward "\\(%\\)\\|\\((.*\\)" pos)))) |
pos))) |
589 |
|
|
590 |
;; This function should search for a string or comment |
;; This function should search for a string or comment |
591 |
;; If comment, return as match data nr 1 |
;; If comment, return as match data nr 1 |