mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-11-21 06:55:35 +00:00
ob: language-specific changes in response to :file arg changes
These languages are capable of writing results to file; for several of them this is their only mode of operation. These changes cause the languages to return to ob.el either the computed result, or nil, when they have written results to file themselves. This is in place of the previous method of returning the output file name as a string to ob.el. * lisp/ob-asymptote.el (org-babel-execute:asymptote): Return nil to signal that the intended content has been written to file. * lisp/ob-ditaa.el (org-babel-execute:ditaa): Return nil to signal that the intended content has been written to file. * lisp/ob-dot.el (org-babel-execute:dot): Return nil to signal that the intended content has been written to file. * lisp/ob-gnuplot.el (org-babel-execute:gnuplot): Return nil to signal that the intended content has been written to file. * lisp/ob-latex.el (org-babel-execute:latex): Return nil to signal that the intended content has been written to file. * lisp/ob-mscgen.el (org-babel-execute:mscgen): Return nil to signal that the intended content has been written to file. * lisp/ob-octave.el (org-babel-execute:octave): Return result; not name of output file. * lisp/ob-plantuml.el (org-babel-execute:plantuml): Return nil to signal that the intended content has been written to file. * lisp/ob-python.el (org-babel-execute:python): Return result; not name of output file. * lisp/ob-ruby.el (org-babel-execute:ruby): Return result; not name of output file. * lisp/ob-sass.el (org-babel-execute:sass): Return nil if result has been written to file
This commit is contained in:
parent
6bcbdce949
commit
e030d95ddb
@ -80,7 +80,7 @@ This function is called by `org-babel-execute-src-block'."
|
||||
body params
|
||||
(org-babel-variable-assignments:asymptote params))))
|
||||
(message cmd) (shell-command cmd)
|
||||
out-file))
|
||||
nil)) ;; signal that output has already been written to file
|
||||
|
||||
(defun org-babel-prep-session:asymptote (session params)
|
||||
"Return an error if the :session header argument is set.
|
||||
|
@ -61,7 +61,7 @@ This function is called by `org-babel-execute-src-block'."
|
||||
(error "Could not find ditaa.jar at %s" org-ditaa-jar-path))
|
||||
(with-temp-file in-file (insert body))
|
||||
(message cmd) (shell-command cmd)
|
||||
out-file))
|
||||
nil)) ;; signal that output has already been written to file
|
||||
|
||||
(defun org-babel-prep-session:ditaa (session params)
|
||||
"Return an error because ditaa does not support sessions."
|
||||
|
@ -77,7 +77,7 @@ This function is called by `org-babel-execute-src-block'."
|
||||
" " (org-babel-process-file-name in-file)
|
||||
" " cmdline
|
||||
" -o " (org-babel-process-file-name out-file)) "")
|
||||
out-file))
|
||||
nil)) ;; signal that output has already been written to file
|
||||
|
||||
(defun org-babel-prep-session:dot (session params)
|
||||
"Return an error because Dot does not support sessions."
|
||||
|
@ -157,7 +157,7 @@ This function is called by `org-babel-execute-src-block'."
|
||||
(gnuplot-send-buffer-to-gnuplot)))
|
||||
(if (member "output" (split-string result-type))
|
||||
output
|
||||
out-file))))
|
||||
nil)))) ;; signal that output has already been written to file
|
||||
|
||||
(defun org-babel-prep-session:gnuplot (session params)
|
||||
"Prepare SESSION according to the header arguments in PARAMS."
|
||||
|
@ -122,7 +122,7 @@ This function is called by `org-babel-execute-src-block'."
|
||||
((string-match "\\.\\([^\\.]+\\)$" out-file)
|
||||
(error "can not create %s files, please specify a .png or .pdf file"
|
||||
(match-string 1 out-file))))
|
||||
out-file)
|
||||
nil) ;; signal that output has already been written to file
|
||||
body))
|
||||
|
||||
(defun org-babel-latex-tex-to-pdf (file)
|
||||
|
@ -73,7 +73,7 @@ mscgen supported formats."
|
||||
(error "
|
||||
ERROR: no output file specified. Add \":file name.png\" to the src header"))
|
||||
(org-babel-eval (concat "mscgen -T " filetype " -o " out-file) body)
|
||||
out-file))
|
||||
nil)) ;; signal that output has already been written to file
|
||||
|
||||
(defun org-babel-prep-session:mscgen (session params)
|
||||
"Raise an error because Mscgen doesn't support sessions."
|
||||
|
@ -88,13 +88,12 @@ end")
|
||||
body params (org-babel-variable-assignments:octave params)))
|
||||
(result (org-babel-octave-evaluate
|
||||
session full-body result-type matlabp)))
|
||||
(or out-file
|
||||
(org-babel-reassemble-table
|
||||
result
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :rowname-names params)) (cdr (assoc :rownames params)))))))
|
||||
(org-babel-reassemble-table
|
||||
result
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :colname-names params)) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name
|
||||
(cdr (assoc :rowname-names params)) (cdr (assoc :rownames params))))))
|
||||
|
||||
(defun org-babel-prep-session:matlab (session params)
|
||||
"Prepare SESSION according to PARAMS."
|
||||
|
@ -70,7 +70,7 @@ This function is called by `org-babel-execute-src-block'."
|
||||
(error "Could not find plantuml.jar at %s" org-plantuml-jar-path))
|
||||
(with-temp-file in-file (insert (concat "@startuml\n" body "\n@enduml")))
|
||||
(message "%s" cmd) (org-babel-eval cmd "")
|
||||
out-file))
|
||||
nil)) ;; signal that output has already been written to file
|
||||
|
||||
(defun org-babel-prep-session:plantuml (session params)
|
||||
"Return an error because plantuml does not support sessions."
|
||||
|
@ -66,13 +66,12 @@ This function is called by `org-babel-execute-src-block'."
|
||||
params (org-babel-variable-assignments:python params)))
|
||||
(result (org-babel-python-evaluate
|
||||
session full-body result-type result-params preamble)))
|
||||
(or (cdr (assoc :file params))
|
||||
(org-babel-reassemble-table
|
||||
result
|
||||
(org-babel-pick-name (cdr (assoc :colname-names params))
|
||||
(cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name (cdr (assoc :rowname-names params))
|
||||
(cdr (assoc :rownames params)))))))
|
||||
(org-babel-reassemble-table
|
||||
result
|
||||
(org-babel-pick-name (cdr (assoc :colname-names params))
|
||||
(cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name (cdr (assoc :rowname-names params))
|
||||
(cdr (assoc :rownames params))))))
|
||||
|
||||
(defun org-babel-prep-session:python (session params)
|
||||
"Prepare SESSION according to the header arguments in PARAMS.
|
||||
|
@ -63,13 +63,12 @@ This function is called by `org-babel-execute-src-block'."
|
||||
body params (org-babel-variable-assignments:ruby params)))
|
||||
(result (org-babel-ruby-evaluate
|
||||
session full-body result-type result-params)))
|
||||
(or (cdr (assoc :file params))
|
||||
(org-babel-reassemble-table
|
||||
result
|
||||
(org-babel-pick-name (cdr (assoc :colname-names params))
|
||||
(cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name (cdr (assoc :rowname-names params))
|
||||
(cdr (assoc :rownames params)))))))
|
||||
(org-babel-reassemble-table
|
||||
result
|
||||
(org-babel-pick-name (cdr (assoc :colname-names params))
|
||||
(cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name (cdr (assoc :rowname-names params))
|
||||
(cdr (assoc :rownames params))))))
|
||||
|
||||
(defun org-babel-prep-session:ruby (session params)
|
||||
"Prepare SESSION according to the header arguments specified in PARAMS."
|
||||
|
@ -56,7 +56,9 @@ This function is called by `org-babel-execute-src-block'."
|
||||
" " (org-babel-process-file-name out-file))))
|
||||
(with-temp-file in-file
|
||||
(insert (org-babel-expand-body:generic body params))) (shell-command cmd)
|
||||
(or file (with-temp-buffer (insert-file-contents out-file) (buffer-string)))))
|
||||
(if file
|
||||
nil ;; signal that output has already been written to file
|
||||
(with-temp-buffer (insert-file-contents out-file) (buffer-string)))))
|
||||
|
||||
(defun org-babel-prep-session:sass (session params)
|
||||
"Raise an error because sass does not support sessions."
|
||||
|
Loading…
Reference in New Issue
Block a user