|
|
@@ -97,39 +97,19 @@ then create. Return the initialized session."
|
|
|
'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."
|
|
|
- (org-babel-comint-in-buffer buffer
|
|
|
- (let ((string-buffer "")
|
|
|
- (full-body (mapconcat #'org-babel-chomp
|
|
|
- (list body org-babel-ruby-last-value-eval org-babel-ruby-eoe-indicator) "\n"))
|
|
|
- results)
|
|
|
- (flet ((my-filt (text) (setq string-buffer (concat string-buffer text))))
|
|
|
- ;; setup filter
|
|
|
- (add-hook 'comint-output-filter-functions 'my-filt)
|
|
|
- ;; pass FULL-BODY to process
|
|
|
- (goto-char (process-mark (get-buffer-process buffer)))
|
|
|
- (insert full-body)
|
|
|
- (comint-send-input)
|
|
|
- ;; wait for end-of-evaluation indicator
|
|
|
- (while (progn
|
|
|
- (goto-char comint-last-input-end)
|
|
|
- (not (save-excursion (and (re-search-forward comint-prompt-regexp nil t)
|
|
|
- (re-search-forward (regexp-quote org-babel-ruby-eoe-indicator) nil t)))))
|
|
|
- (accept-process-output (get-buffer-process buffer)))
|
|
|
- ;; remove filter
|
|
|
- (remove-hook 'comint-output-filter-functions 'my-filt))
|
|
|
- ;; remove echo'd FULL-BODY from input
|
|
|
- (if (string-match (replace-regexp-in-string "\n" "\r\n" (regexp-quote full-body)) string-buffer)
|
|
|
- (setq string-buffer (substring string-buffer (match-end 0))))
|
|
|
- ;; split results with `comint-prompt-regexp'
|
|
|
- (setq results (cdr (member org-babel-ruby-eoe-indicator
|
|
|
- (reverse (mapcar #'org-babel-ruby-read-string
|
|
|
- (mapcar #'org-babel-trim
|
|
|
- (split-string string-buffer comint-prompt-regexp)))))))
|
|
|
- (message "near-final=%S" results)
|
|
|
- (case result-type
|
|
|
- (output (mapconcat #'identity (reverse (cdr results)) "\n"))
|
|
|
- (value (car results))
|
|
|
- (t (reverse results))))))
|
|
|
+ (let* ((full-body (mapconcat #'org-babel-chomp
|
|
|
+ (list body org-babel-ruby-last-value-eval org-babel-ruby-eoe-indicator) "\n"))
|
|
|
+ (raw (org-babel-comint-with-output buffer org-babel-ruby-eoe-indicator t
|
|
|
+ (insert full-body) (comint-send-input)))
|
|
|
+ results)
|
|
|
+ ;; split results with `comint-prompt-regexp'
|
|
|
+ (setq results (cdr (member org-babel-ruby-eoe-indicator
|
|
|
+ (reverse (mapcar #'org-babel-ruby-read-string
|
|
|
+ (mapcar #'org-babel-trim raw))))))
|
|
|
+ (case result-type
|
|
|
+ (output (mapconcat #'identity (reverse (cdr results)) "\n"))
|
|
|
+ (value (car results))
|
|
|
+ (t (reverse results)))))
|
|
|
|
|
|
(defun org-babel-ruby-read-string (string)
|
|
|
"Strip \\\"s from around ruby string"
|