diff options
author | Richard M. Stallman <rms@gnu.org> | 2001-11-10 19:36:51 +0000 |
---|---|---|
committer | Richard M. Stallman <rms@gnu.org> | 2001-11-10 19:36:51 +0000 |
commit | 6114f9e511f724f297c9e97245cdfa051c05ebba (patch) | |
tree | 6fa80a3a85264ebe855861df13ea0bfbe52e79c2 /lisp | |
parent | c48dc445545e4f168a048713fbce564d75bf77f7 (diff) | |
download | emacs-6114f9e511f724f297c9e97245cdfa051c05ebba.tar.gz emacs-6114f9e511f724f297c9e97245cdfa051c05ebba.tar.bz2 emacs-6114f9e511f724f297c9e97245cdfa051c05ebba.zip |
(ps-mode-font-lock-keywords-1): Merge two regular expressions into one.
(ps-mode): Make local bindings for `comment-start' and `comment-start-skip'.
(ps-mode-looking-at-nested): Simplify an if-else construct;
use `set-match-data' to set the result.
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/progmodes/ps-mode.el | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/lisp/progmodes/ps-mode.el b/lisp/progmodes/ps-mode.el index cf9c53749d5..58e87386b31 100644 --- a/lisp/progmodes/ps-mode.el +++ b/lisp/progmodes/ps-mode.el @@ -5,7 +5,7 @@ ;; Author: Peter Kleiweg <kleiweg@let.rug.nl> ;; Maintainer: Peter Kleiweg <kleiweg@let.rug.nl> ;; Created: 20 Aug 1997 -;; Version: 1.1f, 25 Oct 2001 +;; Version: 1.1g, 9 Nov 2001 ;; Keywords: PostScript, languages ;; This file is part of GNU Emacs. @@ -30,7 +30,7 @@ ;;; Code: -(defconst ps-mode-version "1.1f, 25 Oct 2001") +(defconst ps-mode-version "1.1g, 9 Nov 2001") (defconst ps-mode-maintainer-address "Peter Kleiweg <kleiweg@let.rug.nl>") (require 'easymenu) @@ -256,9 +256,12 @@ If nil, the following are tried in turn, until success: ps-mode-font-lock-keywords-1 (list '("//\\w+" . font-lock-type-face) - '("^\\(/\\w+\\)\\>[[ \t]*\\(%.*\\)?\r?$" - . (1 font-lock-function-name-face)) - '("^\\(/\\w+\\)\\>\\([ \t]*{\\|[ \t]*<<\\|.*\\<def\\>\\|[ \t]+[0-9]+[ \t]+dict\\>\\)" + `(,(concat + "^\\(/\\w+\\)\\>" + "\\([[ \t]*\\(%.*\\)?\r?$" ; Nothing but `[' or comment after the name. + "\\|[ \t]*\\({\\|<<\\)" ; `{' or `<<' following the name. + "\\|[ \t]+[0-9]+[ \t]+dict\\>" ; `[0-9]+ dict' following the name. + "\\|.*\\<def\\>\\)") ; `def' somewhere on the same line. . (1 font-lock-function-name-face)) '("/\\w+" . font-lock-variable-name-face) (cons ps-mode-operators 'font-lock-keyword-face))) @@ -523,7 +526,10 @@ Typing \\<ps-run-mode-map>\\[ps-run-goto-error] when the cursor is at the number ps-mode-font-lock-keywords-1 ps-mode-font-lock-keywords-2 ps-mode-font-lock-keywords-3) - t))) + t)) + (set (make-local-variable 'comment-start) "%") + ;; NOTE: `\' has a special meaning in strings only + (set (make-local-variable 'comment-start-skip) "%+[ \t]*")) (defun ps-mode-show-version () "Show current version of PostScript mode." @@ -573,15 +579,13 @@ Typing \\<ps-run-mode-map>\\[ps-run-goto-error] when the cursor is at the number ;; Search next bracket, stepping over escaped brackets. (if (not (looking-at "\\([^()\\\n]\\|\\\\.\\)*\\([()]\\)")) (setq level -1) - (if (string= "(" (match-string 2)) - (setq level (1+ level)) - (setq level (1- level))) - (goto-char (setq pos (match-end 0))))) + (setq level (+ level (if (string= "(" (match-string 2)) 1 -1))) + (goto-char (setq pos (match-end 0))))) (if (not (= level 0)) nil ;; Found string with nested brackets, now set match data nr 2. - (goto-char first) - (re-search-forward "\\(%\\)\\|\\((.*\\)" pos)))) + (set-match-data (list first pos nil nil first pos)) + pos))) ;; This function should search for a string or comment ;; If comment, return as match data nr 1 |