Browse Source

looks like out comint waiting function needs some work...

Eric Schulte 16 years ago
parent
commit
f5481ab666
1 changed files with 20 additions and 13 deletions
  1. 20 13
      lisp/org-babel-comint.el

+ 20 - 13
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