From: Eric Schulte <schulte.eric@gmail.com>
To: Alan Schmitt <alan.schmitt@polytechnique.org>
Cc: "emacs-orgmode@gnu.org" <emacs-orgmode@gnu.org>
Subject: Re: Patch for asynchronous export of ocaml code
Date: Fri, 03 May 2013 09:57:48 -0600 [thread overview]
Message-ID: <87vc6wxeqw.fsf@gmail.com> (raw)
In-Reply-To: m2k3nh77cy.fsf@polytechnique.org
This looks great, please apply this patch.
Thanks,
Alan Schmitt <alan.schmitt@polytechnique.org> writes:
> Hello,
>
> It is not currently possible to asynchronously export the results of the
> evaluation an ocaml babel block because the evaluation needs to start a toplevel
> and thus asks the user what program to run. This of course blocks the
> asynchronous export.
>
> The attached patch adds a custom variable to specify the name of the command
> to run, and directly calls the tuareg function that starts the toplevel given
> the command.
>
> For some context, here is the code that starts the caml session.
>
> #+BEGIN_SRC emacs-lisp
> (defvar tuareg-interactive-buffer-name)
> (defun org-babel-prep-session:ocaml (session params)
> "Prepare SESSION according to the header arguments in PARAMS."
> (require 'tuareg)
> (let ((tuareg-interactive-buffer-name (if (and (not (string= session "none"))
> (not (string= session "default"))
> (stringp session))
> session
> tuareg-interactive-buffer-name)))
> (save-window-excursion
> (if (fboundp 'tuareg-run-caml) (tuareg-run-caml) (tuareg-run-ocaml))
> (get-buffer tuareg-interactive-buffer-name))))
> #+END_SRC
>
> And this is the code from tuareg that is run.
>
> #+BEGIN_SRC emacs-lisp
> ;;;###autoload
> (defun tuareg-run-ocaml ()
> "Run an OCaml toplevel process. I/O via buffer `*ocaml-toplevel*'."
> (interactive)
> (tuareg-run-process-if-needed)
> (display-buffer tuareg-interactive-buffer-name))
>
> (defun tuareg-run-process-if-needed (&optional cmd)
> "Run an OCaml toplevel process if needed, with an optional command name.
> I/O via buffer `*ocaml-toplevel*'."
> (if cmd
> (setq tuareg-interactive-program cmd)
> (unless (comint-check-proc tuareg-interactive-buffer-name)
> (setq tuareg-interactive-program
> (read-shell-command "OCaml toplevel to run: "
> tuareg-interactive-program))))
> (unless (comint-check-proc tuareg-interactive-buffer-name)
> (let ((cmdlist (tuareg-args-to-list tuareg-interactive-program))
> (process-connection-type nil))
> (set-buffer (apply (function make-comint) "ocaml-toplevel"
> (car cmdlist) nil (cdr cmdlist)))
> (tuareg-interactive-mode)
> (sleep-for 1))))
> #+END_SRC
>
> With this patch (and setting `org-confirm-babel-evaluate' to nil), I'm able to
> export documents requiring the evaluation of caml code asynchronously.
>
> Alan
>
>
--
Eric Schulte
http://cs.unm.edu/~eschulte
next prev parent reply other threads:[~2013-05-06 16:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-02 15:02 Patch for asynchronous export of ocaml code Alan Schmitt
2013-05-03 15:57 ` Eric Schulte [this message]
2013-05-07 7:57 ` Alan Schmitt
2013-05-07 12:18 ` Alan Schmitt
2013-05-07 12:52 ` Eric Schulte
2013-05-06 6:22 ` 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=87vc6wxeqw.fsf@gmail.com \
--to=schulte.eric@gmail.com \
--cc=alan.schmitt@polytechnique.org \
--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).