Function: ert--make-print-advice

ert--make-print-advice is a byte-compiled function defined in ert-x.el.gz.

Signature

(ert--make-print-advice COLLECTOR)

Documentation

Create around advice for print functions for ert-collect-messages.

The created advice function will just call the original function unless the output is going to the echo area (when PRINTCHARFUN is t or PRINTCHARFUN is nil and standard-output is t). If the output is destined for the echo area, the advice function will convert it to a string and pass it to COLLECTOR first.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/ert-x.el.gz
(defun ert--make-print-advice (collector)
  "Create around advice for print functions for `ert-collect-messages'.
The created advice function will just call the original function
unless the output is going to the echo area (when PRINTCHARFUN is
t or PRINTCHARFUN is nil and `standard-output' is t).  If the
output is destined for the echo area, the advice function will
convert it to a string and pass it to COLLECTOR first."
  ;;; FIXME: Pass on OVERRIDES.
  (lambda (func object &optional printcharfun _overrides)
    (if (not (eq t (or printcharfun standard-output)))
        (funcall func object printcharfun)
      (funcall collector (with-output-to-string
                           (funcall func object)))
      (funcall func object printcharfun))))