Browse Source

babel: wrapping free language variable in result insertion code

* lisp/babel/ob.el (org-babel-execute-src-block): now passing
  additional optional argument to `org-babel-inert-results'

  (org-babel-insert-result): now accepting additional language
  variable
Eric Schulte 15 years ago
parent
commit
e0b71bf8e2
1 changed files with 7 additions and 9 deletions
  1. 7 9
      lisp/babel/ob.el

+ 7 - 9
lisp/babel/ob.el

@@ -275,7 +275,8 @@ block."
                                       (not (listp result)))
                                       (not (listp result)))
                                  (list (list result))
                                  (list (list result))
                                result)))
                                result)))
-            (org-babel-insert-result result result-params info new-hash indent)
+            (org-babel-insert-result
+	     result result-params info new-hash indent lang)
             (run-hooks 'org-babel-after-execute-hook)
             (run-hooks 'org-babel-after-execute-hook)
             result))
             result))
       (setq call-process-region 'call-process-region-original))))
       (setq call-process-region 'call-process-region-original))))
@@ -956,7 +957,8 @@ link is a file path it is expanded using `expand-file-name'."
            (expand-file-name (match-string 2 raw))))
            (expand-file-name (match-string 2 raw))))
      (t raw))))
      (t raw))))
 
 
-(defun org-babel-insert-result (result &optional result-params info hash indent)
+(defun org-babel-insert-result
+  (result &optional result-params info hash indent lang)
   "Insert RESULT into the current buffer after the end of the
   "Insert RESULT into the current buffer after the end of the
 current source block.  With optional argument RESULT-PARAMS
 current source block.  With optional argument RESULT-PARAMS
 controls insertion of results in the org-mode file.
 controls insertion of results in the org-mode file.
@@ -987,7 +989,8 @@ latex --- results are added inside of a #+BEGIN_LATEX block.
 code ---- the results are extracted in the syntax of the source
 code ---- the results are extracted in the syntax of the source
           code of the language being evaluated and are added
           code of the language being evaluated and are added
           inside of a #+BEGIN_SRC block with the source-code
           inside of a #+BEGIN_SRC block with the source-code
-          language set appropriately."
+          language set appropriately.  Note this relies on the
+          optional LANG argument."
   (if (stringp result)
   (if (stringp result)
       (progn
       (progn
         (setq result (org-babel-clean-text-properties result))
         (setq result (org-babel-clean-text-properties result))
@@ -1048,7 +1051,7 @@ code ---- the results are extracted in the syntax of the source
                             results-switches result)))
                             results-switches result)))
 	   ((member "code" result-params)
 	   ((member "code" result-params)
 	    (insert (format "#+BEGIN_SRC %s%s\n%s#+END_SRC\n"
 	    (insert (format "#+BEGIN_SRC %s%s\n%s#+END_SRC\n"
-                            lang results-switches result)))
+                            (or lang "none") results-switches result)))
 	   ((or (member "raw" result-params) (member "org" result-params))
 	   ((or (member "raw" result-params) (member "org" result-params))
 	    (save-excursion (insert result)) (if (org-at-table-p) (org-cycle)))
 	    (save-excursion (insert result)) (if (org-at-table-p) (org-cycle)))
 	   (t
 	   (t
@@ -1063,11 +1066,6 @@ code ---- the results are extracted in the syntax of the source
 	    (indent-rigidly beg end indent))))
 	    (indent-rigidly beg end indent))))
       (message "finished"))))
       (message "finished"))))
 
 
-(defun org-babel-result-to-org-string (result)
-  "Return RESULT as a string in org-mode format.  This function
-relies on `org-babel-insert-result'."
-  (with-temp-buffer (org-babel-insert-result result) (buffer-string)))
-
 (defun org-babel-remove-result (&optional info)
 (defun org-babel-remove-result (&optional info)
   "Remove the result of the current source block."
   "Remove the result of the current source block."
   (interactive)
   (interactive)