Fix sh block execution in session
Hi, When evaluating shell code blocks in org-babel, the execution seems to hang indefinitely. The following patch is trying to fix this problem by modifying the way shell code is send to comint and the way the end-of-evaluation indicator is looking for. As I am far from an emacs lisp expert and as the patch modifies the widely use org-babel-comint-with-output function, it certainly needs some testing. I've made some tests with shell and R code blocks, but I'm not sure it's enough. Thanks ! Julien Fix sh block execution in a session * lisp/ob-sh.el (org-babel-sh-evaluate) : when sending input to comint, wait until previous line execution is finished * lisp/ob-comint.el (org-babel-comint-with-output) : when looking for end-of-evaluation indicator, search forward for the indicator before searching forward for the prompt
This commit is contained in:
parent
648affcbd4
commit
c227da352a
|
@ -93,9 +93,9 @@ or user `keyboard-quit' during execution of body."
|
||||||
(goto-char comint-last-input-end)
|
(goto-char comint-last-input-end)
|
||||||
(not (save-excursion
|
(not (save-excursion
|
||||||
(and (re-search-forward
|
(and (re-search-forward
|
||||||
comint-prompt-regexp nil t)
|
(regexp-quote ,eoe-indicator) nil t)
|
||||||
(re-search-forward
|
(re-search-forward
|
||||||
(regexp-quote ,eoe-indicator) nil t)))))
|
comint-prompt-regexp nil t)))))
|
||||||
(accept-process-output (get-buffer-process (current-buffer)))
|
(accept-process-output (get-buffer-process (current-buffer)))
|
||||||
;; thought the following this would allow async
|
;; thought the following this would allow async
|
||||||
;; background running, but I was wrong...
|
;; background running, but I was wrong...
|
||||||
|
|
|
@ -170,7 +170,13 @@ return the value of the last statement in BODY."
|
||||||
(session org-babel-sh-eoe-output t body)
|
(session org-babel-sh-eoe-output t body)
|
||||||
(mapc
|
(mapc
|
||||||
(lambda (line)
|
(lambda (line)
|
||||||
(insert line) (comint-send-input nil t) (sleep-for 0.25))
|
(insert line)
|
||||||
|
(comint-send-input nil t)
|
||||||
|
(while (save-excursion
|
||||||
|
(goto-char comint-last-input-end)
|
||||||
|
(not (re-search-forward
|
||||||
|
comint-prompt-regexp nil t)))
|
||||||
|
(accept-process-output (get-buffer-process (current-buffer)))))
|
||||||
(append
|
(append
|
||||||
(split-string (org-babel-trim body) "\n")
|
(split-string (org-babel-trim body) "\n")
|
||||||
(list org-babel-sh-eoe-indicator))))
|
(list org-babel-sh-eoe-indicator))))
|
||||||
|
|
Loading…
Reference in New Issue