summaryrefslogtreecommitdiff
path: root/lisp/org/ob-ocaml.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/org/ob-ocaml.el')
-rw-r--r--lisp/org/ob-ocaml.el29
1 files changed, 14 insertions, 15 deletions
diff --git a/lisp/org/ob-ocaml.el b/lisp/org/ob-ocaml.el
index f5add5c5754..2217118e537 100644
--- a/lisp/org/ob-ocaml.el
+++ b/lisp/org/ob-ocaml.el
@@ -5,7 +5,7 @@
;; Author: Eric Schulte
;; Keywords: literate programming, reproducible research
;; Homepage: http://orgmode.org
-;; Version: 7.01
+;; Version: 7.3
;; This file is part of GNU Emacs.
@@ -51,20 +51,12 @@
(defvar org-babel-ocaml-eoe-indicator "\"org-babel-ocaml-eoe\";;")
(defvar org-babel-ocaml-eoe-output "org-babel-ocaml-eoe")
-(defun org-babel-expand-body:ocaml (body params &optional processed-params)
- "Expand BODY according to PARAMS, return the expanded body."
- (let ((vars (nth 1 (or processed-params (org-babel-process-params params)))))
- (concat
- (mapconcat
- (lambda (pair) (format "let %s = %s;;" (car pair)
- (org-babel-ocaml-elisp-to-ocaml (cdr pair))))
- vars "\n") "\n" body "\n")))
-
(defun org-babel-execute:ocaml (body params)
"Execute a block of Ocaml code with Babel."
- (let* ((processed-params (org-babel-process-params params))
- (vars (nth 1 processed-params))
- (full-body (org-babel-expand-body:ocaml body params processed-params))
+ (let* ((vars (mapcar #'cdr (org-babel-get-header params :var)))
+ (full-body (org-babel-expand-body:generic
+ body params
+ (org-babel-variable-assignments:ocaml params)))
(session (org-babel-prep-session:ocaml
(cdr (assoc :session params)) params))
(raw (org-babel-comint-with-output
@@ -84,9 +76,9 @@
(org-babel-reassemble-table
(org-babel-ocaml-parse-output (org-babel-trim clean))
(org-babel-pick-name
- (nth 4 processed-params) (cdr (assoc :colnames params)))
+ (cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
(org-babel-pick-name
- (nth 5 processed-params) (cdr (assoc :rownames params))))))
+ (cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
(defvar tuareg-interactive-buffer-name)
(defun org-babel-prep-session:ocaml (session params)
@@ -100,6 +92,13 @@
(save-window-excursion (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"
+ (mapcar
+ (lambda (pair) (format "let %s = %s;;" (car pair)
+ (org-babel-ocaml-elisp-to-ocaml (cdr pair))))
+ (mapcar #'cdr (org-babel-get-header params :var))))
+
(defun org-babel-ocaml-elisp-to-ocaml (val)
"Return a string of ocaml code which evaluates to VAL."
(if (listp val)