Function: ielm-standard-output-impl
ielm-standard-output-impl is a byte-compiled function defined in
ielm.el.gz.
Signature
(ielm-standard-output-impl PROCESS)
Documentation
Return a function to use for standard-output while in ielm eval.
The returned function takes one character as input. Passing nil to this function instead of a character flushes the output buffer. Passing t appends a terminating newline if the buffer is nonempty, then flushes the buffer.
Source Code
;; Defined in /usr/src/emacs/lisp/ielm.el.gz
;;; Evaluation
(defun ielm-standard-output-impl (process)
"Return a function to use for `standard-output' while in ielm eval.
The returned function takes one character as input. Passing nil
to this function instead of a character flushes the output
buffer. Passing t appends a terminating newline if the buffer is
nonempty, then flushes the buffer."
;; Use an intermediate output buffer because doing redisplay for
;; each character we output is too expensive. Set up a flush timer
;; so that users don't have to wait for whole lines to appear before
;; seeing output.
(let* ((output-buffer nil)
(flush-timer nil)
(flush-buffer
(lambda ()
(comint-output-filter
process
(apply #'string (nreverse output-buffer)))
(redisplay)
(setf output-buffer nil)
(when flush-timer
(cancel-timer flush-timer)
(setf flush-timer nil)))))
(lambda (char)
(let (flush-now)
(cond ((and (eq char t) output-buffer)
(push ?\n output-buffer)
(setf flush-now t))
((characterp char)
(push char output-buffer)))
(if flush-now
(funcall flush-buffer)
(unless flush-timer
(setf flush-timer (run-with-timer 0.1 nil flush-buffer))))))))