From f5481ab666a4aad58435ba4005ade2865f714cc1 Mon Sep 17 00:00:00 2001 From: Eric Schulte Date: Thu, 11 Jun 2009 12:35:48 -0700 Subject: [PATCH] looks like out comint waiting function needs some work... --- lisp/org-babel-comint.el | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/lisp/org-babel-comint.el b/lisp/org-babel-comint.el index d46d3cf41..68a3acfb1 100644 --- a/lisp/org-babel-comint.el +++ b/lisp/org-babel-comint.el @@ -61,13 +61,19 @@ body inside the protection of `save-window-excursion' and (remove-hook 'comint-output-filter-functions ',my-filter)) string-buffer))) -(defun org-babel-comint-wait-for-output (buffer) - "Wait until output arrives" - (org-babel-comint-in-buffer buffer - (while (progn - (goto-char comint-last-input-end) - (not (re-search-forward comint-prompt-regexp nil t))) - (accept-process-output (get-buffer-process buffer))))) +(defun org-babel-comint-command-to-output (buffer cmd) + "Pass CMD to BUFFER using `org-babel-comint-input-command', and +then return the a list of the output(s) generated by CMD." + (let ((raw (org-babel-comint-with-output + (org-babel-comint-input-command buffer cmd)))) + (mapcar #'org-babel-chomp + ;; split the output along prompts + (split-string + ;; remove CMD if it is at the front of the output + (if (string= cmd (substring raw 0 (length cmd))) + (substring raw (length cmd)) + raw) + comint-prompt-regexp)))) (defun org-babel-comint-input-command (buffer cmd) "Pass CMD to BUFFER The input will not be echoed." @@ -77,12 +83,13 @@ body inside the protection of `save-window-excursion' and (comint-send-input) (org-babel-comint-wait-for-output buffer))) -(defun org-babel-comint-command-to-output (buffer cmd) - "Pass CMD to BUFFER using `org-babel-comint-input-command', and -then return the result as a string using -`org-babel-comint-last-value'." - (org-babel-comint-input-command buffer cmd) - (org-babel-comint-last-value buffer)) +(defun org-babel-comint-wait-for-output (buffer) + "Wait until output arrives" + (org-babel-comint-in-buffer buffer + (while (progn + (goto-char comint-last-input-end) + (not (re-search-forward comint-prompt-regexp nil t))) + (accept-process-output (get-buffer-process buffer))))) (defun org-babel-comint-command-to-last (buffer cmd) "Pass CMD to BUFFER using `org-babel-comint-input-command', and