mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2025-01-10 15:56:42 +00:00
babel: clean compile
This commit is contained in:
parent
9be0990ae1
commit
3416a0e323
15
lisp/ob-C.el
15
lisp/ob-C.el
@ -32,6 +32,7 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-eval)
|
||||
(require 'org)
|
||||
(require 'cc-mode)
|
||||
|
||||
@ -113,14 +114,12 @@ or `org-babel-execute:c++'."
|
||||
(org-babel-reassemble-table
|
||||
(org-babel-read
|
||||
(org-babel-trim
|
||||
(with-temp-buffer
|
||||
(org-babel-shell-command-on-region
|
||||
(point-min) (point-max)
|
||||
(concat tmp-bin-file (if cmdline (concat " " cmdline) ""))
|
||||
(current-buffer) 'replace)
|
||||
(buffer-string))))
|
||||
(org-babel-pick-name (nth 4 processed-params) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name (nth 5 processed-params) (cdr (assoc :rownames params))))
|
||||
(org-babel-eval
|
||||
(concat tmp-bin-file (if cmdline (concat " " cmdline) "")) "")))
|
||||
(org-babel-pick-name
|
||||
(nth 4 processed-params) (cdr (assoc :colnames params)))
|
||||
(org-babel-pick-name
|
||||
(nth 5 processed-params) (cdr (assoc :rownames params))))
|
||||
(progn
|
||||
(with-current-buffer error-buf
|
||||
(goto-char (point-max))
|
||||
|
@ -29,13 +29,10 @@
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-ref)
|
||||
(require 'ob-comint)
|
||||
(require 'ob-eval)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function org-babel-comint-in-buffer "ob-comint" (buffer &rest body))
|
||||
(declare-function comint-send-input "ob-comint" (el'.))
|
||||
(declare-function org-babel-comint-wait-for-output "ob-comint" (buffer))
|
||||
(declare-function org-babel-comint-buffer-livep "ob-comint" (buffer))
|
||||
(declare-function org-babel-comint-with-output "ob-comint" (meta &rest body))
|
||||
(declare-function orgtbl-to-tsv "ob-table" (table params))
|
||||
(declare-function R "ext:essd-r" (&optional start-args))
|
||||
(declare-function inferior-ess-send-input "ext:ess-inf" ())
|
||||
|
@ -39,8 +39,8 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
(require 'ob-eval)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function slime-eval-async "ext:slime" (sexp &optional cont package))
|
||||
(declare-function slime-eval "ext:slime" (sexp &optional package))
|
||||
|
@ -249,7 +249,7 @@ specifies the value of ERROR-BUFFER."
|
||||
(delete-file error-file))
|
||||
exit-status))
|
||||
|
||||
(provide 'ob-run)
|
||||
(provide 'ob-eval)
|
||||
|
||||
;; arch-tag: 5328b17f-957d-42d9-94da-a2952682d04d
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-eval)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(add-to-list 'org-babel-tangle-lang-exts '("perl" . "pl"))
|
||||
@ -108,7 +109,7 @@ last statement in BODY, as elisp."
|
||||
(output (org-babel-eval org-babel-perl-command body))
|
||||
(value (let ((tmp-file (make-temp-file "org-babel-perl-results-")))
|
||||
(org-babel-eval
|
||||
org-babel-python-command
|
||||
org-babel-perl-command
|
||||
(format org-babel-perl-wrapper-method body tmp-file))
|
||||
(org-babel-eval-read-file tmp-file)))))
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
(require 'ob)
|
||||
(require 'ob-ref)
|
||||
(require 'ob-comint)
|
||||
(require 'ob-run)
|
||||
(require 'ob-eval)
|
||||
(require (if (featurep 'xemacs) 'python-mode 'python))
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
|
@ -40,8 +40,8 @@
|
||||
(require 'ob)
|
||||
(require 'ob-ref)
|
||||
(require 'ob-comint)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
(require 'ob-eval)
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function run-ruby "ext:inf-ruby" (&optional command name))
|
||||
|
||||
@ -207,7 +207,7 @@ last statement in BODY, as elisp."
|
||||
#'org-babel-trim
|
||||
(butlast
|
||||
(org-babel-comint-with-output
|
||||
(buffer org-babel-ruby-eoe-indicator t full-body)
|
||||
(buffer org-babel-ruby-eoe-indicator t body)
|
||||
(mapc
|
||||
(lambda (line)
|
||||
(insert (org-babel-chomp line)) (comint-send-input nil t))
|
||||
|
@ -29,9 +29,9 @@
|
||||
;;; Code:
|
||||
(require 'ob)
|
||||
(require 'ob-comint)
|
||||
(require 'ob-eval)
|
||||
(require 'shell)
|
||||
(eval-when-compile
|
||||
(require 'cl))
|
||||
(eval-when-compile (require 'cl))
|
||||
|
||||
(declare-function org-babel-ref-variables "ob-ref" (params))
|
||||
(declare-function org-babel-comint-in-buffer "ob-comint" (buffer &rest body))
|
||||
@ -143,52 +143,30 @@ Emacs-lisp table, otherwise return the results as a string."
|
||||
'output then return a list of the outputs of the statements in
|
||||
BODY, if RESULT-TYPE equals 'value then return the value of the
|
||||
last statement in BODY."
|
||||
(if (not session)
|
||||
;; external process evaluation
|
||||
(save-window-excursion
|
||||
(with-temp-buffer
|
||||
(insert body)
|
||||
;; (message "buffer=%s" (buffer-string)) ;; debugging
|
||||
(org-babel-shell-command-on-region (point-min) (point-max) org-babel-sh-command 'current-buffer 'replace)
|
||||
(cond
|
||||
((member "output" result-params) (buffer-string))
|
||||
;; TODO: figure out how to return non-output values from shell scripts
|
||||
(t ;; if not "output" then treat as "value"
|
||||
(if (member "scalar" result-params)
|
||||
(buffer-string)
|
||||
(let ((tmp-file (make-temp-file "org-babel-sh"))
|
||||
(results (buffer-string)))
|
||||
(with-temp-file tmp-file (insert results))
|
||||
(org-babel-import-elisp-from-file tmp-file)))))))
|
||||
;; comint session evaluation
|
||||
(flet ((strip-empty (lst)
|
||||
(delq nil (mapcar (lambda (el) (unless (= (length el) 0) el)) lst))))
|
||||
(let ((tmp-file (make-temp-file "org-babel-sh"))
|
||||
(results
|
||||
(cdr (member
|
||||
org-babel-sh-eoe-output
|
||||
(strip-empty
|
||||
(reverse
|
||||
(mapcar #'org-babel-sh-strip-weird-long-prompt
|
||||
(mapcar #'org-babel-trim
|
||||
(org-babel-comint-with-output
|
||||
(session org-babel-sh-eoe-output t body)
|
||||
(mapc (lambda (line) (insert line) (comint-send-input))
|
||||
(strip-empty (split-string body "\n")))
|
||||
(insert org-babel-sh-eoe-indicator)
|
||||
(comint-send-input))))))))))
|
||||
;; (message (replace-regexp-in-string
|
||||
;; "%" "%%" (format "processed-results=%S" results))) ;; debugging
|
||||
(or (and results
|
||||
(cond
|
||||
((member "output" result-params)
|
||||
(org-babel-trim (mapconcat #'org-babel-trim
|
||||
(reverse results) "\n")))
|
||||
(t ;; if not "output" then treat as "value"
|
||||
(with-temp-file tmp-file
|
||||
(insert (car results)) (insert "\n"))
|
||||
(org-babel-import-elisp-from-file tmp-file))))
|
||||
"")))))
|
||||
((lambda (results)
|
||||
(if (or (member "scalar" result-params)
|
||||
(member "output" result-params))
|
||||
(buffer-string)
|
||||
(let ((tmp-file (make-temp-file "org-babel-sh")))
|
||||
(with-temp-file tmp-file (insert results))
|
||||
(org-babel-import-elisp-from-file tmp-file))))
|
||||
(if (not session)
|
||||
(org-babel-eval org-babel-sh-command (org-babel-trim body))
|
||||
(let ((tmp-file (make-temp-file "org-babel-sh")))
|
||||
(mapconcat
|
||||
#'org-babel-sh-strip-weird-long-prompt
|
||||
(mapcar
|
||||
#'org-babel-trim
|
||||
(butlast
|
||||
(org-babel-comint-with-output
|
||||
(session org-babel-sh-eoe-output t body)
|
||||
(mapc
|
||||
(lambda (line)
|
||||
(insert line) (comint-send-input nil t) (sleep-for 0.25))
|
||||
(append
|
||||
(split-string (org-babel-trim body) "\n")
|
||||
(list org-babel-sh-eoe-indicator))))
|
||||
2)) "\n")))))
|
||||
|
||||
(defun org-babel-sh-strip-weird-long-prompt (string)
|
||||
"Remove prompt cruft from a string of shell output."
|
||||
|
Loading…
Reference in New Issue
Block a user