Browse Source

babel: adding org-babel-expand-body:generic for languages w/o body expansion support

Eric Schulte 15 years ago
parent
commit
03f13106fb
1 changed files with 8 additions and 1 deletions
  1. 8 1
      contrib/babel/lisp/org-babel.el

+ 8 - 1
contrib/babel/lisp/org-babel.el

@@ -262,6 +262,12 @@ block."
             result))
             result))
       (setq call-process-region 'call-process-region-original))))
       (setq call-process-region 'call-process-region-original))))
 
 
+(defun org-babel-expand-body:generic (body params &optional processed-params)
+  "Expand a block of code with org-babel according to it's header
+arguments.  This generic implementation of body expansion is
+called for languages which have not defined their own specific
+org-babel-expand-body:lang function." body)
+
 (defun org-babel-expand-src-block (&optional arg info params)
 (defun org-babel-expand-src-block (&optional arg info params)
   "Expand the current source code block according to it's header
   "Expand the current source code block according to it's header
 arguments, and pop open the results in a preview buffer."
 arguments, and pop open the results in a preview buffer."
@@ -278,7 +284,8 @@ arguments, and pop open the results in a preview buffer."
                               (string= "yes" (cdr (assoc :noweb params))))
                               (string= "yes" (cdr (assoc :noweb params))))
 			 (org-babel-expand-noweb-references info) (second info))))
 			 (org-babel-expand-noweb-references info) (second info))))
          (cmd (intern (concat "org-babel-expand-body:" lang)))
          (cmd (intern (concat "org-babel-expand-body:" lang)))
-         (expanded (funcall cmd body params))
+         (expanded (funcall (if (fboundp cmd) cmd 'org-babel-expand-body:generic)
+                            body params))
          (buf (get-buffer-create "*Org-Babel Code Body Preview*")))
          (buf (get-buffer-create "*Org-Babel Code Body Preview*")))
     (with-current-buffer buf
     (with-current-buffer buf
       (erase-buffer)
       (erase-buffer)