aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Moellmann1999-10-19 11:47:44 +0000
committerGerd Moellmann1999-10-19 11:47:44 +0000
commitc22d928fa61522d250d494b17c8324e66ebaa6f0 (patch)
tree9faccbb81dc7cc9f2ca51bd3e4355757ece3ccc1
parent8737bb5a2a2dbd80a265a2390a90875d2913eda9 (diff)
downloademacs-c22d928fa61522d250d494b17c8324e66ebaa6f0.tar.gz
emacs-c22d928fa61522d250d494b17c8324e66ebaa6f0.zip
(ps-mode-print-function): Fix default
value: \"lpr\" changed to "lpr" (ps-mode-version): New constant (ps-mode-show-version): New function, added key in ps-mode-map (ps-run-messages): Removed (ps-run-font-lock-keywords-2): New defcustom variable replacing ps-run-messages. These keywords now include the value of ps-run-prompt, making its fontification customizable. (ps-run-init): Removed \\n from docstring, it is now added when the value is used (ps-run-font-lock-keywords-1): Added checking for initial ^ in ps-run-prompt (ps-mode): Added ps-run-font-lock-keywords-2 to list of customizable variables in doc-string (it's equivalent ps-run-messages was missing in previous version of the doc-string) (ps-run-mode): Simplified assignment to font-lock-defaults, using symbols only
-rw-r--r--lisp/ChangeLog20
-rw-r--r--lisp/progmodes/ps-mode.el111
2 files changed, 83 insertions, 48 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f5fe08aa47f..bbba8ec5bf2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,23 @@
11999-10-19 Peter Kleiweg <kleiweg@let.rug.nl>
2
3 * progmodes/ps-mode.el (ps-mode-print-function): Fix default
4 value: \"lpr\" changed to "lpr"
5 (ps-mode-version): New constant
6 (ps-mode-show-version): New function, added key in ps-mode-map
7 (ps-run-messages): Removed
8 (ps-run-font-lock-keywords-2): New defcustom variable replacing
9 ps-run-messages. These keywords now include the value of
10 ps-run-prompt, making its fontification customizable.
11 (ps-run-init): Removed \\n from docstring, it is now added when
12 the value is used
13 (ps-run-font-lock-keywords-1): Added checking for initial ^ in
14 ps-run-prompt
15 (ps-mode): Added ps-run-font-lock-keywords-2 to list of
16 customizable variables in doc-string (it's equivalent
17 ps-run-messages was missing in previous version of the doc-string)
18 (ps-run-mode): Simplified assignment to font-lock-defaults, using
19 symbols only
20
11999-10-19 Alex Schroeder <alex@gnu.org> 211999-10-19 Alex Schroeder <alex@gnu.org>
2 22
3 * ansi-color.el: Complete rewrite. 23 * ansi-color.el: Complete rewrite.
diff --git a/lisp/progmodes/ps-mode.el b/lisp/progmodes/ps-mode.el
index 7d4081d903e..2beaf6eff03 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.1a, 11 Oct 1999 8;; Version: 1.1b, 18 Oct 1999
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,6 +30,8 @@
30 30
31;;; Code: 31;;; Code:
32 32
33(defconst ps-mode-version "1.1b, 18 Oct 1999")
34
33(require 'easymenu) 35(require 'easymenu)
34 36
35;; Define core `PostScript' group. 37;; Define core `PostScript' group.
@@ -101,10 +103,11 @@ When the figure is finished these values should be replaced."
101 (const :tag "dsheet" (1584 2448)) 103 (const :tag "dsheet" (1584 2448))
102 (const :tag "esheet" (2448 3168)))) 104 (const :tag "esheet" (2448 3168))))
103 105
104(defcustom ps-mode-print-function '(lambda () 106(defcustom ps-mode-print-function
105 (let ((lpr-switches nil) 107 '(lambda ()
106 (lpr-command \"lpr\")) 108 (let ((lpr-switches nil)
107 (lpr-buffer))) 109 (lpr-command "lpr"))
110 (lpr-buffer)))
108 "*Lisp function to print current buffer as PostScript." 111 "*Lisp function to print current buffer as PostScript."
109 :group 'PostScript-edit 112 :group 'PostScript-edit
110 :type 'function) 113 :type 'function)
@@ -114,14 +117,19 @@ When the figure is finished these values should be replaced."
114 :group 'PostScript-interaction 117 :group 'PostScript-interaction
115 :type 'regexp) 118 :type 'regexp)
116 119
117(defcustom ps-run-messages 120(defcustom ps-run-font-lock-keywords-2
118 '((">>showpage, press <return> to continue<<" 121 (append (unless (string= ps-run-prompt "")
119 (0 font-lock-keyword-face nil nil)) 122 (list (list (if (= ?^ (string-to-char ps-run-prompt))
120 ("^\\(Error\\|Can't\\).*" 123 ps-run-prompt
121 (0 font-lock-warning-face nil nil)) 124 (concat "^" ps-run-prompt))
122 ("^\\(Current file position is\\) \\([0-9]+\\)" 125 '(0 font-lock-function-name-face nil nil))))
123 (1 font-lock-comment-face nil nil) 126 '((">>showpage, press <return> to continue<<"
124 (2 font-lock-warning-face nil nil))) 127 (0 font-lock-keyword-face nil nil))
128 ("^\\(Error\\|Can't\\).*"
129 (0 font-lock-warning-face nil nil))
130 ("^\\(Current file position is\\) \\([0-9]+\\)"
131 (1 font-lock-comment-face nil nil)
132 (2 font-lock-warning-face nil nil))))
125 "*Medium level highlighting of messages from the PostScript interpreter. 133 "*Medium level highlighting of messages from the PostScript interpreter.
126 134
127See documentation on font-lock for details." 135See documentation on font-lock for details."
@@ -150,7 +158,7 @@ See documentation on font-lock for details."
150(defcustom ps-run-init nil 158(defcustom ps-run-init nil
151 "*String of commands to send to PostScript to start interactive. 159 "*String of commands to send to PostScript to start interactive.
152 160
153Example: \"executive\\n\" 161Example: \"executive\"
154 162
155You won't need to set this option for Ghostscript. 163You won't need to set this option for Ghostscript.
156" 164"
@@ -262,8 +270,11 @@ If nil, the following are tried in turn, until success:
262;; Level 1 font-lock for ps-run-mode 270;; Level 1 font-lock for ps-run-mode
263;; - prompt (function name face) 271;; - prompt (function name face)
264(defconst ps-run-font-lock-keywords-1 272(defconst ps-run-font-lock-keywords-1
265 (unless (or (not (stringp ps-run-prompt)) (string= "" ps-run-prompt)) 273 (unless (string= "" ps-run-prompt)
266 (list (cons (concat "^" ps-run-prompt) 'font-lock-function-name-face))) 274 (list (cons (if (= ?^ (string-to-char ps-run-prompt))
275 ps-run-prompt
276 (concat "^" ps-run-prompt))
277 'font-lock-function-name-face)))
267 "Subdued level highlighting for PostScript run mode.") 278 "Subdued level highlighting for PostScript run mode.")
268 279
269(defconst ps-run-font-lock-keywords ps-run-font-lock-keywords-1 280(defconst ps-run-font-lock-keywords ps-run-font-lock-keywords-1
@@ -389,35 +400,36 @@ If nil, the following are tried in turn, until success:
389 400
390(unless ps-mode-map 401(unless ps-mode-map
391 (setq ps-mode-map (make-sparse-keymap)) 402 (setq ps-mode-map (make-sparse-keymap))
392 (define-key ps-mode-map [return] 'ps-mode-newline) 403 (define-key ps-mode-map "\C-cv" 'ps-mode-show-version)
393 (define-key ps-mode-map "\r" 'ps-mode-newline)
394 (define-key ps-mode-map "\t" 'ps-mode-tabkey)
395 (define-key ps-mode-map "\177" 'ps-mode-backward-delete-char)
396 (define-key ps-mode-map "}" 'ps-mode-r-brace)
397 (define-key ps-mode-map "]" 'ps-mode-r-angle)
398 (define-key ps-mode-map ">" 'ps-mode-r-gt)
399 (define-key ps-mode-map "\C-c\C-b" 'ps-run-buffer)
400 (define-key ps-mode-map "\C-c\C-c" 'ps-run-clear)
401 (define-key ps-mode-map "\C-c\C-j" 'ps-mode-other-newline)
402 (define-key ps-mode-map "\C-c\C-k" 'ps-run-kill)
403 (define-key ps-mode-map "\C-c\C-o" 'ps-mode-comment-out-region)
404 (define-key ps-mode-map "\C-c\C-p" 'ps-mode-print-buffer)
405 (define-key ps-mode-map "\C-c\C-q" 'ps-run-quit)
406 (define-key ps-mode-map "\C-c\C-r" 'ps-run-region)
407 (define-key ps-mode-map "\C-c\C-s" 'ps-run-start)
408 (define-key ps-mode-map "\C-c\C-t" 'ps-mode-epsf-rich)
409 (define-key ps-mode-map "\C-c\C-u" 'ps-mode-uncomment-region)
410 (define-key ps-mode-map "\C-c\C-v" 'ps-run-boundingbox) 404 (define-key ps-mode-map "\C-c\C-v" 'ps-run-boundingbox)
405 (define-key ps-mode-map "\C-c\C-u" 'ps-mode-uncomment-region)
406 (define-key ps-mode-map "\C-c\C-t" 'ps-mode-epsf-rich)
407 (define-key ps-mode-map "\C-c\C-s" 'ps-run-start)
408 (define-key ps-mode-map "\C-c\C-r" 'ps-run-region)
409 (define-key ps-mode-map "\C-c\C-q" 'ps-run-quit)
410 (define-key ps-mode-map "\C-c\C-p" 'ps-mode-print-buffer)
411 (define-key ps-mode-map "\C-c\C-o" 'ps-mode-comment-out-region)
412 (define-key ps-mode-map "\C-c\C-k" 'ps-run-kill)
413 (define-key ps-mode-map "\C-c\C-j" 'ps-mode-other-newline)
414 (define-key ps-mode-map "\C-c\C-c" 'ps-run-clear)
415 (define-key ps-mode-map "\C-c\C-b" 'ps-run-buffer)
416 (define-key ps-mode-map ">" 'ps-mode-r-gt)
417 (define-key ps-mode-map "]" 'ps-mode-r-angle)
418 (define-key ps-mode-map "}" 'ps-mode-r-brace)
419 (define-key ps-mode-map "\177" 'ps-mode-backward-delete-char)
420 (define-key ps-mode-map "\t" 'ps-mode-tabkey)
421 (define-key ps-mode-map "\r" 'ps-mode-newline)
422 (define-key ps-mode-map [return] 'ps-mode-newline)
411 (easy-menu-define ps-mode-main ps-mode-map "PostScript" ps-mode-menu-main)) 423 (easy-menu-define ps-mode-main ps-mode-map "PostScript" ps-mode-menu-main))
412 424
413(unless ps-run-mode-map 425(unless ps-run-mode-map
414 (setq ps-run-mode-map (make-sparse-keymap)) 426 (setq ps-run-mode-map (make-sparse-keymap))
415 (define-key ps-run-mode-map [return] 'ps-run-newline)
416 (define-key ps-run-mode-map "\r" 'ps-run-newline)
417 (define-key ps-run-mode-map "\C-c\C-q" 'ps-run-quit) 427 (define-key ps-run-mode-map "\C-c\C-q" 'ps-run-quit)
418 (define-key ps-run-mode-map "\C-c\C-k" 'ps-run-kill) 428 (define-key ps-run-mode-map "\C-c\C-k" 'ps-run-kill)
419 (define-key ps-run-mode-map "\C-c\C-e" 'ps-run-goto-error) 429 (define-key ps-run-mode-map "\C-c\C-e" 'ps-run-goto-error)
420 (define-key ps-run-mode-map [mouse-2] 'ps-run-mouse-goto-error)) 430 (define-key ps-run-mode-map [mouse-2] 'ps-run-mouse-goto-error)
431 (define-key ps-run-mode-map "\r" 'ps-run-newline)
432 (define-key ps-run-mode-map [return] 'ps-run-newline))
421 433
422 434
423;; Syntax table. 435;; Syntax table.
@@ -476,12 +488,13 @@ be set through the `customize' command:
476 ps-mode-tab 488 ps-mode-tab
477 ps-mode-paper-size 489 ps-mode-paper-size
478 ps-mode-print-function 490 ps-mode-print-function
479 ps-run-tmp-dir
480 ps-run-prompt 491 ps-run-prompt
492 ps-run-font-lock-keywords-2
481 ps-run-x 493 ps-run-x
482 ps-run-dumb 494 ps-run-dumb
483 ps-run-init 495 ps-run-init
484 ps-run-error-line-numbers 496 ps-run-error-line-numbers
497 ps-run-tmp-dir
485 498
486Type \\[describe-variable] for documentation on these options. 499Type \\[describe-variable] for documentation on these options.
487 500
@@ -516,6 +529,11 @@ Typing \\<ps-run-mode-map>\\[ps-run-goto-error] when the cursor is at the number
516 (set-syntax-table ps-mode-syntax-table) 529 (set-syntax-table ps-mode-syntax-table)
517 (run-hooks 'ps-mode-hook)) 530 (run-hooks 'ps-mode-hook))
518 531
532(defun ps-mode-show-version ()
533 "Show current version of PostScript mode"
534 (interactive)
535 (message " *** PostScript Mode (ps-mode) Version %s *** " ps-mode-version))
536
519 537
520;; Helper functions for font-lock. 538;; Helper functions for font-lock.
521 539
@@ -771,7 +789,7 @@ Only one `%' is removed, and it has to be in the first column."
771 (backward-char) 789 (backward-char)
772 (insert (format "\\%03o" (string-to-char (buffer-substring (point) (1+ (point)))))) 790 (insert (format "\\%03o" (string-to-char (buffer-substring (point) (1+ (point))))))
773 (delete-char 1)) 791 (delete-char 1))
774 (message (format "%d change%s made" i (if (= i 1) "" "s"))) 792 (message "%d change%s made" i (if (= i 1) "" "s"))
775 (set-marker endm nil))))) 793 (set-marker endm nil)))))
776 794
777 795
@@ -953,12 +971,10 @@ This mode is invoked from ps-mode and should not be called directly.
953" 971"
954 (kill-all-local-variables) 972 (kill-all-local-variables)
955 (make-local-variable 'font-lock-defaults) 973 (make-local-variable 'font-lock-defaults)
956 (setq font-lock-defaults (list (list 'ps-run-font-lock-keywords 974 (setq font-lock-defaults '((ps-run-font-lock-keywords
957 'ps-run-font-lock-keywords-1 975 ps-run-font-lock-keywords-1
958 (append 976 ps-run-font-lock-keywords-2)
959 ps-run-font-lock-keywords-1 977 t)
960 ps-run-messages))
961 t)
962 major-mode 'ps-run-mode 978 major-mode 'ps-run-mode
963 mode-name "Interactive PS" 979 mode-name "Interactive PS"
964 mode-line-process '(":%s")) 980 mode-line-process '(":%s"))
@@ -978,7 +994,6 @@ This mode is invoked from ps-mode and should not be called directly.
978 (let ((command (if (and window-system ps-run-x) ps-run-x ps-run-dumb)) 994 (let ((command (if (and window-system ps-run-x) ps-run-x ps-run-dumb))
979 (init-file nil) 995 (init-file nil)
980 (process-connection-type nil) 996 (process-connection-type nil)
981 (oldbuf (current-buffer))
982 (oldwin (selected-window)) 997 (oldwin (selected-window))
983 i) 998 i)
984 (unless command 999 (unless command
@@ -987,7 +1002,7 @@ This mode is invoked from ps-mode and should not be called directly.
987 (setq ps-run-mark (make-marker))) 1002 (setq ps-run-mark (make-marker)))
988 (when ps-run-init 1003 (when ps-run-init
989 (setq init-file (ps-run-make-tmp-filename)) 1004 (setq init-file (ps-run-make-tmp-filename))
990 (write-region ps-run-init 0 init-file) 1005 (write-region (concat ps-run-init "\n") 0 init-file)
991 (setq init-file (list init-file))) 1006 (setq init-file (list init-file)))
992 (pop-to-buffer "*ps run*") 1007 (pop-to-buffer "*ps run*")
993 (ps-run-mode) 1008 (ps-run-mode)
@@ -1137,7 +1152,7 @@ grestore
1137 (end-of-line) 1152 (end-of-line)
1138 (insert "\n") 1153 (insert "\n")
1139 (forward-line -1) 1154 (forward-line -1)
1140 (when (and (stringp ps-run-prompt) (looking-at ps-run-prompt)) 1155 (when (looking-at ps-run-prompt)
1141 (goto-char (match-end 0))) 1156 (goto-char (match-end 0)))
1142 (looking-at ".*") 1157 (looking-at ".*")
1143 (goto-char (1+ (match-end 0))) 1158 (goto-char (1+ (match-end 0)))