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)
    (when (eq (process-status target) 'run)
      (unless (stringp object)
	(setq object (eshell-stringify object)))
      (process-send-string target object)))

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