[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 1ef420b19d 1/3: org-babel-comint-with-output: Handl
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 1ef420b19d 1/3: org-babel-comint-with-output: Handle output without trailing newlines |
Date: |
Sun, 23 Oct 2022 00:58:16 -0400 (EDT) |
branch: externals/org
commit 1ef420b19d2e310d9ef67e090ef84cdb6da4744d
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
org-babel-comint-with-output: Handle output without trailing newlines
* lisp/ob-comint.el (org-babel-comint-with-output): Consider scenarios
when comint emits output without trailing newlines. The strategy to
split the full concatenated output using `comint-prompt-regexp' does
not work when the regexp matches bol. Use a constant string as a
separator instead of relying upon `comint-prompt-regexp'.
Reported-by: Rudolf Adamkovič <salutis@me.com>
Link: https://orgmode.org/list/m2czakgpk8.fsf@me.com
---
lisp/ob-comint.el | 23 ++++++++++++++++++++---
1 file changed, 20 insertions(+), 3 deletions(-)
diff --git a/lisp/ob-comint.el b/lisp/ob-comint.el
index ec7d3f6c96..e8d8367076 100644
--- a/lisp/ob-comint.el
+++ b/lisp/ob-comint.el
@@ -74,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
@@ -109,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))))
- (delete "" (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.