Update copyright notices for 2013.
[bpt/emacs.git] / lisp / org / ob-ocaml.el
index bf34b98..bff41f8 100644 (file)
@@ -1,11 +1,10 @@
 ;;; ob-ocaml.el --- org-babel functions for ocaml evaluation
 
-;; Copyright (C) 2009-201 Free Software Foundation, Inc.
+;; Copyright (C) 2009-2013 Free Software Foundation, Inc.
 
 ;; Author: Eric Schulte
 ;; Keywords: literate programming, reproducible research
 ;; Homepage: http://orgmode.org
-;; Version: 7.4
 
 ;; This file is part of GNU Emacs.
 
@@ -44,6 +43,7 @@
 (declare-function tuareg-run-caml "ext:tuareg" ())
 (declare-function tuareg-interactive-send-input "ext:tuareg" ())
 
+(defvar org-babel-tangle-lang-exts)
 (add-to-list 'org-babel-tangle-lang-exts '("ocaml" . "ml"))
 
 (defvar org-babel-default-header-args:ocaml '())
@@ -72,7 +72,7 @@
                                         (progn (setq out nil) line)
                                       (when (string-match re line)
                                         (progn (setq out t) nil))))
-                                (mapcar #'org-babel-trim (reverse raw))))))))
+                                  (mapcar #'org-babel-trim (reverse raw))))))))
     (org-babel-reassemble-table
      (org-babel-ocaml-parse-output (org-babel-trim clean))
      (org-babel-pick-name
                            (get-buffer tuareg-interactive-buffer-name))))
 
 (defun org-babel-variable-assignments:ocaml (params)
-  "Return list of ocaml statements assigning the block's variables"
+  "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)
@@ -125,32 +125,20 @@ OUTPUT is string output from an ocaml process."
   "Convert RESULTS into an elisp table or string.
 If the results look like a table, then convert them into an
 Emacs-lisp table, otherwise return the results as a string."
-  (org-babel-read
-   (if (and (stringp results) (string-match "^\\[.+\\]$" results))
-       (org-babel-read
-        (replace-regexp-in-string
-         "\\[" "(" (replace-regexp-in-string
-                    "\\]" ")" (replace-regexp-in-string
-                               "; " " " (replace-regexp-in-string
-                                         "'" "\"" results)))))
-     results)))
+  (org-babel-script-escape (replace-regexp-in-string ";" "," results)))
 
 (defun org-babel-ocaml-read-array (results)
   "Convert RESULTS into an elisp table or string.
 If the results look like a table, then convert them into an
 Emacs-lisp table, otherwise return the results as a string."
-  (org-babel-read
-   (if (and (stringp results) (string-match "^\\[.+\\]$" results))
-       (org-babel-read
-       (concat
-        "'" (replace-regexp-in-string
-             "\\[|" "(" (replace-regexp-in-string
-                         "|\\]" ")" (replace-regexp-in-string
-                                     "; " " " (replace-regexp-in-string
-                                               "'" "\"" results))))))
-     results)))
+  (org-babel-script-escape
+   (replace-regexp-in-string
+    "\\[|" "[" (replace-regexp-in-string
+               "|\\]" "]" (replace-regexp-in-string
+                           "; " "," results)))))
 
 (provide 'ob-ocaml)
 
 
+
 ;;; ob-ocaml.el ends here