org-babel: file output for ruby and python
With this change, if :file <filepath> is specified, ruby and python blindly output a link to <filepath>. Responsibility for creating the contents in <filepath> lies with the python/ruby code.
This commit is contained in:
parent
210f85ce49
commit
6875d4d8e3
|
@ -40,15 +40,16 @@
|
|||
"Execute a block of Python code with org-babel. This function is
|
||||
called by `org-babel-execute-src-block' via multiple-value-bind."
|
||||
(message "executing Python source code block")
|
||||
(let ((full-body (concat
|
||||
(let* ((full-body (concat
|
||||
(mapconcat ;; define any variables
|
||||
(lambda (pair)
|
||||
(format "%s=%s"
|
||||
(car pair)
|
||||
(org-babel-python-var-to-python (cdr pair))))
|
||||
vars "\n") "\n" (org-babel-trim body) "\n")) ;; then the source block body
|
||||
(session (org-babel-python-initiate-session session)))
|
||||
(org-babel-python-evaluate session full-body result-type)))
|
||||
(session (org-babel-python-initiate-session session))
|
||||
(result (org-babel-python-evaluate session full-body result-type)))
|
||||
(or (cdr (assoc :file params)) result)))
|
||||
|
||||
(defun org-babel-prep-session:python (session params)
|
||||
"Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
|
|
|
@ -50,15 +50,16 @@
|
|||
"Execute a block of Ruby code with org-babel. This function is
|
||||
called by `org-babel-execute-src-block' via multiple-value-bind."
|
||||
(message "executing Ruby source code block")
|
||||
(let ((full-body (concat
|
||||
(let* ((full-body (concat
|
||||
(mapconcat ;; define any variables
|
||||
(lambda (pair)
|
||||
(format "%s=%s"
|
||||
(car pair)
|
||||
(org-babel-ruby-var-to-ruby (cdr pair))))
|
||||
vars "\n") "\n" body "\n")) ;; then the source block body
|
||||
(session (org-babel-ruby-initiate-session session)))
|
||||
(org-babel-ruby-evaluate session full-body result-type)))
|
||||
(session (org-babel-ruby-initiate-session session))
|
||||
(result (org-babel-ruby-evaluate session full-body result-type)))
|
||||
(or (cdr (assoc :file params)) result)))
|
||||
|
||||
(defun org-babel-prep-session:ruby (session params)
|
||||
"Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
|
|
Loading…
Reference in New Issue