summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Schulte <schulte.eric@gmail.com>2010-07-04 14:46:13 -0700
committerEric Schulte <schulte.eric@gmail.com>2010-07-05 11:14:51 -0700
commit3416a0e32366951d789b55dda1248757577acbce (patch)
treed89403d4f670bcba2d748b78677c358b9331be2e
parent9be0990ae118034dc839d234806d0bdf0a71effc (diff)
downloadorg-mode-3416a0e32366951d789b55dda1248757577acbce.tar.gz
babel: clean compile
-rw-r--r--lisp/ob-C.el15
-rw-r--r--lisp/ob-R.el7
-rw-r--r--lisp/ob-clojure.el4
-rw-r--r--lisp/ob-eval.el2
-rw-r--r--lisp/ob-perl.el3
-rw-r--r--lisp/ob-python.el2
-rw-r--r--lisp/ob-ruby.el6
-rw-r--r--lisp/ob-sh.el74
8 files changed, 44 insertions, 69 deletions
diff --git a/lisp/ob-C.el b/lisp/ob-C.el
index 49e8277..50527c3 100644
--- a/lisp/ob-C.el
+++ b/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))
diff --git a/lisp/ob-R.el b/lisp/ob-R.el
index 325ad4d..255e153 100644
--- a/lisp/ob-R.el
+++ b/lisp/ob-R.el
@@ -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" ())
diff --git a/lisp/ob-clojure.el b/lisp/ob-clojure.el
index 309e854..814803a 100644
--- a/lisp/ob-clojure.el
+++ b/lisp/ob-clojure.el
@@ -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))
diff --git a/lisp/ob-eval.el b/lisp/ob-eval.el
index 23b93a8..e5af294 100644
--- a/lisp/ob-eval.el
+++ b/lisp/ob-eval.el
@@ -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
diff --git a/lisp/ob-perl.el b/lisp/ob-perl.el
index d9fe51f..a8d4a8e 100644
--- a/lisp/ob-perl.el
+++ b/lisp/ob-perl.el
@@ -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)))))
diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index 3a5fc2a..b27ee05 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -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))
diff --git a/lisp/ob-ruby.el b/lisp/ob-ruby.el
index 7d08e04..5f06d4c 100644
--- a/lisp/ob-ruby.el
+++ b/lisp/ob-ruby.el
@@ -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))
diff --git a/lisp/ob-sh.el b/lisp/ob-sh.el
index 986cbc6..7c1d7cb 100644
--- a/lisp/ob-sh.el
+++ b/lisp/ob-sh.el
@@ -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."