When tried to apply =trace-function= to a recursive-factorial which print the tracing course to the current buffer:
#+BEGIN_SRC elisp (defun factorial(n) (if (= n 1) 1 (* n (factorial (- n 1))))) (trace-function #'factorial (current-buffer)) (factorial 4) #+END_SRC====================================================================== 1 -> (factorial 4) | 2 -> (factorial 3) | | 3 -> (factorial 2) | | | 4 -> (factorial 1) | | | 4 <- factorial: 1 | | 3 <- factorial: 2 | 2 <- factorial: 6 1 <- factorial: 24 It works as expected but report in the echo area the error : : org-babel-insert-result: Wrong type argument: markerp, nil Additionally, the tracing result does not append immediately to the source code but join to its next heading. #+BEGIN_SRC elisp (defun factorial(n) (if (= n 1) 1 (* n (factorial (- n 1))))) (trace-function #'factorial (current-buffer)) (factorial 4) #+END_SRC * Result ====================================================================== 1 -> (factorial 4) | 2 -> (factorial 3) | | 3 -> (factorial 2) | | | 4 -> (factorial 1) | | | 4 <- factorial: 1 | | 3 <- factorial: 2 | 2 <- factorial: 6 1 <- factorial: 24