anonymous function instead of using flet
* lisp/ob-comint.el (org-babel-comint-with-output): Don't name the filter function, but rather pass through the anonymous lambda directly.
This commit is contained in:
parent
5b9cbe9291
commit
2817f68c17
|
@ -75,39 +75,40 @@ or user `keyboard-quit' during execution of body."
|
||||||
(full-body (cadr (cdr (cdr meta)))))
|
(full-body (cadr (cdr (cdr meta)))))
|
||||||
`(org-babel-comint-in-buffer ,buffer
|
`(org-babel-comint-in-buffer ,buffer
|
||||||
(let ((string-buffer "") dangling-text raw)
|
(let ((string-buffer "") dangling-text raw)
|
||||||
(org-flet ((my-filt (text)
|
;; setup filter
|
||||||
(setq string-buffer (concat string-buffer text))))
|
(setq comint-output-filter-functions
|
||||||
;; setup filter
|
(cons (lambda (text) (setq string-buffer (concat string-buffer text)))
|
||||||
(add-hook 'comint-output-filter-functions 'my-filt)
|
comint-output-filter-functions))
|
||||||
(unwind-protect
|
(unwind-protect
|
||||||
(progn
|
(progn
|
||||||
;; got located, and save dangling text
|
;; got located, and save dangling text
|
||||||
(goto-char (process-mark (get-buffer-process (current-buffer))))
|
(goto-char (process-mark (get-buffer-process (current-buffer))))
|
||||||
(let ((start (point))
|
(let ((start (point))
|
||||||
(end (point-max)))
|
(end (point-max)))
|
||||||
(setq dangling-text (buffer-substring start end))
|
(setq dangling-text (buffer-substring start end))
|
||||||
(delete-region start end))
|
(delete-region start end))
|
||||||
;; pass FULL-BODY to process
|
;; pass FULL-BODY to process
|
||||||
,@body
|
,@body
|
||||||
;; wait for end-of-evaluation indicator
|
;; wait for end-of-evaluation indicator
|
||||||
(while (progn
|
(while (progn
|
||||||
(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
|
||||||
(regexp-quote ,eoe-indicator) nil t)
|
(regexp-quote ,eoe-indicator) nil t)
|
||||||
(re-search-forward
|
(re-search-forward
|
||||||
comint-prompt-regexp 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...
|
||||||
;; (run-with-timer .5 .5 'accept-process-output
|
;; (run-with-timer .5 .5 'accept-process-output
|
||||||
;; (get-buffer-process (current-buffer)))
|
;; (get-buffer-process (current-buffer)))
|
||||||
)
|
)
|
||||||
;; replace cut dangling text
|
;; replace cut dangling text
|
||||||
(goto-char (process-mark (get-buffer-process (current-buffer))))
|
(goto-char (process-mark (get-buffer-process (current-buffer))))
|
||||||
(insert dangling-text))
|
(insert dangling-text))
|
||||||
;; remove filter
|
;; remove filter
|
||||||
(remove-hook 'comint-output-filter-functions 'my-filt)))
|
(setq comint-output-filter-functions
|
||||||
|
(cdr comint-output-filter-functions)))
|
||||||
;; remove echo'd FULL-BODY from input
|
;; remove echo'd FULL-BODY from input
|
||||||
(if (and ,remove-echo ,full-body
|
(if (and ,remove-echo ,full-body
|
||||||
(string-match
|
(string-match
|
||||||
|
|
Loading…
Reference in New Issue