Function: comint-redirect-send-command-to-process
comint-redirect-send-command-to-process is an autoloaded, interactive
and byte-compiled function defined in comint.el.gz.
Signature
(comint-redirect-send-command-to-process COMMAND OUTPUT-BUFFER PROCESS ECHO &optional NO-DISPLAY)
Documentation
Send COMMAND to PROCESS, with output to OUTPUT-BUFFER.
With prefix arg, echo output in process buffer.
If NO-DISPLAY is non-nil, do not show the output buffer.
Probably introduced at or before Emacs version 21.1.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/comint.el.gz
;;;###autoload
(defun comint-redirect-send-command-to-process
(command output-buffer process echo &optional no-display)
"Send COMMAND to PROCESS, with output to OUTPUT-BUFFER.
With prefix arg, echo output in process buffer.
If NO-DISPLAY is non-nil, do not show the output buffer."
(interactive "sCommand: \nBOutput Buffer: \nbProcess Buffer: \nP" comint-mode)
(let* (;; The process buffer
(process-buffer (if (processp process)
(process-buffer process)
process))
(proc (get-buffer-process process-buffer)))
;; Change to the process buffer
(with-current-buffer process-buffer
;; Make sure there's a prompt in the current process buffer
(and comint-redirect-perform-sanity-check
(save-excursion
(goto-char (point-max))
(or (re-search-backward comint-prompt-regexp nil t)
(error "No prompt found or `comint-prompt-regexp' not set properly"))))
;; Set up for redirection
(comint-redirect-setup
output-buffer
(current-buffer) ; Comint Buffer
comint-prompt-regexp ; Finished Regexp
echo) ; Echo input
;; Set the filter.
(add-function :around (process-filter proc) #'comint-redirect-filter)
;; Send the command
(process-send-string (current-buffer) (concat command "\n"))
;; Show the output
(or no-display
(display-buffer
(get-buffer-create
(if (listp output-buffer)
(car output-buffer)
output-buffer)))))))