summaryrefslogtreecommitdiff
path: root/lisp/org/ob-comint.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/org/ob-comint.el')
-rw-r--r--lisp/org/ob-comint.el33
1 files changed, 26 insertions, 7 deletions
diff --git a/lisp/org/ob-comint.el b/lisp/org/ob-comint.el
index c99d6a8ba71..e8d83670767 100644
--- a/lisp/org/ob-comint.el
+++ b/lisp/org/ob-comint.el
@@ -4,7 +4,7 @@
;; Author: Eric Schulte
;; Keywords: literate programming, reproducible research, comint
-;; Homepage: https://orgmode.org
+;; URL: https://orgmode.org
;; This file is part of GNU Emacs.
@@ -30,6 +30,10 @@
;; org-babel at large.
;;; Code:
+
+(require 'org-macs)
+(org-assert-version)
+
(require 'ob-core)
(require 'org-compat)
(require 'comint)
@@ -70,11 +74,26 @@ or user `keyboard-quit' during execution of body."
(let ((buffer (nth 0 meta))
(eoe-indicator (nth 1 meta))
(remove-echo (nth 2 meta))
- (full-body (nth 3 meta)))
+ (full-body (nth 3 meta))
+ (org-babel-comint-prompt-separator
+ "org-babel-comint-prompt-separator"))
`(org-babel-comint-in-buffer ,buffer
(let* ((string-buffer "")
(comint-output-filter-functions
- (cons (lambda (text) (setq string-buffer (concat string-buffer text)))
+ (cons (lambda (text)
+ (setq string-buffer
+ (concat
+ string-buffer
+ ;; Upon concatenation, the prompt may no
+ ;; longer match `comint-prompt-regexp'.
+ ;; In particular, when the regexp has ^
+ ;; and the output does not contain
+ ;; trailing newline. Use more reliable
+ ;; match to split the output later.
+ (replace-regexp-in-string
+ comint-prompt-regexp
+ ,org-babel-comint-prompt-separator
+ text))))
comint-output-filter-functions))
dangling-text)
;; got located, and save dangling text
@@ -105,7 +124,9 @@ or user `keyboard-quit' during execution of body."
"\n" "[\r\n]+" (regexp-quote (or ,full-body "")))
string-buffer))
(setq string-buffer (substring string-buffer (match-end 0))))
- (split-string string-buffer comint-prompt-regexp)))))
+ (delete "" (split-string
+ string-buffer
+ ,org-babel-comint-prompt-separator))))))
(defun org-babel-comint-input-command (buffer cmd)
"Pass CMD to BUFFER.
@@ -124,9 +145,7 @@ statement (not large blocks of code)."
(while (progn
(goto-char comint-last-input-end)
(not (and (re-search-forward comint-prompt-regexp nil t)
- (goto-char (match-beginning 0))
- (string= (face-name (face-at-point))
- "comint-highlight-prompt"))))
+ (goto-char (match-beginning 0)))))
(accept-process-output (get-buffer-process buffer)))))
(defun org-babel-comint-eval-invisibly-and-wait-for-file