emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: abst.proc.do@qq.com (abst.proc.do)
To: emacs-orgmode@gnu.org
Subject: Indirect trace-function results to org-babel current-buffer
Date: Sat, 28 Mar 2020 11:09:13 +0800	[thread overview]
Message-ID: <87d08xch0m.fsf@abst.proc.do> (raw)

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

                 reply	other threads:[~2020-03-28  3:12 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87d08xch0m.fsf@abst.proc.do \
    --to=abst.proc.do@qq.com \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).