Browse Source

ob-ruby: xmpfilter result type for outputting annotated source code

  Thanks to Avdi Grimm for suggesting this addition

* lisp/ob-ruby.el (xmp): Declaring this function to appease the
  compiler.
  (org-babel-execute:ruby): "xmp" result option for outputting
  annotated source code.
Eric Schulte 9 years ago
parent
commit
3f90f26336
1 changed files with 9 additions and 2 deletions
  1. 9 2
      lisp/ob-ruby.el

+ 9 - 2
lisp/ob-ruby.el

@@ -44,6 +44,7 @@
 (eval-when-compile (require 'cl))
 
 (declare-function run-ruby "ext:inf-ruby" (&optional command name))
+(declare-function xmp "ext:rcodetools" (&optional option))
 
 (add-to-list 'org-babel-tangle-lang-exts '("ruby" . "rb"))
 
@@ -61,8 +62,14 @@ This function is called by `org-babel-execute-src-block'."
          (result-type (cdr (assoc :result-type params)))
          (full-body (org-babel-expand-body:generic
 		     body params (org-babel-variable-assignments:ruby params)))
-         (result (org-babel-ruby-evaluate
-		  session full-body result-type result-params)))
+         (result (if (member "xmp" result-params)
+		     (with-temp-buffer
+		     (require 'rcodetools)
+		     (insert full-body)
+		     (xmp (cdr (assoc :xmp-option params)))
+		     (buffer-string))
+		   (org-babel-ruby-evaluate
+		      session full-body result-type result-params))))
     (org-babel-reassemble-table
      result
      (org-babel-pick-name (cdr (assoc :colname-names params))