Mercurial > emacs
comparison lisp/comint.el @ 1131:853d0d4c61fb
entered into RCS
author | Richard M. Stallman <rms@gnu.org> |
---|---|
date | Sun, 13 Sep 1992 21:51:49 +0000 |
parents | a93f0b1ba909 |
children | dcf780f7ae1b |
comparison
equal
deleted
inserted
replaced
1130:e18597ff3c95 | 1131:853d0d4c61fb |
---|---|
106 | 106 |
107 ;;; Code: | 107 ;;; Code: |
108 | 108 |
109 (defconst comint-version "2.03") | 109 (defconst comint-version "2.03") |
110 | 110 |
111 (require 'ring) | |
111 | 112 |
112 ;;; Buffer Local Variables: | 113 ;;; Buffer Local Variables: |
113 ;;;============================================================================ | 114 ;;;============================================================================ |
114 ;;; Comint mode buffer local variables: | 115 ;;; Comint mode buffer local variables: |
115 ;;; comint-prompt-regexp - string comint-bol uses to match prompt. | 116 ;;; comint-prompt-regexp - string comint-bol uses to match prompt. |
182 (process-kill-without-query)). In contrast, the comint-mode-hook is only | 183 (process-kill-without-query)). In contrast, the comint-mode-hook is only |
183 executed once when the buffer is created.") | 184 executed once when the buffer is created.") |
184 | 185 |
185 (defvar comint-mode-map nil) | 186 (defvar comint-mode-map nil) |
186 | 187 |
188 (defvar comint-ptyp t | |
189 "True if communications via pty; false if by pipe. Buffer local. | |
190 This is to work around a bug in emacs process signalling.") | |
191 | |
187 (defvar comint-input-ring nil) | 192 (defvar comint-input-ring nil) |
188 (defvar comint-last-input-start) | 193 (defvar comint-last-input-start) |
189 (defvar comint-last-input-end) | 194 (defvar comint-last-input-end) |
195 (defvar comint-input-ring-index) | |
196 (put 'comint-input-ring 'permanent-local t) | |
197 (put 'comint-ptyp 'permanent-local t) | |
190 | 198 |
191 (defun comint-mode () | 199 (defun comint-mode () |
192 "Major mode for interacting with an inferior interpreter. | 200 "Major mode for interacting with an inferior interpreter. |
193 Interpreter name is same as buffer name, sans the asterisks. | 201 Interpreter name is same as buffer name, sans the asterisks. |
194 Return at end of buffer sends line as input. | 202 Return at end of buffer sends line as input. |
213 | 221 |
214 \\{comint-mode-map} | 222 \\{comint-mode-map} |
215 | 223 |
216 Entry to this mode runs the hooks on comint-mode-hook" | 224 Entry to this mode runs the hooks on comint-mode-hook" |
217 (interactive) | 225 (interactive) |
218 (let ((old-ring (and (assq 'comint-input-ring (buffer-local-variables)) | 226 ;; Do not remove this. All major modes must do this. |
219 (boundp 'comint-input-ring) | 227 (kill-all-local-variables) |
220 comint-input-ring)) | |
221 (old-ptyp comint-ptyp)) ; preserve across local var kill. gross. | |
222 ; (kill-all-local-variables) ; Removed 1/15/90 Olin | |
223 (setq major-mode 'comint-mode) | 228 (setq major-mode 'comint-mode) |
224 (setq mode-name "Comint") | 229 (setq mode-name "Comint") |
225 (setq mode-line-process '(": %s")) | 230 (setq mode-line-process '(": %s")) |
226 (use-local-map comint-mode-map) | 231 (use-local-map comint-mode-map) |
227 (make-local-variable 'comint-last-input-start) | 232 (make-local-variable 'comint-last-input-start) |
239 (make-local-variable 'comint-input-sentinel) | 244 (make-local-variable 'comint-input-sentinel) |
240 (make-local-variable 'comint-input-filter) | 245 (make-local-variable 'comint-input-filter) |
241 (make-local-variable 'comint-input-sender) | 246 (make-local-variable 'comint-input-sender) |
242 (make-local-variable 'comint-eol-on-send) | 247 (make-local-variable 'comint-eol-on-send) |
243 (make-local-variable 'comint-ptyp) | 248 (make-local-variable 'comint-ptyp) |
244 (setq comint-ptyp old-ptyp) | |
245 (make-local-variable 'comint-exec-hook) | 249 (make-local-variable 'comint-exec-hook) |
246 (run-hooks 'comint-mode-hook) | 250 (run-hooks 'comint-mode-hook) |
247 ;Do this after the hook so the user can mung COMINT-INPUT-RING-SIZE w/his hook. | 251 (or comint-input-ring |
248 ;The test is so we don't lose history if we run comint-mode twice in | 252 (setq comint-input-ring (make-ring comint-input-ring-size)))) |
249 ;a buffer. | |
250 (setq comint-input-ring (if (ring-p old-ring) old-ring | |
251 (make-ring comint-input-ring-size))))) | |
252 | |
253 ;;; The old-ptyp stuff above is because we have to preserve the value of | |
254 ;;; comint-ptyp across calls to comint-mode, in spite of the | |
255 ;;; kill-all-local-variables that it does. Blech. Hopefully, this will all | |
256 ;;; go away when a later release fixes the signalling bug. | |
257 ;;; (Later: I removed the kill-all-local-variables, but have left this | |
258 ;;; other code in place just in case I reverse myself.) | |
259 | 253 |
260 (if comint-mode-map | 254 (if comint-mode-map |
261 nil | 255 nil |
262 (setq comint-mode-map (make-sparse-keymap)) | 256 (setq comint-mode-map (make-sparse-keymap)) |
263 (define-key comint-mode-map "\ep" 'comint-previous-input) | 257 (define-key comint-mode-map "\ep" 'comint-previous-input) |
310 (save-excursion | 304 (save-excursion |
311 (set-buffer buffer) | 305 (set-buffer buffer) |
312 (comint-mode)) ; Install local vars, mode, keymap, ... | 306 (comint-mode)) ; Install local vars, mode, keymap, ... |
313 (comint-exec buffer name program startfile switches))) | 307 (comint-exec buffer name program startfile switches))) |
314 buffer)) | 308 buffer)) |
315 | |
316 (defvar comint-ptyp t | |
317 "True if communications via pty; false if by pipe. Buffer local. | |
318 This is to work around a bug in emacs process signalling.") | |
319 | 309 |
320 (defun comint-exec (buffer name command startfile switches) | 310 (defun comint-exec (buffer name command startfile switches) |
321 "Fires up a process in buffer for comint modes. | 311 "Fires up a process in buffer for comint modes. |
322 Blasts any old process running in the buffer. Doesn't set the buffer mode. | 312 Blasts any old process running in the buffer. Doesn't set the buffer mode. |
323 You can use this to cheaply run a series of processes in the same comint | 313 You can use this to cheaply run a series of processes in the same comint |