Преглед на файлове

babel: added row/col-name support to all applicable languages

Eric Schulte преди 15 години
родител
ревизия
bfc93ca808

+ 10 - 8
contrib/babel/lisp/langs/org-babel-C.el

@@ -116,14 +116,16 @@ called by `org-babel-execute-src-block'."
                        tmp-src-file)
                (current-buffer) 'replace error-buf)))))
     (if (= compile 0)
-        (org-babel-read
-         (org-babel-trim
-          (with-temp-buffer
-            (org-babel-shell-command-on-region
-             (point-min) (point-max)
-             (concat tmp-bin-file (if cmdline (concat " " cmdline) ""))
-             (current-buffer) 'replace)
-            (buffer-string))))
+        (org-babel-reassemble-table
+         (org-babel-read
+          (org-babel-trim
+           (with-temp-buffer
+             (org-babel-shell-command-on-region
+              (point-min) (point-max)
+              (concat tmp-bin-file (if cmdline (concat " " cmdline) ""))
+              (current-buffer) 'replace)
+             (buffer-string))))
+         (nth 4 processed-params) (nth 5 processed-params))
       (progn
         (with-current-buffer error-buf
           (goto-char (point-max))

+ 3 - 1
contrib/babel/lisp/langs/org-babel-clojure.el

@@ -269,6 +269,8 @@ last statement in BODY, as elisp."
          (vars (second processed-params))
          (body (org-babel-clojure-build-full-form body vars))
          (session (org-babel-clojure-initiate-session (first processed-params))))
-    (org-babel-clojure-evaluate session body (fourth processed-params))))
+    (org-babel-reassemble-table
+     (org-babel-clojure-evaluate session body (fourth processed-params))
+     (nth 4 processed-params) (nth 5 processed-params))))
 
 (provide 'org-babel-clojure)

+ 13 - 7
contrib/babel/lisp/langs/org-babel-emacs-lisp.el

@@ -35,6 +35,10 @@
 
 (add-to-list 'org-babel-tangle-langs '("emacs-lisp" "el"))
 
+(defvar org-babel-default-header-args:emacs-lisp
+  '((:hlines . "no") (:colnames . "no"))
+  "Default arguments to use when evaluating an emacs-lisp source block.")
+
 (defun org-babel-execute:emacs-lisp (body params)
   "Execute a block of emacs-lisp code with org-babel."
   (message "executing emacs-lisp code block...")
@@ -43,13 +47,15 @@
            (result-params (third processed-params))
            (vars (second processed-params))
            (print-level nil) (print-length nil))
-      (eval `(let ,(mapcar (lambda (var) `(,(car var) ',(cdr var)))
-                           vars)
-	       ,(read (concat "(progn "
-			      (if (or (member "code" result-params)
-				      (member "pp" result-params))
-				  (concat "(pp " body ")") body)
-			      ")")))))))
+      (org-babel-reassemble-table
+       (eval `(let ,(mapcar (lambda (var) `(,(car var) ',(cdr var)))
+                            vars)
+                ,(read (concat "(progn "
+                               (if (or (member "code" result-params)
+                                       (member "pp" result-params))
+                                   (concat "(pp " body ")") body)
+                               ")"))))
+       (nth 4 processed-params) (nth 5 processed-params)))))
 
 (provide 'org-babel-emacs-lisp)
 ;;; org-babel-emacs-lisp.el ends here

+ 5 - 3
contrib/babel/lisp/langs/org-babel-haskell.el

@@ -75,9 +75,11 @@
                    #'org-babel-haskell-read-string
                    (cdr (member org-babel-haskell-eoe
                                 (reverse (mapcar #'org-babel-trim raw)))))))
-    (case result-type
-      (output (mapconcat #'identity (reverse (cdr results)) "\n"))
-      (value (org-babel-haskell-table-or-string (car results))))))
+    (org-babel-reassemble-table
+     (case result-type
+       (output (mapconcat #'identity (reverse (cdr results)) "\n"))
+       (value (org-babel-haskell-table-or-string (car results))))
+     (nth 4 processed-params) (nth 5 processed-params))))
 
 (defun org-babel-haskell-read-string (string)
   "Strip \\\"s from around haskell string"

+ 3 - 1
contrib/babel/lisp/langs/org-babel-ocaml.el

@@ -63,7 +63,9 @@
                 (comint-send-input nil t)
                 (insert org-babel-ocaml-eoe-indicator)
                 (comint-send-input nil t))))
-    (org-babel-ocaml-parse-output (org-babel-trim (car raw)))))
+    (org-babel-reassemble-table
+     (org-babel-ocaml-parse-output (org-babel-trim (car raw)))
+     (nth 4 processed-params) (nth 5 processed-params))))
 
 (defun org-babel-prep-session:ocaml (session params)
   "Prepare SESSION according to the header arguments specified in PARAMS."

+ 3 - 1
contrib/babel/lisp/langs/org-babel-octave.el

@@ -62,7 +62,9 @@
 				     (org-babel-octave-var-to-octave (cdr pair))))
 			   vars "\n") "\n" body "\n"))
 	 (result (org-babel-octave-evaluate session augmented-body result-type matlabp)))
-    (or out-file result)))
+    (or out-file
+        (org-babel-reassemble-table
+         result (nth 4 processed-params) (nth 5 processed-params)))))
 
 (defun org-babel-octave-var-to-octave (var)
   "Convert an emacs-lisp variable into an octave variable.

+ 3 - 2
contrib/babel/lisp/langs/org-babel-oz.el

@@ -233,7 +233,8 @@ called by `org-babel-execute-src-block' via multiple-value-bind."
 ;; 	(session-buffer (org-babel-oz-initiate-session session))
 ;; 	(session (org-babel-prep-session:oz session params))
 	)
-    ;; actually execute the source-code block 
+    ;; actually execute the source-code block
+    (org-babel-reassemble-table
      (case result-type
        (output
 	(progn 
@@ -245,7 +246,7 @@ called by `org-babel-execute-src-block' via multiple-value-bind."
 	  (oz-send-string-expression full-body (if wait-time
 						   wait-time
 						 1)))))
-    ))
+     (nth 4 processed-params) (nth 5 processed-params))))
 
 ;; This function should be used to assign any variables in params in
 ;; the context of the session environment.

+ 3 - 1
contrib/babel/lisp/langs/org-babel-perl.el

@@ -52,7 +52,9 @@ called by `org-babel-execute-src-block'."
 			       (org-babel-perl-var-to-perl (cdr pair))))
 		     vars "\n") "\n" (org-babel-trim body) "\n")) ;; then the source block body
 	(session (org-babel-perl-initiate-session session)))
-    (org-babel-perl-evaluate session full-body result-type)))
+    (org-babel-reassemble-table
+     (org-babel-perl-evaluate session full-body result-type)
+     (nth 4 processed-params) (nth 5 processed-params))))
 
 (defun org-babel-prep-session:perl (session params)
   "Prepare SESSION according to the header arguments specified in PARAMS."

+ 3 - 1
contrib/babel/lisp/langs/org-babel-python.el

@@ -54,7 +54,9 @@ called by `org-babel-execute-src-block'."
                       vars "\n") "\n" (org-babel-trim body) "\n")) ;; then the source block body
          
          (result (org-babel-python-evaluate session full-body result-type)))
-    (or (cdr (assoc :file params)) result)))
+    (or (cdr (assoc :file params))
+        (org-babel-reassemble-table
+         result (nth 4 processed-params) (nth 5 processed-params)))))
 
 (defun org-babel-prep-session:python (session params)
   "Prepare SESSION according to the header arguments specified in PARAMS."

+ 3 - 1
contrib/babel/lisp/langs/org-babel-ruby.el

@@ -63,7 +63,9 @@ called by `org-babel-execute-src-block'."
 			       (org-babel-ruby-var-to-ruby (cdr pair))))
 		     vars "\n") "\n" body "\n")) ;; then the source block body
          (result (org-babel-ruby-evaluate session full-body result-type)))
-    (or (cdr (assoc :file params)) result)))
+    (or (cdr (assoc :file params))
+        (org-babel-reassemble-table
+         result (nth 4 processed-params) (nth 5 processed-params)))))
 
 (defun org-babel-prep-session:ruby (session params)
   "Prepare SESSION according to the header arguments specified in PARAMS."

+ 3 - 1
contrib/babel/lisp/langs/org-babel-sh.el

@@ -56,7 +56,9 @@ function is called by `org-babel-execute-src-block'."
                                 (car pair)
                                 (org-babel-sh-var-to-sh (cdr pair) sep)))
                       vars "\n") "\n" body "\n\n"))) ;; then the source block body
-    (org-babel-sh-evaluate session full-body result-type)))
+    (org-babel-reassemble-table
+     (org-babel-sh-evaluate session full-body result-type)
+     (nth 4 processed-params) (nth 5 processed-params))))
 
 (defun org-babel-prep-session:sh (session params)
   "Prepare SESSION according to the header arguments specified in PARAMS."

+ 4 - 1
contrib/babel/lisp/langs/org-babel-sql.el

@@ -70,7 +70,10 @@ called by `org-babel-execute-src-block'."
     (shell-command command)
     (with-temp-buffer
       (org-table-import out-file nil)
-      (org-table-to-lisp))))
+      (org-babel-reassemble-table
+       (org-table-to-lisp)
+       (nth 4 processed-params) (nth 5 processed-params)))))
+
 
 (defun org-babel-prep-session:sql (session params)
   "Prepare SESSION according to the header arguments specified in PARAMS."