Function: comint-exec
comint-exec is a byte-compiled function defined in comint.el.gz.
Signature
(comint-exec BUFFER NAME COMMAND STARTFILE SWITCHES)
Documentation
Start up a process named NAME in buffer BUFFER for Comint modes.
Runs the given COMMAND with SWITCHES, and initial input from STARTFILE.
COMMAND should be one of the following:
- a string, denoting an executable program to create via
start-file-process
- a cons pair of the form (HOST . SERVICE), denoting a TCP
connection to be opened via open-network-stream
- nil, denoting a newly-allocated pty.
This function blasts any old process running in the buffer, and
does not set the buffer mode. You can use this to cheaply run a
series of processes in the same Comint buffer. The hook
comint-exec-hook is run after each exec.
Source Code
;; Defined in /usr/src/emacs/lisp/comint.el.gz
(defun comint-exec (buffer name command startfile switches)
"Start up a process named NAME in buffer BUFFER for Comint modes.
Runs the given COMMAND with SWITCHES, and initial input from STARTFILE.
COMMAND should be one of the following:
- a string, denoting an executable program to create via
`start-file-process'
- a cons pair of the form (HOST . SERVICE), denoting a TCP
connection to be opened via `open-network-stream'
- nil, denoting a newly-allocated pty.
This function blasts any old process running in the buffer, and
does not set the buffer mode. You can use this to cheaply run a
series of processes in the same Comint buffer. The hook
`comint-exec-hook' is run after each exec."
(with-current-buffer buffer
(let ((proc (get-buffer-process buffer))) ; Blast any old process.
(if proc (delete-process proc)))
;; Crank up a new process
(let ((proc
(if (consp command)
(open-network-stream name buffer (car command) (cdr command))
(comint-exec-1 name buffer command switches))))
(set-process-filter proc #'comint-output-filter)
(setq-local comint-ptyp process-connection-type) ; t if pty, nil if pipe.
;; Jump to the end, and set the process mark.
(goto-char (point-max))
(set-marker (process-mark proc) (point))
;; Feed it the startfile.
(when startfile
(comint-send-string proc (with-temp-buffer
(insert-file-contents startfile)
(buffer-string))))
(run-hooks 'comint-exec-hook)
buffer)))