Function: eshell-insertion-filter

eshell-insertion-filter is a byte-compiled function defined in esh-proc.el.gz.

Signature

(eshell-insertion-filter PROC STRING)

Documentation

Insert a string into the eshell buffer, or a process/file/buffer.

PROC is the process for which we're inserting output. STRING is the output.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-proc.el.gz
(defun eshell-insertion-filter (proc string)
  "Insert a string into the eshell buffer, or a process/file/buffer.
PROC is the process for which we're inserting output.  STRING is the
output."
  (eshell-debug-command 'process
    "received output from process `%s'\n\n%s" proc string)
  (when (buffer-live-p (process-buffer proc))
    (with-current-buffer (process-buffer proc)
      (process-put proc :eshell-pending
                   (concat (process-get proc :eshell-pending)
                           string))
      (if (process-get proc :eshell-busy)
          (eshell-debug-command 'process "i/o busy for process `%s'" proc)
        (unwind-protect
            (let ((handles (process-get proc :eshell-handles))
                  (index (process-get proc :eshell-handle-index))
                  data)
              (while (setq data (process-get proc :eshell-pending))
                (process-put proc :eshell-pending nil)
                (eshell-debug-command 'process
                  "forwarding output from process `%s'\n\n%s" proc data)
                (condition-case nil
                    (eshell-output-object data index handles)
                  (eshell-pipe-broken
                   ;; The output pipe broke, so send SIGPIPE to the
                   ;; process.  NOTE: Due to the additional indirection
                   ;; of Emacs process filters, the process will likely
                   ;; see the SIGPIPE later than it would in a regular
                   ;; shell, which could cause problems.  For cases
                   ;; where this matters, using an external pipe
                   ;; operator (`*|') may work instead.
                   (cond
                    ;; Delay signaling remote processes to prevent
                    ;; "Forbidden reentrant call of Tramp".
                    ((process-get proc 'remote-pid)
                     (run-at-time 0 nil #'signal-process proc 'SIGPIPE))
                    ;; MS-Windows doesn't support SIGPIPE, so send
                    ;; SIGTERM there instead; this is reasonably close
                    ;; to the right behavior, since the default action
                    ;; for SIGPIPE is to terminate the process.
                    ((eq system-type 'windows-nt)
                     (signal-process proc 'SIGTERM))
                    (t
                     (signal-process proc 'SIGPIPE)))))))
          (process-put proc :eshell-busy nil))))))