aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Monnier2005-07-29 20:14:37 +0000
committerStefan Monnier2005-07-29 20:14:37 +0000
commitceee4f5d3936a6bcf2aba5e92fadeddc15c44dc0 (patch)
treec951447a14d44007706de8c7cadc1072a75381e5
parent01e4a4fa0349d23595f61f531fec66d8f3c11c65 (diff)
downloademacs-ceee4f5d3936a6bcf2aba5e92fadeddc15c44dc0.tar.gz
emacs-ceee4f5d3936a6bcf2aba5e92fadeddc15c44dc0.zip
Avoid end-of-buffer. Clean up.
-rw-r--r--lisp/vmsproc.el72
1 files changed, 34 insertions, 38 deletions
diff --git a/lisp/vmsproc.el b/lisp/vmsproc.el
index 9871daa7a5e..56237693670 100644
--- a/lisp/vmsproc.el
+++ b/lisp/vmsproc.el
@@ -1,6 +1,6 @@
1;;; vmsproc.el --- run asynchronous VMS subprocesses under Emacs 1;;; vmsproc.el --- run asynchronous VMS subprocesses under Emacs
2 2
3;; Copyright (C) 1986 Free Software Foundation, Inc. 3;; Copyright (C) 1986, 2005 Free Software Foundation, Inc.
4 4
5;; Author: Mukesh Prasad 5;; Author: Mukesh Prasad
6;; Maintainer: FSF 6;; Maintainer: FSF
@@ -34,13 +34,11 @@
34 "String to insert to distinguish commands entered by user.") 34 "String to insert to distinguish commands entered by user.")
35 35
36(defvar subprocess-running nil) 36(defvar subprocess-running nil)
37(defvar command-mode-map nil) 37(defvar command-mode-map
38 38 (let ((map (make-sparse-keymap)))
39(if command-mode-map 39 (define-key map "\C-m" 'command-send-input)
40 nil 40 (define-key map "\C-u" 'command-kill-line)
41 (setq command-mode-map (make-sparse-keymap)) 41 map))
42 (define-key command-mode-map "\C-m" 'command-send-input)
43 (define-key command-mode-map "\C-u" 'command-kill-line))
44 42
45(defun subprocess-input (name str) 43(defun subprocess-input (name str)
46 "Handles input from a subprocess. Called by Emacs." 44 "Handles input from a subprocess. Called by Emacs."
@@ -65,8 +63,7 @@ the end."
65 (if subprocess-running 63 (if subprocess-running
66 (return t)) 64 (return t))
67 (setq subprocess-buf (get-buffer-create "*COMMAND*")) 65 (setq subprocess-buf (get-buffer-create "*COMMAND*"))
68 (save-excursion 66 (with-current-buffer subprocess-buf
69 (set-buffer subprocess-buf)
70 (use-local-map command-mode-map)) 67 (use-local-map command-mode-map))
71 (setq subprocess-running (spawn-subprocess 1 'subprocess-input 68 (setq subprocess-running (spawn-subprocess 1 'subprocess-input
72 'subprocess-exit)) 69 'subprocess-exit))
@@ -81,25 +78,24 @@ the end."
81 (setq cmd (substring command 0 (string-match " " command))) 78 (setq cmd (substring command 0 (string-match " " command)))
82 (setq args (substring command (string-match " " command))) 79 (setq args (substring command (string-match " " command)))
83 (call-process cmd nil buffer nil "*dcl*" args))) 80 (call-process cmd nil buffer nil "*dcl*" args)))
84;BUGS: only the output up to the end of the first image activation is trapped. 81 ;; BUGS: only the output up to the end of the first image activation is trapped.
85; (if (not subprocess-running) 82 ;; (if (not subprocess-running)
86; (start-subprocess)) 83 ;; (start-subprocess))
87; (save-excursion 84 ;; (with-current-buffer buffer
88; (set-buffer buffer) 85 ;; (let ((output-filename (concat "SYS$SCRATCH:OUTPUT-FOR-"
89; (let ((output-filename (concat "SYS$SCRATCH:OUTPUT-FOR-" 86 ;; (getenv "USER") ".LISTING")))
90; (getenv "USER") ".LISTING"))) 87 ;; (while (file-exists-p output-filename)
91; (while (file-exists-p output-filename) 88 ;; (delete-file output-filename))
92; (delete-file output-filename)) 89 ;; (define-logical-name "SYS$OUTPUT" (concat output-filename "-NEW"))
93; (define-logical-name "SYS$OUTPUT" (concat output-filename "-NEW")) 90 ;; (send-command-to-subprocess 1 command)
94; (send-command-to-subprocess 1 command) 91 ;; (send-command-to-subprocess 1 (concat
95; (send-command-to-subprocess 1 (concat 92 ;; "RENAME " output-filename
96; "RENAME " output-filename 93 ;; "-NEW " output-filename))
97; "-NEW " output-filename)) 94 ;; (while (not (file-exists-p output-filename))
98; (while (not (file-exists-p output-filename)) 95 ;; (sleep-for 1))
99; (sleep-for 1)) 96 ;; (define-logical-name "SYS$OUTPUT" nil)
100; (define-logical-name "SYS$OUTPUT" nil) 97 ;; (insert-file output-filename)
101; (insert-file output-filename) 98 ;; (delete-file output-filename))))
102; (delete-file output-filename))))
103 99
104(defun subprocess-command () 100(defun subprocess-command ()
105 "Starts asynchronous subprocess if not running and switches to its window." 101 "Starts asynchronous subprocess if not running and switches to its window."
@@ -115,8 +111,7 @@ the spawned subprocess. Otherwise brings back current
115line to the last line for resubmission." 111line to the last line for resubmission."
116 (interactive) 112 (interactive)
117 (beginning-of-line) 113 (beginning-of-line)
118 (let ((current-line (buffer-substring (point) 114 (let ((current-line (buffer-substring (point) (line-end-position))))
119 (progn (end-of-line) (point)))))
120 (if (eobp) 115 (if (eobp)
121 (progn 116 (progn
122 (if (not subprocess-running) 117 (if (not subprocess-running)
@@ -129,15 +124,16 @@ line to the last line for resubmission."
129 (progn (beginning-of-line) (insert command-prefix-string))) 124 (progn (beginning-of-line) (insert command-prefix-string)))
130 (next-line 1)))) 125 (next-line 1))))
131 ;; else -- if not at last line in buffer 126 ;; else -- if not at last line in buffer
132 (end-of-buffer) 127 (goto-char (point-max))
133 (backward-char) 128 (backward-char)
134 (next-line 1) 129 (next-line 1)
135 (if (string-equal command-prefix-string 130 (insert
136 (substring current-line 0 (length command-prefix-string))) 131 (if (compare-strings command-prefix-string nil nil
137 (insert (substring current-line (length command-prefix-string))) 132 current-line 0 (length command-prefix-string))
138 (insert current-line))))) 133 (substring current-line (length command-prefix-string))
134 current-line)))))
139 135
140(defun command-kill-line() 136(defun command-kill-line ()
141 "Kills the current line. Used in command mode." 137 "Kills the current line. Used in command mode."
142 (interactive) 138 (interactive)
143 (beginning-of-line) 139 (beginning-of-line)
@@ -145,5 +141,5 @@ line to the last line for resubmission."
145 141
146(define-key esc-map "$" 'subprocess-command) 142(define-key esc-map "$" 'subprocess-command)
147 143
148;;; arch-tag: 600b2512-f903-4887-bcd2-e76b306f5b66 144;; arch-tag: 600b2512-f903-4887-bcd2-e76b306f5b66
149;;; vmsproc.el ends here 145;;; vmsproc.el ends here