Function: eshell-send-input
eshell-send-input is an interactive and byte-compiled function defined
in esh-mode.el.gz.
Signature
(eshell-send-input &optional USE-REGION QUEUE-P NO-NEWLINE)
Documentation
Send the input received to Eshell for parsing and processing.
After eshell-last-output-end, sends all text from that marker to
point as input. Before that marker, calls eshell-get-old-input to
retrieve old input, copies it to the end of the buffer, and sends it.
If USE-REGION is non-nil, the current region (between point and mark) will be used as input.
If QUEUE-P is non-nil, input will be queued until the next prompt, rather than sent to the currently active process. If no process, the input is processed immediately.
If NO-NEWLINE is non-nil, the input is sent without an implied final newline.
Key Bindings
Source Code
;; Defined in /usr/src/emacs/lisp/eshell/esh-mode.el.gz
(defun eshell-send-input (&optional use-region queue-p no-newline)
"Send the input received to Eshell for parsing and processing.
After `eshell-last-output-end', sends all text from that marker to
point as input. Before that marker, calls `eshell-get-old-input' to
retrieve old input, copies it to the end of the buffer, and sends it.
If USE-REGION is non-nil, the current region (between point and mark)
will be used as input.
If QUEUE-P is non-nil, input will be queued until the next prompt,
rather than sent to the currently active process. If no process, the
input is processed immediately.
If NO-NEWLINE is non-nil, the input is sent without an implied final
newline."
(interactive "P")
;; Note that the input string does not include its terminal newline.
(let* ((proc-running-p (eshell-head-process))
(send-to-process-p (and proc-running-p (not queue-p))))
(unless (and send-to-process-p
(not (eq (process-status
(eshell-head-process))
'run)))
(if (or send-to-process-p
(>= (point) eshell-last-output-end))
(goto-char (point-max))
(let ((copy (eshell-get-old-input use-region)))
(goto-char eshell-last-output-end)
(insert-and-inherit copy)))
(unless (or no-newline
(and eshell-send-direct-to-subprocesses
send-to-process-p))
(insert-before-markers-and-inherit ?\n))
;; Delete and reinsert input. This seems like a no-op, except
;; for the resulting entries in the undo list: undoing this
;; insertion will delete the region, moving the process mark
;; back to its original position.
(let ((text (buffer-substring eshell-last-output-end (point)))
(inhibit-read-only t))
(delete-region eshell-last-output-end (point))
(insert text))
(if send-to-process-p
(progn
(eshell-update-markers eshell-last-output-end)
(if (or eshell-send-direct-to-subprocesses
(= eshell-last-input-start eshell-last-input-end))
(unless no-newline
(process-send-string (eshell-head-process) "\n"))
(process-send-region (eshell-head-process)
eshell-last-input-start
eshell-last-input-end)))
(if (= eshell-last-output-end (point))
(run-hooks 'eshell-post-command-hook)
(let (input)
(eshell-condition-case err
(progn
(setq input (buffer-substring-no-properties
eshell-last-output-end (1- (point))))
(run-hook-with-args 'eshell-expand-input-functions
eshell-last-output-end (1- (point)))
(let ((cmd (eshell-parse-command-input
eshell-last-output-end (1- (point)))))
(when cmd
(eshell-update-markers eshell-last-output-end)
(setq input (buffer-substring-no-properties
eshell-last-input-start
(1- eshell-last-input-end)))
(run-hooks 'eshell-input-filter-functions)
(and (catch 'eshell-terminal
(ignore
(if (and (not proc-running-p)
(eshell-invoke-directly-p cmd))
(eval cmd)
(eshell-eval-command cmd input))))
(eshell-life-is-too-much)))))
(error
(eshell-reset t)
(eshell-interactive-print
(concat (error-message-string err) "\n"))
(run-hooks 'eshell-post-command-hook)
(insert-and-inherit input)))))))))