Browse Source

Now accepting vector results from source blocks, and inserting into org file as tables.

Eric Schulte 16 years ago
parent
commit
4385611ebf
2 changed files with 14 additions and 10 deletions
  1. 2 3
      litorgy/litorgy-lisp.el
  2. 12 7
      litorgy/litorgy.el

+ 2 - 3
litorgy/litorgy-lisp.el

@@ -40,9 +40,8 @@ function is called by `litorgy-execute-src-block'."
     (let ((vars (litorgy-reference-variables params))
           (print-level nil) (print-length nil) results)
       (message "executing emacs-lisp code block...")
-      (format "%S"
-              (eval `(let ,(mapcar (lambda (var) `(,(car var) ',(cdr var))) vars)
-                       ,(read body)))))))
+      (eval `(let ,(mapcar (lambda (var) `(,(car var) ',(cdr var))) vars)
+                       ,(read body))))))
 
 (provide 'litorgy-lisp)
 ;;; litorgy-lisp.el ends here

+ 12 - 7
litorgy/litorgy.el

@@ -151,16 +151,21 @@ form.  (language body header-arguments-alist)"
 current source block.  With optional argument REPLACE replace any
 existing results currently located after the source block."
   (if replace (litorgy-remove-result))
-  (unless (or (string-equal (substring result -1)
-                            "\n")
-              (string-equal (substring result -1)
-                            "\r"))
-    (setq result (concat result "\n")))
+  (if (and (stringp result)
+           (not (or (string-equal (substring result -1)
+                                  "\n")
+                    (string-equal (substring result -1)
+                                  "\r"))))
+      (setq result (concat result "\n")))
   (save-excursion
     (re-search-forward "^#\\+end_src" nil t) (open-line 1) (forward-char 2)
-    (litorgy-examplize-region (point) (progn (insert result) (point)))))
+    (if (stringp result)
+        (litorgy-examplize-region (point) (progn (insert result) (point)))
+      (insert ;; for now lets assume the result is a table if it's not a string
+       (orgtbl-to-orgtbl result '(:fmt (lambda (cell) (format "%S" cell)))))
+      (forward-line -1)
+      (org-cycle))))
                                                
-
 (defun litorgy-remove-result ()
   "Remove the result following the current source block"
   (save-excursion