aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Triska2010-07-24 00:51:37 +0200
committerStefan Monnier2010-07-24 00:51:37 +0200
commit9cf2db99c671636d9a37eec7027bdf6d2d9a5814 (patch)
tree9d1dfe9d5fdb0f96da004ea73c8b78a8a01ee2e8
parent33ac04147b6c42796f4c0c16d6aeb261033c171e (diff)
downloademacs-9cf2db99c671636d9a37eec7027bdf6d2d9a5814.tar.gz
emacs-9cf2db99c671636d9a37eec7027bdf6d2d9a5814.zip
* lisp/progmodes/ps-mode.el: Use comint.
(ps-run-mode-map): Adapt for comint-mode; omit "\r", [return].. (ps-mode-other-newline): Simplify. (ps-run-mode): Derive from comint-mode instead of fundamental-mode, yielding input history etc. (ps-run-start, ps-run-quit, ps-run-clear, ps-run-region) (ps-run-send-string): Adapt for comint-mode. (ps-run-newline): Remove now unneeded function. Fixes: debbugs:5954
-rw-r--r--lisp/ChangeLog11
-rw-r--r--lisp/progmodes/ps-mode.el56
2 files changed, 32 insertions, 35 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 02e75a40b21..dcd6d4fd28c 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,14 @@
12010-07-23 Markus Triska <markus.triska@gmx.at>
2
3 * progmodes/ps-mode.el: Use comint (bug#5954).
4 (ps-run-mode-map): Adapt for comint-mode; omit "\r", [return]..
5 (ps-mode-other-newline): Simplify.
6 (ps-run-mode): Derive from comint-mode instead of
7 fundamental-mode, yielding input history etc.
8 (ps-run-start, ps-run-quit, ps-run-clear, ps-run-region)
9 (ps-run-send-string): Adapt for comint-mode.
10 (ps-run-newline): Remove now unneeded function.
11
12010-07-23 Michael Albinus <michael.albinus@gmx.de> 122010-07-23 Michael Albinus <michael.albinus@gmx.de>
2 13
3 * net/tramp.el (tramp-methods): Move hostname to the end in all 14 * net/tramp.el (tramp-methods): Move hostname to the end in all
diff --git a/lisp/progmodes/ps-mode.el b/lisp/progmodes/ps-mode.el
index 7b235bc3b68..387a0cb6e00 100644
--- a/lisp/progmodes/ps-mode.el
+++ b/lisp/progmodes/ps-mode.el
@@ -39,6 +39,7 @@
39(defconst ps-mode-version "1.1h, 16 Jun 2005") 39(defconst ps-mode-version "1.1h, 16 Jun 2005")
40(defconst ps-mode-maintainer-address "Peter Kleiweg <p.c.j.kleiweg@rug.nl>") 40(defconst ps-mode-maintainer-address "Peter Kleiweg <p.c.j.kleiweg@rug.nl>")
41 41
42(require 'comint)
42(require 'easymenu) 43(require 'easymenu)
43 44
44;; Define core `PostScript' group. 45;; Define core `PostScript' group.
@@ -431,12 +432,11 @@ If nil, use `temporary-file-directory'."
431 432
432(unless ps-run-mode-map 433(unless ps-run-mode-map
433 (setq ps-run-mode-map (make-sparse-keymap)) 434 (setq ps-run-mode-map (make-sparse-keymap))
435 (set-keymap-parent ps-run-mode-map comint-mode-map)
434 (define-key ps-run-mode-map "\C-c\C-q" 'ps-run-quit) 436 (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) 437 (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) 438 (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) 439 (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 440
441 441
442;; Syntax table. 442;; Syntax table.
@@ -718,12 +718,9 @@ defines the beginning of a group. These tokens are: { [ <<"
718 (blink-matching-open)) 718 (blink-matching-open))
719 719
720(defun ps-mode-other-newline () 720(defun ps-mode-other-newline ()
721 "Perform newline in `*ps run*' buffer." 721 "Perform newline in `*ps-run*' buffer."
722 (interactive) 722 (interactive)
723 (let ((buf (current-buffer))) 723 (ps-run-send-string ""))
724 (set-buffer "*ps run*")
725 (ps-run-newline)
726 (set-buffer buf)))
727 724
728 725
729;; Print PostScript. 726;; Print PostScript.
@@ -980,7 +977,7 @@ plus the usually uncoded characters inserted on positions 1 through 28."
980 977
981;; Interactive PostScript interpreter. 978;; Interactive PostScript interpreter.
982 979
983(define-derived-mode ps-run-mode fundamental-mode "Interactive PS" 980(define-derived-mode ps-run-mode comint-mode "Interactive PS"
984 "Major mode in interactive PostScript window. 981 "Major mode in interactive PostScript window.
985This mode is invoked from `ps-mode' and should not be called directly. 982This mode is invoked from `ps-mode' and should not be called directly.
986 983
@@ -1014,20 +1011,23 @@ This mode is invoked from `ps-mode' and should not be called directly.
1014 (setq init-file (ps-run-make-tmp-filename)) 1011 (setq init-file (ps-run-make-tmp-filename))
1015 (write-region (concat ps-run-init "\n") 0 init-file) 1012 (write-region (concat ps-run-init "\n") 0 init-file)
1016 (setq init-file (list init-file))) 1013 (setq init-file (list init-file)))
1017 (pop-to-buffer "*ps run*") 1014 (pop-to-buffer "*ps-run*")
1018 (ps-run-mode) 1015 (ps-run-mode)
1019 (when (process-status "ps-run") 1016 (when (process-status "ps-run")
1020 (delete-process "ps-run")) 1017 (delete-process "ps-run"))
1021 (erase-buffer) 1018 (erase-buffer)
1022 (setq command (append command init-file)) 1019 (setq command (append command init-file))
1023 (insert (mapconcat 'identity command " ") "\n") 1020 (insert (mapconcat 'identity command " ") "\n")
1024 (apply 'start-process "ps-run" "*ps run*" command) 1021 (apply 'make-comint "ps-run" (car command) nil (cdr command))
1022 (with-current-buffer "*ps-run*"
1023 (use-local-map ps-run-mode-map)
1024 (setq comint-prompt-regexp ps-run-prompt))
1025 (select-window oldwin))) 1025 (select-window oldwin)))
1026 1026
1027(defun ps-run-quit () 1027(defun ps-run-quit ()
1028 "Quit interactive PostScript." 1028 "Quit interactive PostScript."
1029 (interactive) 1029 (interactive)
1030 (ps-run-send-string "quit" t) 1030 (ps-run-send-string "quit")
1031 (ps-run-cleanup)) 1031 (ps-run-cleanup))
1032 1032
1033(defun ps-run-kill () 1033(defun ps-run-kill ()
@@ -1039,9 +1039,9 @@ This mode is invoked from `ps-mode' and should not be called directly.
1039(defun ps-run-clear () 1039(defun ps-run-clear ()
1040 "Clear/reset PostScript graphics." 1040 "Clear/reset PostScript graphics."
1041 (interactive) 1041 (interactive)
1042 (ps-run-send-string "showpage" t) 1042 (ps-run-send-string "showpage")
1043 (sit-for 1) 1043 (sit-for 1)
1044 (ps-run-send-string "" t)) 1044 (ps-run-send-string ""))
1045 1045
1046(defun ps-run-buffer () 1046(defun ps-run-buffer ()
1047 "Send buffer to PostScript interpreter." 1047 "Send buffer to PostScript interpreter."
@@ -1056,7 +1056,7 @@ This mode is invoked from `ps-mode' and should not be called directly.
1056 (let ((f (ps-run-make-tmp-filename))) 1056 (let ((f (ps-run-make-tmp-filename)))
1057 (set-marker ps-run-mark begin) 1057 (set-marker ps-run-mark begin)
1058 (write-region begin end f) 1058 (write-region begin end f)
1059 (ps-run-send-string (format "(%s) run" f) t))) 1059 (ps-run-send-string (format "(%s) run" f))))
1060 1060
1061(defun ps-run-boundingbox () 1061(defun ps-run-boundingbox ()
1062 "View BoundingBox." 1062 "View BoundingBox."
@@ -1104,17 +1104,15 @@ grestore
1104" x1 y1 x2 y1 x2 y2 x1 y2) 1104" x1 y1 x2 y1 x2 y2 x1 y2)
1105 0 1105 0
1106 f) 1106 f)
1107 (ps-run-send-string (format "(%s) run" f) t) 1107 (ps-run-send-string (format "(%s) run" f))
1108 (set-buffer buf))) 1108 (set-buffer buf)))
1109 1109
1110(defun ps-run-send-string (string &optional echo) 1110(defun ps-run-send-string (string)
1111 (let ((oldwin (selected-window))) 1111 (let ((oldwin (selected-window)))
1112 (pop-to-buffer "*ps run*") 1112 (pop-to-buffer "*ps-run*")
1113 (goto-char (point-max)) 1113 (comint-goto-process-mark)
1114 (when echo 1114 (insert string)
1115 (insert string "\n")) 1115 (comint-send-input)
1116 (set-marker (process-mark (get-process "ps-run")) (point))
1117 (process-send-string "ps-run" (concat string "\n"))
1118 (select-window oldwin))) 1116 (select-window oldwin)))
1119 1117
1120(defun ps-run-make-tmp-filename () 1118(defun ps-run-make-tmp-filename ()
@@ -1140,18 +1138,6 @@ grestore
1140 (mouse-set-point event) 1138 (mouse-set-point event)
1141 (ps-run-goto-error)) 1139 (ps-run-goto-error))
1142 1140
1143(defun ps-run-newline ()
1144 "Process newline in PostScript interpreter window."
1145 (interactive)
1146 (end-of-line)
1147 (insert "\n")
1148 (forward-line -1)
1149 (when (looking-at ps-run-prompt)
1150 (goto-char (match-end 0)))
1151 (looking-at ".*")
1152 (goto-char (1+ (match-end 0)))
1153 (ps-run-send-string (buffer-substring (match-beginning 0) (match-end 0))))
1154
1155(defun ps-run-goto-error () 1141(defun ps-run-goto-error ()
1156 "Jump to buffer position read as integer at point. 1142 "Jump to buffer position read as integer at point.
1157Use line numbers if `ps-run-error-line-numbers' is not nil" 1143Use line numbers if `ps-run-error-line-numbers' is not nil"