Function: eshell-output-object-to-target

eshell-output-object-to-target is a byte-compiled function defined in esh-io.el.gz.

Signature

(eshell-output-object-to-target OBJECT TARGET)

Documentation

Insert OBJECT into TARGET.

Returns what was actually sent, or nil if nothing was sent.

Source Code

;; Defined in /usr/src/emacs/lisp/eshell/esh-io.el.gz
(defun eshell-output-object-to-target (object target)
  "Insert OBJECT into TARGET.
Returns what was actually sent, or nil if nothing was sent."
  (cond
   ((functionp target)
    (funcall target object))

   ((symbolp target)
    (if (eq target t)                   ; means "print to display"
	(eshell-output-filter nil (eshell-stringify object))
      (if (not (symbol-value target))
	  (set target object)
	(setq object (eshell-stringify object))
	(if (not (stringp (symbol-value target)))
	    (set target (eshell-stringify
			 (symbol-value target))))
	(set target (concat (symbol-value target) object)))))

   ((markerp target)
    (if (buffer-live-p (marker-buffer target))
	(with-current-buffer (marker-buffer target)
	  (let ((moving (= (point) target)))
	    (save-excursion
	      (goto-char target)
	      (unless (stringp object)
		(setq object (eshell-stringify object)))
	      (insert-and-inherit object)
	      (set-marker target (point-marker)))
	    (if moving
		(goto-char target))))))

   ((eshell-processp target)
    (unless (stringp object)
      (setq object (eshell-stringify object)))
    (condition-case err
        (process-send-string target object)
      (error
       ;; If `process-send-string' raises an error and the process has
       ;; finished, treat it as a broken pipe.  Otherwise, just
       ;; re-throw the signal.
       (if (memq (process-status target)
		 '(run stop open closed))
           (signal (car err) (cdr err))
         (signal 'eshell-pipe-broken (list target))))))

   ((consp target)
    (apply (car target) object (cdr target))))
  object)