summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Schmitt <alan.schmitt@polytechnique.org>2013-05-02 16:57:29 +0200
committerAlan Schmitt <alan.schmitt@polytechnique.org>2013-05-07 09:55:15 +0200
commit6871bdc8e7b773edac44f65b07f40ae3c0a4e2cc (patch)
treee80ac58c469fc567d18cbbba828a38bbc62fa19e
parent69464bf13522e40027beefce8e1655f96292ed91 (diff)
downloadorg-mode-6871bdc8e7b773edac44f65b07f40ae3c0a4e2cc.tar.gz
Babel ocaml: allow ocaml code to run during asynchronous export
* lisp/ob-ocaml.el: Add a custom variable `org-babel-ocaml-command' to specify the name of the toplevel to run. (org-babel-prep-session:ocaml): Directly call `tuareg-run-process-if-needed' with `org-babel-ocaml-command' as argument.
-rw-r--r--lisp/ob-ocaml.el14
1 files changed, 11 insertions, 3 deletions
diff --git a/lisp/ob-ocaml.el b/lisp/ob-ocaml.el
index 03500bb..1a194d8 100644
--- a/lisp/ob-ocaml.el
+++ b/lisp/ob-ocaml.el
@@ -51,6 +51,13 @@
(defvar org-babel-ocaml-eoe-indicator "\"org-babel-ocaml-eoe\";;")
(defvar org-babel-ocaml-eoe-output "org-babel-ocaml-eoe")
+(defcustom org-babel-ocaml-command "ocaml"
+ "Name of the command for executing Ocaml code."
+ :version "24.4"
+ :package-version '(Org . "8.0")
+ :group 'org-babel
+ :type 'string)
+
(defun org-babel-execute:ocaml (body params)
"Execute a block of Ocaml code with Babel."
(let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
@@ -96,9 +103,10 @@
(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))))
+ (if (fboundp 'tuareg-run-process-if-needed)
+ (tuareg-run-process-if-needed org-babel-ocaml-command)
+ (tuareg-run-caml))
+ (get-buffer tuareg-interactive-buffer-name)))
(defun org-babel-variable-assignments:ocaml (params)
"Return list of ocaml statements assigning the block's variables."