Function: org-babel-eval
org-babel-eval is a byte-compiled function defined in ob-eval.el.gz.
Signature
(org-babel-eval COMMAND QUERY)
Documentation
Run COMMAND on QUERY.
Return standard output produced by COMMAND. If COMMAND exits
with a non-zero code or produces error output, show it with
org-babel-eval-error-notify.
Writes QUERY into a temp-buffer that is processed with
org-babel--shell-command-on-region.
Source Code
;; Defined in /usr/src/emacs/lisp/org/ob-eval.el.gz
(defun org-babel-eval (command query)
"Run COMMAND on QUERY.
Return standard output produced by COMMAND. If COMMAND exits
with a non-zero code or produces error output, show it with
`org-babel-eval-error-notify'.
Writes QUERY into a temp-buffer that is processed with
`org-babel--shell-command-on-region'."
(let ((error-buffer (get-buffer-create " *Org-Babel Error*")) exit-code)
(with-current-buffer error-buffer (erase-buffer))
(with-temp-buffer
;; Ensure trailing newline. It is required for cmdproxy.exe.
(insert query "\n")
(setq exit-code
(org-babel--shell-command-on-region
command error-buffer))
(let ((stderr (with-current-buffer error-buffer (buffer-string))))
(if (or (not (numberp exit-code))
(> exit-code 0)
(not (string-empty-p stderr)))
(progn
(org-babel-eval-error-notify exit-code stderr)
(save-excursion
(when (get-buffer org-babel-error-buffer-name)
(with-current-buffer org-babel-error-buffer-name
(unless (derived-mode-p 'compilation-mode)
(compilation-mode))
;; Compilation-mode enforces read-only, but
;; Babel expects the buffer modifiable.
(setq buffer-read-only nil))))
;; Return output, if any.
(buffer-string))
(buffer-string))))))