aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman2001-11-10 19:36:51 +0000
committerRichard M. Stallman2001-11-10 19:36:51 +0000
commit6114f9e511f724f297c9e97245cdfa051c05ebba (patch)
tree6fa80a3a85264ebe855861df13ea0bfbe52e79c2
parentc48dc445545e4f168a048713fbce564d75bf77f7 (diff)
downloademacs-6114f9e511f724f297c9e97245cdfa051c05ebba.tar.gz
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.
-rw-r--r--lisp/progmodes/ps-mode.el28
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 @@
5;; Author: Peter Kleiweg <kleiweg@let.rug.nl> 5;; Author: Peter Kleiweg <kleiweg@let.rug.nl>
6;; Maintainer: Peter Kleiweg <kleiweg@let.rug.nl> 6;; Maintainer: Peter Kleiweg <kleiweg@let.rug.nl>
7;; Created: 20 Aug 1997 7;; Created: 20 Aug 1997
8;; Version: 1.1f, 25 Oct 2001 8;; Version: 1.1g, 9 Nov 2001
9;; Keywords: PostScript, languages 9;; Keywords: PostScript, languages
10 10
11;; This file is part of GNU Emacs. 11;; This file is part of GNU Emacs.
@@ -30,7 +30,7 @@
30 30
31;;; Code: 31;;; Code:
32 32
33(defconst ps-mode-version "1.1f, 25 Oct 2001") 33(defconst ps-mode-version "1.1g, 9 Nov 2001")
34(defconst ps-mode-maintainer-address "Peter Kleiweg <kleiweg@let.rug.nl>") 34(defconst ps-mode-maintainer-address "Peter Kleiweg <kleiweg@let.rug.nl>")
35 35
36(require 'easymenu) 36(require 'easymenu)
@@ -256,9 +256,12 @@ If nil, the following are tried in turn, until success:
256 ps-mode-font-lock-keywords-1 256 ps-mode-font-lock-keywords-1
257 (list 257 (list
258 '("//\\w+" . font-lock-type-face) 258 '("//\\w+" . font-lock-type-face)
259 '("^\\(/\\w+\\)\\>[[ \t]*\\(%.*\\)?\r?$" 259 `(,(concat
260 . (1 font-lock-function-name-face)) 260 "^\\(/\\w+\\)\\>"
261 '("^\\(/\\w+\\)\\>\\([ \t]*{\\|[ \t]*<<\\|.*\\<def\\>\\|[ \t]+[0-9]+[ \t]+dict\\>\\)" 261 "\\([[ \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.
262 . (1 font-lock-function-name-face)) 265 . (1 font-lock-function-name-face))
263 '("/\\w+" . font-lock-variable-name-face) 266 '("/\\w+" . font-lock-variable-name-face)
264 (cons ps-mode-operators 'font-lock-keyword-face))) 267 (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
523 ps-mode-font-lock-keywords-1 526 ps-mode-font-lock-keywords-1
524 ps-mode-font-lock-keywords-2 527 ps-mode-font-lock-keywords-2
525 ps-mode-font-lock-keywords-3) 528 ps-mode-font-lock-keywords-3)
526 t))) 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]*"))
527 533
528(defun ps-mode-show-version () 534(defun ps-mode-show-version ()
529 "Show current version of PostScript mode." 535 "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
573 ;; Search next bracket, stepping over escaped brackets. 579 ;; Search next bracket, stepping over escaped brackets.
574 (if (not (looking-at "\\([^()\\\n]\\|\\\\.\\)*\\([()]\\)")) 580 (if (not (looking-at "\\([^()\\\n]\\|\\\\.\\)*\\([()]\\)"))
575 (setq level -1) 581 (setq level -1)
576 (if (string= "(" (match-string 2)) 582 (setq level (+ level (if (string= "(" (match-string 2)) 1 -1)))
577 (setq level (1+ level)) 583 (goto-char (setq pos (match-end 0)))))
578 (setq level (1- level)))
579 (goto-char (setq pos (match-end 0)))))
580 (if (not (= level 0)) 584 (if (not (= level 0))
581 nil 585 nil
582 ;; Found string with nested brackets, now set match data nr 2. 586 ;; Found string with nested brackets, now set match data nr 2.
583 (goto-char first) 587 (set-match-data (list first pos nil nil first pos))
584 (re-search-forward "\\(%\\)\\|\\((.*\\)" pos)))) 588 pos)))
585 589
586;; This function should search for a string or comment 590;; This function should search for a string or comment
587;; If comment, return as match data nr 1 591;; If comment, return as match data nr 1