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."
  (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))
      (unless (process-get proc :eshell-busy) ; Already being handled?
        (while (process-get proc :eshell-pending)
          (let ((handles (process-get proc :eshell-handles))
                (index (process-get proc :eshell-handle-index))
                (data (process-get proc :eshell-pending)))
            (process-put proc :eshell-pending nil)
            (process-put proc :eshell-busy t)
            (unwind-protect
                (condition-case nil
                    (eshell-output-object data index handles)
                  ;; FIXME: We want to send SIGPIPE to the process
                  ;; here.  However, remote processes don't currently
                  ;; support that, and not all systems have SIGPIPE in
                  ;; the first place (e.g. MS Windows).  In these
                  ;; cases, just delete the process; this is
                  ;; reasonably close to the right behavior, since the
                  ;; default action for SIGPIPE is to terminate the
                  ;; process.  For use cases where SIGPIPE is truly
                  ;; needed, using an external pipe operator (`*|')
                  ;; may work instead (e.g. when working with remote
                  ;; processes).
                  (eshell-pipe-broken
                   (if (or (process-get proc 'remote-pid)
                           (eq system-type 'windows-nt))
                       (delete-process proc)
                     (signal-process proc 'SIGPIPE))))
              (process-put proc :eshell-busy nil))))))))