Function: trace-make-advice

trace-make-advice is a byte-compiled function defined in trace.el.gz.

Signature

(trace-make-advice FUNCTION BUFFER BACKGROUND CONTEXT)

Documentation

Build the piece of advice to be added to trace FUNCTION.

FUNCTION is the name of the traced function. BUFFER is the buffer where the trace should be printed. BACKGROUND if nil means to display BUFFER. CONTEXT should be a function that returns extra text that should be printed after the arguments in the trace.

Source Code

;; Defined in /usr/src/emacs/lisp/emacs-lisp/trace.el.gz
(defun trace-make-advice (function buffer background context)
  "Build the piece of advice to be added to trace FUNCTION.
FUNCTION is the name of the traced function.
BUFFER is the buffer where the trace should be printed.
BACKGROUND if nil means to display BUFFER.
CONTEXT should be a function that returns extra text that should
be printed after the arguments in the trace."
  (lambda (body &rest args)
    (let ((trace-level (1+ trace-level))
          (trace-buffer (get-buffer-create buffer)))
      ;; Insert a separator from previous trace output:
      (unless inhibit-trace
        (unless background (trace--display-buffer trace-buffer))
        (if (= trace-level 1) (trace--insert trace-separator)))
      (trace--entry-message
       function trace-level args context)
      (let ((result))
        (unwind-protect
            (setq result (list (apply body args)))
          (trace--exit-message
           function
           trace-level
           (if result (car result) '\!non-local\ exit\!)
           context))
        (car result)))))