emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Alan Schmitt <alan.schmitt@polytechnique.org>
To: Eric Schulte <schulte.eric@gmail.com>
Cc: emacs-orgmode <emacs-orgmode@gnu.org>
Subject: Re: ocaml babel no longer works?
Date: Mon, 11 Feb 2013 22:23:09 +0100	[thread overview]
Message-ID: <m2pq064kaq.fsf@polytechnique.org> (raw)
In-Reply-To: <876221i41q.fsf@gmail.com>

Hello,

Eric Schulte writes:

> Thanks for looking into this.  I've applied a patch to ob-ocaml.el which
> should handle the two different tuareg execution functions.

Thanks a lot.

About the thing "getting stuck", I made some progress. My error was that
I did not add ";;" at the end of my ocaml phrase, which resulted in an
error in the toplevel:

#+begin_quote
        Objective Caml version 3.12.1

# let x = 2 in x
"org-babel-ocaml-eoe";;
  Characters 13-14:
  let x = 2 in x
               ^
Error: This expression is not a function; it cannot be applied
#+end_quote

As you see, it's trying to apply the 'x' to the "oeo" thing. My guess is
that babel waits until seeing this special string before sending the
result back. By the way, this allows for some fun things, like this:

#+BEGIN_SRC ocaml
let f x = () in f
#+END_SRC

make babel stuck because the interpreter is in this state:

#+begin_quote
# let f x = () in f
"org-babel-ocaml-eoe";;
  - : unit = ()
#+end_quote

So I have a suggestion and two feature requests.

The suggestion: instead of appending '"org-babel-ocaml-eoe";;' to the
code, how simply put ';;' (which will make sure everything is flushed)
then detect the toplevel is done by seeing the string '# ' at the
beginning of the line? Would there be an issue with the fact that this
line does not have a newline? If so, an alternative suggestion would be
to use the longer ';; "org-babel-ocaml-eoe";;' which makes sure the
phrase in the input won't interact with the marker.

The first feature requests: if there is an error, could it be parsed?
(It probably always start with 'Error: '). Then the error could be put
in the result block, instead of waiting for the marker that will never
appear.

The second feature request: I want to use this for my ocaml lab classes
(I'm thinking of giving them an org file they have to complete by
writing the caml code). Could it be possible to have an option for the
full output of the compiler (and not just the result) to be printed? I
see it does it when it does not recognize the type of the output. So I
guess such an option would be applied to either
org-babel-ocaml-parse-output or the place where it's called.

Thanks a lot for any suggestion as how to implement this. I think I see
how to do the second one (except I don't know how to add a configuration
variable to toggle it). I have no idea about the first one, though.

Alan

  parent reply	other threads:[~2013-02-11 21:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-08 14:23 ocaml babel no longer works? Alan Schmitt
2013-02-09 12:06 ` Alan Schmitt
2013-02-09 21:09   ` Eric Schulte
2013-02-09 21:17     ` Sebastien Vauban
2013-02-11 21:23     ` Alan Schmitt [this message]
2013-02-13 16:24       ` Eric Schulte
2013-02-14  7:40         ` Alan Schmitt
2013-02-14 17:34           ` Eric Schulte
2013-05-02  9:49         ` Alan Schmitt
2013-05-03 15:57           ` Eric Schulte
2013-05-07  7:56             ` Alan Schmitt
2013-05-06  6:20           ` Alan Schmitt

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=m2pq064kaq.fsf@polytechnique.org \
    --to=alan.schmitt@polytechnique.org \
    --cc=emacs-orgmode@gnu.org \
    --cc=schulte.eric@gmail.com \
    /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).