[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/org 574e04d119 5/7: lisp/ob-comint.el: Refactor `org-ba
From: |
ELPA Syncer |
Subject: |
[elpa] externals/org 574e04d119 5/7: lisp/ob-comint.el: Refactor `org-babel-comint-with-output' |
Date: |
Fri, 29 Mar 2024 09:58:25 -0400 (EDT) |
branch: externals/org
commit 574e04d11992b2850d55b82a5e4af4fad35a6fc6
Author: Matthew Trzcinski <matt@excalamus.com>
Commit: Matthew Trzcinski <matt@excalamus.com>
lisp/ob-comint.el: Refactor `org-babel-comint-with-output'
* lisp/ob-comint.el (org-babel-comint-with-output): Replace logic for
prompt and echo filtering with `org-babel-comint--prompt-filter' and
`org-babel-comint--echo-filter'. Delete
`org-babel-comint-prompt-separator' variable and move related comment
to `org-babel-comint--prompt-filter'.
---
lisp/ob-comint.el | 39 +++++++++------------------------------
1 file changed, 9 insertions(+), 30 deletions(-)
diff --git a/lisp/ob-comint.el b/lisp/ob-comint.el
index e8d8e76094..d13aacccc1 100644
--- a/lisp/ob-comint.el
+++ b/lisp/ob-comint.el
@@ -79,6 +79,9 @@ This is useful when prompt unexpectedly changes."
PROMPT-REGEXP defaults to `comint-prompt-regexp'."
(let* ((prompt-regexp (or prompt-regexp comint-prompt-regexp))
+ ;; We need newline in case if we do progressive replacement
+ ;; of agglomerated comint prompts with `comint-prompt-regexp'
+ ;; containing ^.
(separator "org-babel-comint--prompt-filter-separator\n"))
(while (string-match-p prompt-regexp string)
(setq string
@@ -112,12 +115,7 @@ 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))
- (org-babel-comint-prompt-separator
- ;; We need newline in case if we do progressive replacement
- ;; of agglomerated comint prompts with `comint-prompt-regexp'
- ;; containing ^.
- "org-babel-comint-prompt-separator\n"))
+ (full-body (nth 3 meta)))
`(org-babel-comint-in-buffer ,buffer
(let* ((string-buffer "")
(comint-output-filter-functions
@@ -161,31 +159,12 @@ or user `keyboard-quit' during execution of body."
(goto-char (process-mark (get-buffer-process (current-buffer))))
(insert dangling-text)
+ ;; remove echo'd FULL-BODY from input
+ (and ,remove-echo ,full-body
+ (setq string-buffer (org-babel-comint--echo-filter string-buffer
,full-body)))
+
;; Filter out prompts.
- (while (string-match-p comint-prompt-regexp string-buffer)
- (setq string-buffer
- (replace-regexp-in-string
- ;; Sometimes, we get multiple agglomerated
- ;; prompts together in a single output:
- ;; "prompt prompt prompt output"
- ;; Or even "<whitespace>prompt<whitespace>prompt ...>.
- ;; Remove them progressively, so that
- ;; possible "^" in the prompt regexp gets to
- ;; work as we remove the heading prompt
- ;; instance.
- (format "\\(?:%s\\)?\\(?:%s\\)[ \t]*"
,org-babel-comint-prompt-separator comint-prompt-regexp)
- ,org-babel-comint-prompt-separator
- string-buffer)))
- ;; remove echo'd FULL-BODY from input
- (when (and ,remove-echo ,full-body
- (string-match
- (replace-regexp-in-string
- "\n" "[\r\n]+" (regexp-quote (or ,full-body "")))
- string-buffer))
- (setq string-buffer (substring string-buffer (match-end 0))))
- (delete "" (split-string
- string-buffer
- ,org-babel-comint-prompt-separator))))))
+ (org-babel-comint--prompt-filter string-buffer)))))
(defun org-babel-comint-input-command (buffer cmd)
"Pass CMD to BUFFER.
- [elpa] externals/org updated (1be2f96931 -> e9c288dfac), ELPA Syncer, 2024/03/29
- [elpa] externals/org e9c288dfac 7/7: lisp/ob-comint.el: Fix prompt appearing in async shell results, ELPA Syncer, 2024/03/29
- [elpa] externals/org 227cbb5359 2/7: lisp/ob-comint.el: Create comint prompt filter, ELPA Syncer, 2024/03/29
- [elpa] externals/org c2b763dd14 3/7: testing/lisp/test-ob-comint.el: Make test for echo filter, ELPA Syncer, 2024/03/29
- [elpa] externals/org 574e04d119 5/7: lisp/ob-comint.el: Refactor `org-babel-comint-with-output',
ELPA Syncer <=
- [elpa] externals/org 0102988afb 6/7: testing/lisp/test-ob-shell.el: Test async prompt removal, ELPA Syncer, 2024/03/29
- [elpa] externals/org 820a99b171 1/7: testing/lisp/test-ob-comint.el: Make test for prompt filter, ELPA Syncer, 2024/03/29
- [elpa] externals/org 3776eba2f7 4/7: lisp/ob-comint.el: Create comint echo filter, ELPA Syncer, 2024/03/29