comparison lisp/comint.el @ 9388:c9b5541ec9f5

(comint-check-proc): Recognise `open'. (comint-exec): Use open-network-stream if command is a cons pair.
author Richard M. Stallman <rms@gnu.org>
date Fri, 07 Oct 1994 10:20:37 +0000
parents b2440a22efc2
children 077430ee7179
comparison
equal deleted inserted replaced
9387:ccd27c6ef48d 9388:c9b5541ec9f5
484 menu-bar-final-items)) 484 menu-bar-final-items))
485 ) 485 )
486 486
487 (defun comint-check-proc (buffer) 487 (defun comint-check-proc (buffer)
488 "Return t if there is a living process associated w/buffer BUFFER. 488 "Return t if there is a living process associated w/buffer BUFFER.
489 Living means the status is `run' or `stop'. 489 Living means the status is `open', `run', or `stop'.
490 BUFFER can be either a buffer or the name of one." 490 BUFFER can be either a buffer or the name of one."
491 (let ((proc (get-buffer-process buffer))) 491 (let ((proc (get-buffer-process buffer)))
492 (and proc (memq (process-status proc) '(run stop))))) 492 (and proc (memq (process-status proc) '(open run stop)))))
493 493
494 ;;; Note that this guy, unlike shell.el's make-shell, barfs if you pass it () 494 ;;; Note that this guy, unlike shell.el's make-shell, barfs if you pass it ()
495 ;;; for the second argument (program). 495 ;;; for the second argument (program).
496 ;;;###autoload 496 ;;;###autoload
497 (defun make-comint (name program &optional startfile &rest switches) 497 (defun make-comint (name program &optional startfile &rest switches)
498 "Make a comint process NAME in a buffer, running PROGRAM. 498 "Make a comint process NAME in a buffer, running PROGRAM.
499 The name of the buffer is made by surrounding NAME with `*'s. 499 The name of the buffer is made by surrounding NAME with `*'s.
500 If there is already a running process in that buffer, it is not restarted. 500 PROGRAM should be either a string denoting an executable program to create
501 Optional third arg STARTFILE is the name of a file to send the contents of to 501 via `start-process', or a cons pair of the form (HOST . SERVICE) denoting a TCP
502 the process. Any more args are arguments to PROGRAM." 502 connection to be opened via `open-network-stream'. If there is already a
503 running process in that buffer, it is not restarted. Optional third arg
504 STARTFILE is the name of a file to send the contents of to the process.
505
506 If PROGRAM is a string, any more args are arguments to PROGRAM."
503 (let ((buffer (get-buffer-create (concat "*" name "*")))) 507 (let ((buffer (get-buffer-create (concat "*" name "*"))))
504 ;; If no process, or nuked process, crank up a new one and put buffer in 508 ;; If no process, or nuked process, crank up a new one and put buffer in
505 ;; comint mode. Otherwise, leave buffer and existing process alone. 509 ;; comint mode. Otherwise, leave buffer and existing process alone.
506 (cond ((not (comint-check-proc buffer)) 510 (cond ((not (comint-check-proc buffer))
507 (save-excursion 511 (save-excursion
530 (save-excursion 534 (save-excursion
531 (set-buffer buffer) 535 (set-buffer buffer)
532 (let ((proc (get-buffer-process buffer))) ; Blast any old process. 536 (let ((proc (get-buffer-process buffer))) ; Blast any old process.
533 (if proc (delete-process proc))) 537 (if proc (delete-process proc)))
534 ;; Crank up a new process 538 ;; Crank up a new process
535 (let ((proc (comint-exec-1 name buffer command switches))) 539 (let ((proc
540 (if (consp command)
541 (open-network-stream name buffer (car command) (cdr command))
542 (comint-exec-1 name buffer command switches))))
536 (set-process-filter proc 'comint-output-filter) 543 (set-process-filter proc 'comint-output-filter)
537 (make-local-variable 'comint-ptyp) 544 (make-local-variable 'comint-ptyp)
538 (setq comint-ptyp process-connection-type) ; T if pty, NIL if pipe. 545 (setq comint-ptyp process-connection-type) ; T if pty, NIL if pipe.
539 ;; Jump to the end, and set the process mark. 546 ;; Jump to the end, and set the process mark.
540 (goto-char (point-max)) 547 (goto-char (point-max))