astahlman / ob-async

Asynchronous src_block execution for org-babel
343 stars 32 forks source link

View output of process before it finishes #13

Open DvdMgr opened 6 years ago

DvdMgr commented 6 years ago

Is it possible to view the output of the process that is being executed by ob-sync while it is still running? I would like to see at which point of the execution my program is, since it prints progress on the standard output, but I've found no mention of this in the readme. As a possible approach, redirecting the output of the program to a temporary buffer would be fine!

Thanks for the great work!

astahlman commented 6 years ago

I'd love to have this, too. Unfortunately, I can't think of a straightforward way to implement it.

I'm actually not even sure how to do this without ob-async. I think we would first need to ensure that stdout of any subprocess launched by org-babel-execute:$lang is captured in a local buffer. Then we would have to somehow shuttle the contents of that buffer in the inferior Emacs process back to the parent process, which may involve extending emacs-async.

Maybe I'm making it harder than it needs to be - open to ideas if anyone wants to take this on.

astahlman commented 6 years ago

Then we would have to somehow shuttle the contents of that buffer in the inferior Emacs process back to the parent process, which may involve extending emacs-async.

Or maybe we should explore a thread-based approach (available in Emacs 26) instead of using emacs-async. See this comment for details.

preetpalS commented 6 years ago

@astahlman Maybe there is a simple way to do with this tee. See http://man7.org/linux/man-pages/man1/tee.1.html ; it is available on Windows as well (there might be ways to do this natively on Windows as well).

ibizaman commented 5 years ago

@astahlman I was wondering did you try using set-process-filter? I'm monkey patching emacs-async to see if this can lead to somewhere. I've seen it used here https://github.com/gregsexton/ob-ipython/blob/7147455230841744fb5b95dcbe03320313a77124/ob-ipython.el#L279-L297

astahlman commented 5 years ago

Hey @ibizaman, I didn't try it myself but I'd be interested to hear the results of your monkey-patching experiment.

adrianparvino commented 5 years ago

This exists, for prior art: https://github.com/whacked/ob-shstream/blob/master/ob-shstream.el