Browse Source

fixed error exporting the results of a source-code block

Eric Schulte 16 years ago
parent
commit
b2b62cd506
2 changed files with 7 additions and 19 deletions
  1. 1 1
      lisp/langs/org-babel-ditaa.el
  2. 6 18
      lisp/org-babel-exp.el

+ 1 - 1
lisp/langs/org-babel-ditaa.el

@@ -46,7 +46,7 @@
 (add-to-list 'org-babel-tangle-langs '("ditaa" "ditaa"))
 
 (defvar org-babel-default-header-args:ditaa
-  '((:results . "file") (:exports . "none"))
+  '((:results . "file") (:exports . "results"))
   "Default arguments to use when evaluating a ditaa source block.")
 
 (defun org-babel-execute:ditaa (body params)

+ 6 - 18
lisp/org-babel-exp.el

@@ -43,8 +43,8 @@ both ---- display the code and the results
 code ---- the default, display the code inside the block but do
           not process
 
-results - process the block and replace it with the results of
-          execution
+results - just like none only the block is run on export ensuring
+          that it's results are present in the org-mode buffer
 
 none ----- do not display either code or results upon export"
   (interactive)
@@ -80,7 +80,10 @@ options and are taken from `org-babel-defualt-inline-header-args'."
   (case (intern (or (cdr (assoc :exports params)) "code"))
     ('none "")
     ('code (org-babel-exp-code body lang params inline))
-    ('results (org-babel-exp-results body lang params inline))
+    ('results (save-excursion
+                ;; org-exp-blocks places us at the end of the block
+                (re-search-backward org-babel-src-block-regexp nil t)
+                (org-babel-execute-src-block) ""))
     ('both (concat (org-babel-exp-code body lang params inline)
                    "\n\n"
                    (org-babel-exp-results body lang params inline)))))
@@ -91,20 +94,5 @@ options and are taken from `org-babel-defualt-inline-header-args'."
     (format "#+BEGIN_SRC %s\n%s%s\n#+END_SRC" lang body
             (if (string-match "\n$" body) "" "\n"))))
 
-(defun org-babel-exp-results (body lang params &optional inline)
-  ;; I expect there's a good reason why not, but would it be possible
-  ;; to use org-babel-execute-src-block here? [ded]
-  (let* ((cmd (intern (concat "org-babel-execute:" lang)))
-         (result
-	  (multiple-value-bind (session vars result-params result-type)
-	      (org-babel-process-params params) (funcall cmd body params)))
-         (result-as-org (org-babel-result-to-org-string result)))
-    (if inline
-        (format "=%s=" result)
-      (if (stringp result)
-          (format "#+BEGIN_EXAMPLE\n%s%s\n#+END_EXAMPLE" result
-                  (if (string-match "\n$" body) "" "\n"))
-        result-as-org))))
-
 (provide 'org-babel-exp)
 ;;; org-babel-exp.el ends here