From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: I need help extending ob-ocaml to support :results output Date: Sun, 23 Mar 2014 19:50:54 -0600 Message-ID: <87vbv4gxzl.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:47057) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WRuAb-0005jx-1O for emacs-orgmode@gnu.org; Sun, 23 Mar 2014 21:59:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WRuAW-0003GH-Co for emacs-orgmode@gnu.org; Sun, 23 Mar 2014 21:59:20 -0400 Received: from mail-ob0-x22a.google.com ([2607:f8b0:4003:c01::22a]:43721) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WRuAW-0003Fq-8x for emacs-orgmode@gnu.org; Sun, 23 Mar 2014 21:59:16 -0400 Received: by mail-ob0-f170.google.com with SMTP id uz6so5129059obc.29 for ; Sun, 23 Mar 2014 18:59:12 -0700 (PDT) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Alan Schmitt Cc: emacs-orgmode Alan Schmitt writes: > Hello, > > It seems that ob-ocaml does not support ":results output". For instance, > evaluating the following block: > > #+begin_src ocaml :results output > Printf.printf "foo\nbar\n";; > #+end_src > > Does not result in the two lines "foo" and "bar" but in the value being > returned. > > Unfortunately I don't know enough of babel and emacs-lisp to extend > ob-ocaml to support this. Would someone be willing to guide me through > the `org-babel-execute:ocaml' function in ob-ocaml.el so that I can add > this functionality? > You can step through the execution of `org-babel-execute:ocaml' by first evaluating the function with a prefix argument (meaning with the cursor within the function body press C-u C-A-x) which will edebug [1] the function. You can then evaluate an OCaml code block and when execution hits the `org-babel-execute:ocaml' it will pause, and you can step through the function by continuously pressing space bar. In this way you can see how the code is executed, and you can interactively look at the OCaml session buffer to see where output is printed. Pay special attention to the `org-babel-comint-with-output' function, which is probably where you'll need to make changes when the following holds. (member "output" (cdr (assoc :result-params params))) You can also look for the string "output" in other ob-*.el language files to see how output results are collected. Hope this helps, > > Thanks, > > Alan > Footnotes: [1] see (info "(elisp)Edebug") -- Eric Schulte https://cs.unm.edu/~eschulte PGP: 0x614CA05D